Shutdown/Startup Schedule
danlee20
Posts: 31
I am attempting to create my own schedule for system startup and shutdown. I would like to create my own module but have never done this. To get started, I need to allow the user to input a date and time in the touch panel.
questions:
How do I pull that info from the text input box in tp4? What I am going to do once I get the data from the input box i will use a compare_string with the time keyword.
Am I on the right track?
questions:
How do I pull that info from the text input box in tp4? What I am going to do once I get the data from the input box i will use a compare_string with the time keyword.
Am I on the right track?
0
Comments
What is the best way to go about this???
As far as how you go about doing it - I suggest you write it down & think of all of the steps necessary to trigger something. Think, for instance, on how you set your alarm to wake you up. You need to input the time. The clock needs to evaluate what time you've entered and compare it against the current time. If it's the same, do something - if not, don't. The logic is fairly simple, in my opinion.
The process of actually shutting the system down can be as elaborate as you want to make it. When I have done it, I use two timelines. One is my feedback timeline that cycles at either 1/2 or 1 second to update specific feedback that would appear on almost all of the screens of a touch panel (such as mic mute status). That is where I check for the shutdown time. What I do is start a two-hour process to shut down the system. This is in case someone is actually using the system after hours. If I see a button press when the timer has started, I restart the timer to give them another two hours of use. I do this so that if someone is really using the system, I give them two hours to finish up. For example, if they are watching a DVD, there could be two hours from the time they start it until the movie is finished. I don't want to shut the system down while they are still using it, so I wait two hours from the last time they pressed a button.
If I am withing the shutdown "window", and I haven't already started my countdown timer process, I start a timeline that has an array of 6 elements. The first is for 1 hour and 55 minutes, and the remainder are for one minute each. When a timeline.sequence is triggered, I pop up a warning message on the panel that says that the system will shutdown in 5, 4, 3, 2, <1 minutes. There is a button that they can press to restart the countdown back to two hours. That way, if they see the message and press the button, I don't bother them again for an hour and 55 minutes.
The reason for the shutdown window, is to prevent the timer from running during the normal operating hours. For example, I will only have the countdown timer running between 7PM and 6AM for most systems. So timeline 2is only allowed to run between those hours. If 6AM comes along and the timeline is active, I kill it.
There are probably a million ways to do this. Back several years ago I needed an auto-shutdown process and this is what I did. It may be completely different if I were to rewrite it today.
How would I go about this?
First - Attend training. Read PI. Read the Netlinx Manual - pick the options that work for your situation.
Second - Make the touch panel page. Decide if you want to use strings, commands, or channels on the buttons you created.
Third - Write the associated code to handle your button presses.
-- feel free to reverse two and three --
Fourth - Test. Fix. Try Again. Possibly post the TP4 file and code on the forums for suggestions.
{
PUSH:
{
SEND_COMMAND dvTPSCHED,"'^TXT-11,0 ',ITOA(nONE)"
}
}
Can you not pass a command through a button event? I am still not getting any text input on the panel.
Looks like you missed the comma after the 0.
I can't see your TP4 file to tell if this is correct other than that.
my code:
BUTTON_EVENT[dvTPSCHED,0]
{
PUSH:
{
SWITCH(BUTTON.INPUT.CHANNEL)
{
CASE 1:
{
SEND_COMMAND dvTPSCHED,"'^TXT-11,0, ',ITOA(nONE)"
}
CASE 2:
{
SEND_COMMAND dvTPSCHED,"'^TXT-11,0, ',ITOA(nTWO)"
}
CASE 3:
{
SEND_COMMAND dvTPSCHED,"'^TXT-11,0, ',ITOA(nTHREE)"
}
}
}
}
Those limitations are defined by you in how you go about programming it. For example you could limit the size of the array stroring the values. or you could follow the length of the pointer, or you could just ignor imputs past 4 values. It all depends upon how you program.
My Code:
BUTTON_EVENT[dvTPSCHED,12]
{
PUSH:
{
SEND_COMMAND dvTPSCHED,"'?TXT-11,0 '"
}
}
This is what I see in notifications:
Line 1 (12:50:45):: Input Status:Pushed [10001:3:1] - Channel 12
Line 2 (12:50:45):: Command To [10001:3:1]-[?TXT-11,0 ]
Line 3 (12:50:45):: Input Status:Released [10001:3:1] - Channel 12
You know they cover all this in programming classes. It'd really do you good to enroll. Your going to find this forum will turn on you pretty soon as you are asking questions that clearly indicate that you haven't been to classes.
Hope that helps.
I don't think you need to go this deep, probably just store them in an char array when you get the TP input that you were appending with ^BAT.
Ha! Shows how much I read in these posts..
You need to create a VT button and assign it to the constant. I called mine "MY_DIGITS_VT_CHNL".
This code will only allow you to enter 4 digits if you enter a 5th it will clear the previous 4 and start over. It will also clear the digits collected if you take longer than 10 senconds between entries.
FYI, this hasn't been tested but should work as described.
Eric- i have been to programmer 1, it is very basic in programmer one. The last few days they go very fast not allowing for any information to absorb. This is not the instructors fault, but rather the time they have to cram information into you. I certainly do not want to get on the forums bad side. Its just, since joining this forum I have learned a tremendous amount!!!
I apologize for the amount of questions I ask, but I do really appreciate everyones help. I came to this forum to learn and be taught from guys like yourself that have been doing this for years. I hope to one day be at a level that you all are at.
Thank you for all your help thus far
I agree that just simply storing the number in a char array would be the easiest & fastest way to do it. When you're done, I think I'll post a way I'd do it. It could turn out to be a fun little exercise.
Almost all of this makes sense. You just showed me a completely different way of thinking about doing this. The only thing I am having trouble understanding is quoted line above. Please forgive me, as im sure its something very simple.
Button that just gets pushed to intiate a PUSH in a BUTTON_EVENT are normally just assigned a channel port & code. If you want to send the TP VT (variable text) you need to send it to a button that has the address port/code set. Usually these buttons don't need the channel port/code set.
If your buttons for these digits are on channel port 2 (for example) and code numbers 10-19 (0-9), 20 (enter) then typically you would create a VT button that has the address port set to 2 and typically the address code of 1 if this is the first VT button you've created. Could be anything but usually you start with 1. For the sake of this code the address port needs to be the same and the channel ports but with slight modifications it could be anything you want but again normally they're the same.
Then the part about the constant would be just creating a contstant with the value of the address code being used for your VT.
DEFINE_CONSTANT
MY_DIGITS_VT_CHNL = 1;// using address code number 1 for your VT
You would mostly likely change that name to something more appropriate or just remove the MY_ portion.
Now anytime you push a digit button you'll send or re-send the string holding your string to your VT text button. Keep in mind everything on the TP is button so when we call a VT field a button we don't typically intend it to be pushed but just used as a display. Later when you start doing music lists they'll become both buttons for pushing and displays for VT buts that's not until we get to chapter 6 in our text book.
I am still working on building my schedule and have figured quite a bit out. I was quite sick for about a week so I to take some time off.
To use the TIME function in netlinx, is this a data event? Here is an example of what I have tried but gotten no results.
DATA_EVENT[dvIO]
{
Push:
{
IF(TIME = 23:00)
{
on[dvIO,2]
}
}
}
That is an example I tried just to expieriement with the time call. It is almost exactly what is in th manual, so im curious as to why it is not doing anything. I also cannot find anywhere wher I can change the Netlinx time and date format. Is the possible?
Thanks in advance
IF(TIME = '23:00:00')....
In NetLinx Studio, press "Help" then click on "NetLinx Keyword Help." Or, highlight the word TIME and press F1.
You said it was "almost exactly what is in the manual" - what manual?
Your trying to process a push in a data event and IO's only have ONLINE: or OFFLINE: events possible in data_events. Typically you just set IO port parameters in the ONLINE handler of the IO's data_event like: Now for your PUSH you need to create a button_event so do some reading on them. You could also do a channel_event instead with ON: & OFF: handlers.
Then you have a logic issue with your code using the IF(TIME = 23:00) which should be IF(TIME = '23:00:00') as posted earlier but that will only ever work if your push event occurs at exactly 23:00:00 so you basically have a 1 second window each day when an IO push will fire off that code.
What are you trying to achieve? If you're just trying to set the IO channel to to on at 23:00:00 then just drop in define program or a timeline. For new programmers define program is the easiest to accomplish but put it after a wait 5 or something so it only runs and compare the time every 1/2 second rather that 6000 (?) times a second. Also keep in mind that the time 23:00:00 will be true for a full second and while that seems short to us the processor could run through that code thousands of times and each time executing your code. Not so bad if you're just turning on the IO but other code could cripple your processor so the wait 5 will only allow it to fire twice at most. If running other code, not just setting your IO you'd want to add a flag or a wait 10 so the code only fires once.