Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sat Nov 18, 2017 6:03 pm

All times are UTC - 7 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Format Numeric Display
PostPosted: Thu Dec 01, 2011 10:39 am 
Offline

Joined: Thu Dec 01, 2011 9:53 am
Posts: 2
Hardware: Opto22 G70 OptoTerminal
Software: Qlarity Foundry v2.501 for Opto22
I am displaying a 2-term totalizer using the OptoIO_Label object from the OptoIO_Control library. The tags in the Opto brain are each 32-bit integers. One will display a value in thousandths of acre-ft and one displays whole acre feet. I'd like to position two displays adjacent one another to show the composite value. The display for the least significant value will have a prefix of "."; I would also like it to display leading zeroes so it will show ".001" when the tag holds a value of 1. I don't see a way to do this using the standard properties of the object.

Thanks for any help you can offer.


Top
 Profile  
 
PostPosted: Thu Dec 01, 2011 11:02 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
There are a few ways to tackle the problem.

The first is to use the Opto controller to combine the numbers into a single floating point value or string value. If you are comfortable using scripting/charting on the controller this may be the simplest solution.

If you prefer a solution entirely on the HMI, then it can be done as well, although it is slightly more complex.

How I would start is to remove your two OptoIO_Label objects and in their place create a single LabelV2 object, which I will call AcreFeetValueLabel for the purposes of this example.

I will then add the following global code (in Code View)

Code:
dim intPart as integer
func intPart (newVal as integer)
    if newVal <> intPart then
        intPart := NewVal
    endif
    SetupLabel()
endfunc

dim fractionPart as integer
init fractionPart := default
func fractionPart(newval as integer)
    if newVal <> fractionPart then
        fractionPart := newval
    endif
    SetupLabel()
endfunc

func SetupLabel()
    AcreFeetValueLabel.value = str(intPart) + "." + right("000" + str(fractionPart), 3)
endfunc


Next, create two OptoIO_VirtualVariable objects in the screen that contains the label. Configure them to query the appropriate variables in your strategy and then add the following code to them:
Code:
func QueryIntegerSucceeded(QueryID as integer, value as integer)
    intPart = value
endfunc


and

Code:
func QueryIntegerSucceeded(QueryID as integer, value as integer)
    fractionPart = value
endfunc

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
PostPosted: Thu Dec 01, 2011 12:19 pm 
Offline

Joined: Thu Dec 01, 2011 9:53 am
Posts: 2
Thanks for the reply.
I think I will build a string in the Opto controller. I need to be able to display numbers with greater than 7 significant figures and maintain precision in the 0.001 range, so floating-point is out.
This code looks clever, but I'm leery of putting too much scripting on the terminal because I've seen issues with them bogging down. There is already a lot going on with this terminal and the display in question has dozens of live values on it plus 8 values that would require this scripting.
I was hoping for a simple tweak to automatically format a display with leading zeroes.
Cheers,
Max


Top
 Profile  
 
PostPosted: Fri Dec 02, 2011 8:28 am 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
The script Jeremy is suggesting shouldn't hurt performance. If you are having performance issues, make sure that you are not using any TTF fonts (specifically for dynamically updating objects), they can be very slow. Change them all to BDF and you should see a difference.

_________________
Ron L.

http://www.beijerelectronicsinc.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours


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:  
cron
Powered by phpBB® Forum Software © phpBB Group