Alarm Logging


Recommended Posts

HI, i'm trying to configure the alarm logging to MySql Via ODBC

My ODBC connection is good and is used for general logging.

the Error is as Follows

C1021 Could not create table for alarm logging. Msg: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SHORT, Status TEXT(1))' at line 1

Now when when look in MySql i don't have a Datatype 'Short'

Is it possible to manually create the table via SQL Script to avoid this error

Link to comment
Share on other sites

Yes, that would be the easy solution. DAQFactory only tries to create the table if the INSERT command fails (which usually happens when the table doesn't exist). Here's the SQL string used:

CREATE TABLE ALARMLOG (TheTime DATE, Name TEXT(100), Description TEXT(255), Priority SHORT, Status TEXT(1));

Just adjust it for your data types. The INSERT command looks like this (inside a printf, thus the % specifiers for actual values):

INSERT INTO ALARMLOG (TheTime, Name, Description, Priority, Status) VALUES (%f,'%s','%s',%d,'%s');

Link to comment
Share on other sites

Ok I think we are getting there,

Why are my problems never straight forward.

On MySQL i have enabled the Global Logging.

The Insert Command for the alarm log is failing, Hence DAQ trying to create a new table with DataType 'SHORT' and that creates another error.

When i monitor the Queries for both a Logging Set and the Alarm Logging I get the following

INSERT INTO ALARMLOG (TheTime, Name, Description, Priority, Status) VALUES (40596.535624,'Min_Close_1','Axis 1 Min Close Abort Triggered 1 Times + Min_Close_Triggers_1',4,'F')

INSERT INTO test (TheTime,Actual_Position_0) VALUES (1298379082.500067900000,50.000000) // None Excel Time

test is my test data logging .

Note the Difference in Time Stamp.

The Default logging is not using Excel Time,

With Excel Time enabled

INSERT INTO test (TheTime,Actual_Position_0) VALUES (40596.546892363462,50.000000)

and then we generate an error?

I have managed to get the logging working by forcing the 'TheTime' data type to a Double

i will do the conversion to real time when i retrieve the data

Any idea's ?????

I don't like having workarounds,

Causes deployment issues

Link to comment
Share on other sites

The built in logging for alarms was designed for logging to Access (and presumably MSSQL, but really Access) because at the time that was what most people used. Access takes date/time stamps the same way Excel does: decimal days since 1970. Anyhow, that is why the difference.

The best solution is probably to use the Alarm events and do the logging yourself in script. Then you can log what you want in whatever format you want. That is kind of what DAQFactory is about. You can do a lot of stuff really easy, but you don't get a lot of choices that way. We could give more choices, but then it'd be more complicated, and we could never cover what every customer wants. Its better, in our opinion, to just offer scripting tools to allow you to do whatever you want in these cases. Fortunately, we don't force you to choose between scripting and using these easy to use tools. You can take advantage of the ease of built in Alarms, and then use the events on those alarms to log the data however you want.

Link to comment
Share on other sites


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