Adding a sleep in the basic program

when My program starts I loop though and add all tags to a ONCHANGE event, at the same time I call a function the calls the http request to my IIS, but it seem to filling the queue as the calls in the loop are to fast. How can I put a statement in before my call to the IIS to wait or pause so not to fill the queue.

I have about 360 Tags.
code:

n% = GETSYS PRG, “NBTAGS” // Get all of tags as an int
DIM tagInfo$( n%, 50) // create an array with enough indexes to fit all tags
// Print "Number of Tags: " + Str$(n%)
FOR i% = 0 TO (n% - 1)
SETSYS TAG, “load”, -i% // -i% for index correction
t$ = GETSYS TAG, “name” // Load tagName (includes Room:Tag)
i$ = GETSYS TAG, “id” // Load Tag Index

// save tag and index for updating polled values from db

TagInfo$((i%+1), 1 TO 46 ) = t$ // tag name
TagInfo$((i%+1), 47 TO 50 ) = i$ // tag index

// Print "Full Tag name: " + t$ + " - Tag Index: " + i$
//
ONCHANGE t$, “@updateServer(’ " + t$ + " ', ’ " + i$ + " ’ )”
// Init Load new values after startup

@updateServer( t$ , i$)

LOGEVENT “add tag to onchange event” + t$ + i$, 120

NEXT i%

— logs

I would recommend using ONTIMER in the section. Have it start a timer and use TSET to set a delay for X seconds.

You could use a timer and then when the timer fires call the IIS.

Just a heads up the queue will only handle ten calls before it is full.

1 Like

any example how I would implement this with the function call to @updateServer( t$ , i$)

I am very new to this form of basic coding.

how would I set this up for the function above: @updateServer( t$ , i$)

what happens when the queue is full, does it discard any more request to call the iis?

Hi @wizardontherun

I think some example code that would work for you.

delay example.txt (442 Bytes)

They fail.

I under stand how it works but how would I add it into my code, from above with the ONCHANGE t$, “@updateServer(’ " + t$ + " ', ’ " + i$ + " ’ )” function. So if I have 25 tags that trigger the onchange function call, it will pause the on updateserver function to 1 sec sleep.

Just need to make sure the queue does not fill up and drop requests

MOVED TO STAFF NOTE (355 KB)

You should just be able to add the code you want to execute into this section of the example

Function timeroff()
Print"Function was executed after a 5 second delay" //In this section you can perform the actual delayed function
Tset 1,0 //Turns the timer back off afterwards
Endfn

Right now it’s set for a 5 second delay, so you’d need to change the tset to be 1,1 instead of 1,5. But other than that you should just be able to include it in the function Timeroff.

You’d also want to make it so that your onchange will trigger timer 1 to turn on

did not work as planed, when I have 10 values that change it calls the function and completes all changed values, then pauses for the 1 sec or it pauses 1 sec then does all the changed values.

I need t have a something like for to loop that will make the code waste 1 sec of time before going t the next statement, like a sleep/wait type function. I can do a for to but not sure how long it will take to loop to the end value for 1 sec.

Really need this as the onchange is filling the queue and we are loosing data being posted to our IIS server.

Help from any one would be great.

Hi @wizardontherun,

The function above should be able to put a 1 second delay with an Onchange but if you’re looking for a For loop example these might be helpful references

https://techforum.ewon.biz/thread-257.html

Just wondering why you do not use the data mailbox. Let the Flexy upload the data to the mailbox and then grab it from there for use in your IIS server. No data will be lost and then can handle the number of tags.

I all ready have the receiving api on the iis, and my script also retrieves changed data from the iis and updates the flexy tags. but I dont have a clue on using the data mail box.
I thought this would be an easy way to update the iis (mssql) data for our app.
do you outsource your programming, if we change to that route? or help in the flexy issue?
frank.perryman@daserco.com

Currently I just help when I can through the forum.

There is also the option to have the Flexy use your own data mailbox if you wanted to create an API for taking that data in.

the one problem we have is the data has to be updated to/from the flexy in almost real time so the client app and the almost real time current information on the plc. I do have a problem waiting for support that I created a FOR TO NEXT and getting an error.

141 i% = 0
142 FOR i% = 1 TO 1000000
143 Print “…”
144 NEXT i%
145 Print "End Delay " + Time$

image

https://techforum.ewon.biz/thread-257.html

Do you have the programming reference guide? Also found the link above using Mr. Google.

Topic closed due to inactivity.