Hi,
In my current project, I have several finite state machines that control a few AGVs that transport material.
As its current state, the AGVs generate a readable verbose output each time they transit from one state to the next (even if they just reload the state after some time). I filter the output by using an RBE node, so the verbose is only generated if the new state is different from the previous one.
For better debugging, I added a JSON column to the MySQL database, and was planning to pass the whole JSON object holding all the information for the AGV (configuration, job and status information, feedback from the fleet manager).
A full agv JSON object looks like this:
{"config":{"FMS":"192.168.2.241:443","IP":"192.168.2.247","name":"AGV53","robot_name":"robot_10053"},"AIC":{"fsm_state":"IDLE_NO_POS","verbose":"AGV53 is idle somewhere"},"incubed":{"availability":"REGISTERED","action":"GOTO_TARGET","actionState":"FINISHED","actionError":"NO_ERROR","goal":"14-8","executionMode":"NONE","voltage":53.12,"amperage":-2.7,"chargestage":"DISCONNECTED","batteryissue":"NO_ISSUE","errorcode":0,"linearspd":0,"angularspd":0,"xpos":14.144,"ypos":41.178,"bearing":-91.631,"cpuUsage":120.1,"coreTemp":53}}
And the function I'm currently using to write to the MySQL DB is the following:
// Prepare the SQL string for GLOBAL
var SQLstr = "INSERT INTO unit_1.agv_verbose (log_id, log_ts, agv_name, status_line)";
SQLstr += " VALUES ( UUID(), current_timestamp(), \"" + msg.agv.config.name + "\", \"" + msg.agv.AIC.verbose + "\");";
msg.topic = SQLstr;
return msg;
Now, the DB has an additional column called agv_obj that it is defined as a JSON object, but I don't know how to pass it onto the DB.
What I thought first is to just queue the JSON string, but then I need to replace all the quotes in the JSON by ("), or it will have parse errors when I pass it onto the MYSQL node, right?
Is someone aware of a more efficient way of doing it?