Dynamically create a component and function on a page


Recommended Posts

Say there is a enviroment monitoring sensor network over a map. We would like to do the following:

We create a page for "sensor installation". By inputting the sensor's coordinates, Daqfactory is enable to draw a sensor on the map page. So after "installing" four sensors, we will see the four sensors on the map page with its measurement displayed with each one.

Then when we click one of the sensors, its details page pops up. And if we do some adjustments, the control can be sent to that corresponding sensors.

Is Daqfactory able to do such application? Thanks.

Link to comment
Share on other sites

Yes, you can do that, but DAQFactory does not currently support dynamic creation of screen components, so you'd have to premake a certain number of "sensor" displays. I'd probably name them such as S0, S1, S2, etc. I'd give each a quick sequence action that calls a sequence function that takes a sensor number as an input. Then you'd only have to create one function for all the sensors. Then you can make them invisible by doing:

component.s1.visible = 0

or = 1 to make it visible. Of course you'd substitute s2, s3, etc for s1.

Then, you would need to come up with a way to convert your map coords to screen coords. Not really that hard, just a little algebra. You can then move any of your preset components using:

component.s1.moveto(x,y)

where x and y are the coords you want to move (where 0,0 is top left corner).

Finally, if you want to create a loop or similar to cycle through components, or otherwise access them using a variable, you would use the execute function. For example, to make the components s0 through s9 invisible you'd do:

for (private x = 0, x < 10, x++)
   execute("component.s" + doubletostr(x) + ".visible = 0")
endfor

Overall this sort of app is really quite easy. Feel free to post if you have other questions.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.