Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Chinese brand PSU_monitoring rs485 and Mango


  • Well, looks something is working :

    0_1478299096889_upload-f087c10f-9c3c-4807-abed-a0e87d2523ed

    i ques this is normal ?


  • Alright. made some changes as, reading where not what the should be. now i get the right results from reading the Hex.

    Script "message Queue"

    // get Hex from source
    
    var busVoltage = /[0-9A-Fa-f]{30}([0-9A-Fa-f]{16}).*/.exec(source.value); 
    var extractedValue = busVoltage[1];
    
    var PsuLoad = /[0-9A-Fa-f]{78}([0-9A-Fa-f]{16}).*/.exec(source.value); 
    var extractedValue = PsuLoad[1];
    
    // Alarm relays Bit ( 1 is Alarm )
    var Alarm = /[0-9A-Fa-f]{185}([0-9A-Fa-f]{1}).*/.exec(source.value); 
    var extractedValue = Alarm[1];
    
    // door alarm Bit (1 is Door open )
    var DoorAlarm = /[0-9A-Fa-f]{185}([0-9A-Fa-f]{1}).*/.exec(source.value); 
    var extractedValue = DoorAlarm[1];
    
    
    var message = busVoltage[1];
    
    function toASCII(message) {
      var result = "";
      while(message.length > 1) { //parse two characters at a time
         var charCode = message.substr(0, 2);
         result += String.fromCharCode( "0x" + charCode );
         message = message.substr(2); 
      }
      return result;
    }
    
    // swap bytes /hex
    
    function swap32(val) {
    return ((val & 0xFF) << 24)
           | ((val & 0xFF00) << 8)
           | ((val >> 8) & 0xFF00)
           | ((val >> 24) & 0xFF);
    }
    
    //print (message);
    
    
    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);
    }
    
    
    function roundToTwo(num) {    
        return +(Math.round(num + "e+2")  + "e-2");
    }
    
    
    // covert Hex to String
    var subresult = (toASCII(message));
    // create human readabe number
    var result = (roundToTwo(hex2float("0x" +subresult)));
    
    // send payload
    return target.value + "MainAlarm-" + Alarm[1] + ";" + "Door-" + DoorAlarm[1] + ";" + "busvolt-" + result + ";" ;
    
    

    at this point i get as result : MainAlarm-0;Door-0;busvolt-53.68;

    thats correct.

    so i have right input , further i am still completely lost in how i should proceed.

    i added my other (modbus) device and thats straight forward , enter the source and add data points to it. thats easy.
    now why cant i see the logic for the other source..


  • Did made some progress, via an other approach ;

    Created : tcp/ip source ( 2 sec update period )
    Created : Data Point to that :

         "loggingType":"NONE",
         "dataType":"ALPHANUMERIC",
         "queryable":true,
          "readCommand":"<your_hex_request_for_your_device>",
          "settable":false,
          "valueIndex":0,
          "valueRegex":".*",
    

    Created META-source
    Created : Data Point to that :

         "name":"DoorAlarm",
         "enabled":true,
         "dataType":"ALPHANUMERIC",
         "updateContext":true,
         "varName":"p110"
    

    added in script field :

    // get Hex from source
    
    // Alarm relays Bit ( 1 is Alarm )
    var DoorAlarm = /[0-9A-Fa-f]{185}([0-9A-Fa-f]{1}).*/.exec(p110.value); 
    var extractedValue = DoorAlarm[1];
    
    // payload
    return "DoorAlarm- " + DoorAlarm[1];
    

    ...

    So i added some other "Meta-data points" for other values.
    This works ok, and i can understand how it works.

    Now the first approach has probably benefits in setting up many same kind devices/values i guess , so i am focusing on that as well , as i would like to understand how that should work.


  • The first approach's benefit is just somewhat more efficiently extract many points' values from a single message. You can still do that with meta points, where the incoming message provides a context update to all the meta points. Also, you can return the DoorAlarm[1] in the meta point if the meta point is Numeric and it will be treated as a Numeric. The "DoorAlarm" string portion is just to identify the point in the object (map, dictionary) in the script, where the value portion would be set out to data points created on the scripting data source. Those points on the scripting data source would ultimately be used for displays or dashboards.


  • Thanks Phil(lips) , i am going to play with it , little stupid off topic question :

    "How to purge all Information on "Urgent events" or "information " . seems there is no option/knob when viewing the list. ( clear dates , seem to do nothing when selected periode )


  • Events can be purged from the system settings page, as well as setting a system policy for purging old events, and you can set the data source's event levels to DO_NOT_LOG if you expect it to generate a lot of events on the data source's edit page.

    I am not sure what you're refering to as 'clear dates' so I may not have understood exactly correct. Events on the events page (/events.shtm) get 'Acknowledged' to clear them from a user's view in the header. Actual deleting is handled by the purge settings in the system settings page, under "Purge settings"


  • i was refering to this :

    0_1478634603932_upload-0ef18116-152a-4813-84f0-59d3cf60c4e5


  • Ah, got it. So, to the right of that button are two date input fields. These restrict the range of the events in the display, and those which are acknowledged with the "Acknowledge all in view" button. The "Clear Dates" button just empties these fields, such that there is no date restriction on the events displayed on the page.


  • i do see now, i got some Years in there that are far from now, gehehe . thats why it didnt had effect probably..

    thnx for the pointers.


  • You can also run:

    delete from events
    

    In Mango's SQL console to flush the events table.
    Also, this thread is 💯. Great work all.