Hi! I am trying to program an aquarium computer using Perl. It reads sensors from the one-wire network. The network is up and running and i am allready reading the sensors, but i need some help.
Let's assume that i have 2 sensors:
temp1 and temp2
The main application waits for a sighup/sigterm/siginit to abort the application. Waits for the threads to finish and then dies. This allready works.
"temp1" and "temp2" are fired as different threads; Each subroutine is an infinite loop (as long as there is no signal) and does nothing more then read a file on the local file system, prints it and sleeps 5 seconds and then does that same trick again. This also works.
Normally the temperature is set to 25. If it falls below (e.g. 24.8), the heater is activated, it if rises above 25.2 the cooler is activated.
Now; i want to be able to control some values (Nominal, Hysteris etc) from a website. And i would like those changes to be instant.
For example; lets say i set the nominal value to 20C, and the temp is 24.7 i want the cooler to be instantly activated. Since the thread is allready running (and it may be in a "sleep 5" state) i don't know how i would do that.
First i though of sockets (e.g. the main application waits for an incomming connection/command and if it receives that, the threads get recycled) but i could not get that to work.
I hope you still follow me. How would i do such a thing?
-----
Next step is lightning (basically thesame scenario):
The application is running the lightning program. It is currently 08:00, and the lights are at 0%. The next settings is 08:15 and the lights should be at 50% intensity. This can be done fairly easily.
But what if the user changes the lightning scenario at 08:10 (from the website), meaning that the lightning thread has to reinitialize since the curve shifted?
How would you accomplish such a task?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.