Chinese brand PSU_monitoring rs485 and Mango
-
Perhaps the device holds open the connection and your timeout is set to 0? I would give it a try with a 1000ms timeout or so.
-
Nope, reboot did not help, rebooting device and connections did not help.
settings :
-
Your value index is wrong. It should be 0. and your value regex can just be
.*
-
i removed everything and restarted Mango.
The "value index: set to 1 was indeed the bottleneck. ( i checked to see what difference 0 or 1 made.
so i have data again,
The errors
"
WARN 2016-10-31 23:57:49,316 (com.serotonin.m2m2.rt.dataSource.PollingDataSource$2.execute:228) - PSU-tcp_ip: poll scheduled at 2016/10/31 23:57:49.316 aborted because Task Currently Runnining
"
in terminal are still there do.i don t care at the moment, as getting things running is more important to me at the moment.
now i start building COMMAND and RESPONSE from the beginning of the forum..
-
I mentioned how to fix that, you would turn your timeout down from 50000 ms to less than your polling interval, so less than 5000.
-
That fixed it indeed.
i noticed i can check scripting code by clicking on the "little green Script dot".
Its still not clear to me.
-
Data source collects makes connection to device. ( interval for set here )
that is the easy part, -
tcp/ip Data point asks for data ( command data point )
-
tcp/ip Data point response listen for data
-
tcp/ip Data point "link" this to Scripting data point, "message queue" datapoint.
-
in the "link" script screen i put in ?? which pieces of code ?
-
in the Script Data source i also put in which pieces ?
i tried a lot of combinations, but i don t see it.
-
-
Response --> Point Link to parse values --> Scripting Data Source to process message queue into points' values
-
Alright i got it. thnx.
i had little play with :
var busVoltage = /[0-9A-Fa-f]{46}([0-9A-Fa-f]{8}).*/.exec(source.value);
var extractedValue = busVoltage[1];print (busVoltage[1]);
Script result:
42453939so that works, i found code for converting the hex to float, but no knowledge of writing (java) coding structure is a show stopper at the moment. but i do have fun learning , gehehe
-
Nice!
All the scripts use JavaScript.
-
little update ,
i found that i need to convert in javascript the with sort of
function hex2float(num) { var sign = (num & 0x80000000) ? -1 : 1; var exponent = ((num >> 23) & 0xff) - 127; var mantissa = 1 + ((num & 0x7fffff) / 0x7fffff); return sign * mantissa * Math.pow(2, exponent); } window.alert (hex2float("0xA4703942")); //flipped does the trick window.alert (hex2float("0x423970A4")); // outcome 46,36..... ( not rounded ) `` so little progress here.
-
Perfectum Resultativum ;
-
now put all this in Mango needs again some pointers i think..
-
i got this in " point links as script " , is this ok ?
and what to put in :
the script - source script. ?
i tried 1000 different combinations. and reading the wiki / manuals. but sorry, i don't
get it... -
Looking at your message queue, there are no identifiers. I assume this is because this is always for the same point. You could connect the point link to a point directly representing that value, if there is only one point's value in a message. Otherwise, you'll want some identifiers so that your script can parse the message queue and set points identified by the identifier to the value. I would have the identifiers in an object, where the object looks something like...
{ "identifier1" : p334, .....}
Where p334 is the variable name for the context point of the script.
-
identifiers, object etc, is probably JavaScript terms....hmm and i was thinking it was almost done, gehehe.
i need a neighbor with programming skills ( the neighbors house is for sale btw )
so back to learning books .. -
Ha! Well, we'll see how the politics here go ;)
Identifier is just a name that you can use in both places. Object is a JavaScript term for things defined as { "key": value }. Other names are Map and Dictionary.
-
ok learned "Object"
Can someone point me some explanation links about :
var identifierMap = { "messageIdentifier" : contextPoint1 .... }
cant find much on " indentifierMap " on internet somehow.
-
That's just a variable name, so that later in the script you can type
var ident = "messageIdentifier"; identifierMap[ ident ].set( /*your value here*/ );
Where context points are added to the script through the UI of the Scripting data source.
-
"messageIdentiefier" is the variable/object coming from point link script right ?
-
Yeah. It looks like right now you're setting message queue to something like
49.73;49.73;49.73;
The identifier would be useful if you have multiple values to get out of a message. You explicitly know their positions when you extract the values, so you can give them something you can identify them with. So instead your message queue may look like,
busVoltage-49.73;busVoltage-49.73;busVoltage-49.73;otherValue-106.2;yetAnotherValue-78.1;
such that you could identify where to set those values out to in the script.