It is currently Fri Apr 18, 2014 12:44 pm




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
 Keypad Entry Allowing Values Outside Range 
Author Message
Sergeant
Sergeant

Joined: Tue Jul 12, 2011 4:36 am
Posts: 59
Location: St. Louis, Missouri USA
Post Keypad Entry Allowing Values Outside Range
I'm working on a script that shouldn't allow a value to get passed through to the PLC if it outside the range. But the value is getting passed to the PLC when it is outside the range.

Code:
spLow = event.source.parent.getComponent('ledSetpointLow').value
spHigh = event.source.parent.getComponent('ledSetpointHigh').value
keyPad = event.source.getComponent('ledSetPointSpeed').value = system.gui.showNumericKeypad(event.source.getComponent('ledSetPointSpeed').value)

if  keyPad <= spLow:
   system.gui.warningBox("Setpoint too Low")
   
elif keyPad >= spHigh:
   system.gui.warningBox("Setpoint too High")
   
else:
   keyPad


I'm thinking there is something I might be missing in the script to cancel the action if the value is outside the range.

_________________
Jesse Reynolds
Senior Controls Engineer
Jordan Industrial Controls


Tue May 22, 2012 9:26 am
Profile
Moderator
Moderator

Joined: Sun Apr 02, 2006 2:46 pm
Posts: 1982
Location: Sacramento, CA
Post Re: Keypad Entry Allowing Values Outside Range
You need to do something like this:
Code:
spLow = event.source.parent.getComponent('ledSetpointLow').value
spHigh = event.source.parent.getComponent('ledSetpointHigh').value
keyPad = system.gui.showNumericKeypad(event.source.getComponent('ledSetPointSpeed').value)

if  keyPad <= spLow:
   system.gui.warningBox("Setpoint too Low")   
elif keyPad >= spHigh:
   system.gui.warningBox("Setpoint too High")
else:
   event.source.getComponent('ledSetPointSpeed').value = keyPad
You only set the property when the value is in the right range. Before you were setting it at the same time you return it from the showNumericKeypad function.

_________________
Travis Cox
Inductive Automation
Technical Support Rep.


Tue May 22, 2012 9:37 am
Profile WWW
Sergeant
Sergeant

Joined: Tue Jul 12, 2011 4:36 am
Posts: 59
Location: St. Louis, Missouri USA
Post Re: Keypad Entry Allowing Values Outside Range
I see what I did wrong, Thanks. But if those high and low values are put on the tags EngLow and EngHigh meta properties shouldn't the error be caught there before it's passed to the PLC?

_________________
Jesse Reynolds
Senior Controls Engineer
Jordan Industrial Controls


Tue May 22, 2012 9:42 am
Profile
Moderator
Moderator

Joined: Sun Apr 02, 2006 2:46 pm
Posts: 1982
Location: Sacramento, CA
Post Re: Keypad Entry Allowing Values Outside Range
No, only if we use those meta values.

_________________
Travis Cox
Inductive Automation
Technical Support Rep.


Tue May 22, 2012 10:05 am
Profile WWW
Sergeant
Sergeant

Joined: Tue Jul 12, 2011 4:36 am
Posts: 59
Location: St. Louis, Missouri USA
Post Re: Keypad Entry Allowing Values Outside Range
Use them in the script? Because the event.source.parent.getComponent('ledSetpointLow').value and event.source.parent.getComponent('ledSetpointHigh').value are bound to those meta properties.

_________________
Jesse Reynolds
Senior Controls Engineer
Jordan Industrial Controls


Tue May 22, 2012 10:09 am
Profile
Moderator
Moderator

Joined: Sun Apr 02, 2006 2:46 pm
Posts: 1982
Location: Sacramento, CA
Post Re: Keypad Entry Allowing Values Outside Range  Topic is solved
Right, you are using them in the script. If you didn't have the if checks the showNumericKeypad doesn't know what the high and low are.

_________________
Travis Cox
Inductive Automation
Technical Support Rep.


Tue May 22, 2012 10:32 am
Profile WWW
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: