News:

Welcome on our forum!

Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - jamesant

#1
We have got a server running where it

periodically receives packets of data and parses them,
then runs the script execute module to check the data is valid,
then writes an OK back if the data is alright,
or discards the packet if it was corrupt,
then if the packet was not discarded it writes the values into an SQL database.

But on some occasions the script execute module does not run, so the packet gets written to the SQL database without being checked by the script execute module. Then the same packet is received again (because no OK was sent last time) and the database gets lots of duplicate data.

Eventually (Maybe 5 or 10 minutes later) the script execute module starts running again, and all returns to normal.

What could be the cause of the script execute module not running - is it likely to be related to errors in the SQL write perhaps ?


#2
I tried using the deadband filter, but found it didn't do what I needed

I solved it by changing the sql query.
It deletes the record if it wrote a null value into the Temp1 column.

insert into ADatabaseT1
values (:P1,:P2,:P3)   
delete from ADatabaseT1
where Temp1 is null 
#3
How can I stop the SQL database plug-in from carrying out an SQL query if any of the values it needs to write is NULL ?

For example

insert into ADatabaseT1
values (:P1,:P2,:P3)   

if the value of P1 is NULL, I want the sql query to be skipped
#4
I get
Undeclared identifier: 'DataPacket' if I try and use DataPacket() as a function.

I am using C++ script.

I searched for DataPacket in the forum posts and found the answer in another thread :

string sName1 = "DATA_PACKET";
string data;
{
   data = GetVariable(sName1);
   ShowMessage(data);
}

Thanks for the clue.
#5
How do you access the whole data packet ?

I can see how to access individual variables, but not the whole packet.

#6
Does the script get executed before the ascii parser and the sql database write ?

If so, I can write a script to reject bad data before it gets any further. If not, will it be too late by the time the checksum is checked in the Script execute plugin?

How do I access the incoming data in a script ?
Is there some sort of global array of received characters to process ?
#7
I am receiving data using the Advanced TCP/IP data logger like this:

$25623,25637,49414,25616,44142,54216,-68682,131008150028,0660\r\n

The last 4 digit value is a checksum of the previous 8 values.

I want to be sure the data is correct before it is put into an sql database, and reply with an OK to indicate that the data can be deleted. If the checksum is wrong, I need to discard the data and reply ERROR to get the data sent again.

What is the best way to do this?

I can change the format of the checksum if required.