• ThomasEinasto

    I would also be interested for more information in the GT version of ES.

    posted in Hardware read more
  • ThomasEinasto

    @MattFox I was hesitant to give my 2 cents about this but we also have been come into contact with this issue where eMMC drive has become corrupted.

    posted in MangoES Hardware read more
  • ThomasEinasto

    @jorge-gonzalez said in Script to convert from Hex to Dec:

    13:32

    @Jorge-Gonzalez, documentation to solve your problems.

    Firstly see what parseInt does - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt

    There you can see that the hexdecimal value has to be in correct format be it with 0x or without. Your string splits 2 bytes in the hexdecimal format by using a colon. You need to remove it. Simply do it by utilizing .replace method on a string before putting it into parseInt. Or if you have a string which contains multiple values utilize .split method on a string and then put the bytes together before putting the value into parseInt.

    Replace method explanation
    https://www.w3schools.com/jsref/jsref_replace.asp

    Split method explanation
    https://www.w3schools.com/jsref/jsref_split.asp

    Following function is following the detailed explanation you provided in the post.

    function stringsplitter (string) {
    
    var result = {};
    
    // This contains the bytes of data
    result.arrayofbytes = string.split(':');
    
    // Get byte count of data inside the string
    result.bytecount = result.arrayofbytes.length;
    
    // Start at the beginning
    var variablecounter = 0;
    
    result.hexdata = [];
    result.decimaldata = [];
    
    // Loop over the array, but taking into account that we have 2 byte data, use try/catch so that function will return if something should fail
    try{
    for (var x = 0;x < result.bytecount / 2;x++){
     
    result.hexdata[x] = result.arrayofbytes[variablecounter] + result.arrayofbytes[variablecounter+1];
    result.decimaldata[x] = parseInt(result.hexdata[x],16);
    variablecounter += 2;
    
    }
    }catch(err){
     return err
    }
    
    
    
    
    // return object with all our data which includes hexdecimal data, decimaldata and byte count inside the string
    return result;
    
    }
    
    // Example usage
    
    var devicestring = '13:30:27:14:01:33:02:6c:02:76';
    
    var data = stringsplitter(devicestring);
    
    //get array in hexdecimal and decimal format
    var hexdata = data.hexdata;
    var decimaldata = data.decimaldata;
    
    // first value in hexdecimal and decimal format
    var firstvaluehex = hexdata[0];
    var firstvaluedecimal = decimaldata[0];
    
    // Second value in hexdecimal and decimal format
    var secondvaluehex = hexdata[1];
    var secondvaluedecimal = decimaldata[1];
    
    // Following that your post had used an example with the last value
    
    var lastvalue = decimaldata[4];
    
    // Should be 23
    var lastvaluecorrected = lastvalue * 0.1 - 40;
    
    

    Thomas

    posted in How-To read more
  • ThomasEinasto

    @steve-o said in Calculation using ^ (to the power of) in a Meta Data Point:

    (610.7*10^((7.5x23)/(237.3+23))/1000)

    Steve, what is your temp variable? Is it the name of your variable? Then you should use this:

    (610.7*Math.pow(10,((7.5*temp.value))/(237.3+23))/1000) 
    

    Following works as it should on math pow

    (610.7*Math.pow(10,((7.5*23))/(237.3+23))/1000) 
    // returns 2.808825816730143
    

    posted in User help read more
  • ThomasEinasto

    @jared-wiltshire said in Why this kind of <style> can not work?:

    @Zhilin-Chen
    Open up the Chrome debugger (Right click, inspect element) and confirm that

    • The classes are being applied to the element(s) you are trying to target
    • The styles from the class are not being overridden by a higher priority rule or inline style

    @Jared-Wiltshire So basically adding !important to style solves it right?

    @Zhilin-Chen, Following solves this by @Jared-Wiltshire explanations.

    <style>
    .grey-fill {
    fill: grey !important;
    }
    .red-fill {
    fill: red  !important;
    }
    .blue-fill {
    fill: blue  !important;
    }
    .green-fill {
    fill: green  !important;
    }
    </style>
    
    <div class="ma-designer-root" id="445b6000b-362e-407f-aa27-05545fea5884" style="width: inherit; height: inherit; position: relative; bottom: inherit; left: inherit;">
    <ma-svg ng-include="'/rest/v2/file-stores/default/sss/demo.svg'">
    <div ma-selector="#t1" ng-class="{'grey-fill': (v342.value < 0.94) || (v342.value > 1.06), 'red-fill':(v342.value >= 0.94 &amp;&amp; v342.value < 0.95) , 'blue-fill': (v342.value <= 1.06 &amp;&amp; v342.value > 1.05), 'green-fill': (v342.value >= 0.95) &amp;&amp; (v342.value <= 1.05)}">
    </div>
    </ma-svg>
    <ma-get-point-value point-xid="demo1" point="v342"></ma-get-point-value>
    </div>
    

    posted in User help read more
  • ThomasEinasto

    @zhilin-chen said in Why this kind of <style> can not work?:

    Hi, Thomas and Jared

    Thank you so much!! You guys are so quick! However, That is not what I mean. What I mean is that the style statement still does not work with your code. Other kinds of style such as something with animation could work with this condition. But this colour-fill one could not. Quite confusing though. Sorry still new in Mango.

    eg. below

    <div class="ma-designer-root" id="a7f018fd-f4bf-469e-bec7-1282ad4606bc" style="width: 1366px; height: 768px; position: relative;"></div>
    <style>
    .grey-fill {
    fill: grey;
    }
    .red-fill {
    fill: red;
    }
    .blue-fill {
    fill: blue;
    }
    .green-fill {
    fill: green;
    }
    </style>
    
    <div class="ma-designer-root" id="445b6000b-362e-407f-aa27-05545fea5884" style="width: inherit; height: inherit; position: relative; bottom: inherit; left: inherit;">
    <ma-svg ng-include="'/rest/v2/file-stores/default/sss/demo.svg'">
    <div ma-selector="#t1" ng-class="{'grey-fill': (v342.value < 0.94) || (v342.value > 1.06), 'red-fill':(v342.value >= 0.94 &amp;&amp; v342.value < 0.95) , 'blue-fill': (v342.value <= 1.06 &amp;&amp; v342.value > 1.05), 'green-fill': (v342.value >= 0.95) &amp;&amp; (v342.value <= 1.05)}">
    </div>
    </ma-svg>
    <ma-get-point-value point-xid="demo1" point="v342"></ma-get-point-value>
    </div>
    

    Actually I tested my code out and you are right that ng-class fails but ng-style does not.

    One way you could achieve your result is following:

    <div class="ma-designer-root" id="445b6000b-362e-407f-aa27-05545fea5884" style="width: inherit; height: inherit; position: relative; bottom: inherit; left: inherit;">
    
    <ma-svg ng-include="'/rest/v2/file-stores/default/sss/demo.svg'">
    
    <div ma-selector="#t1" 
    ng-style="{'fill': (v342.value < 0.94) || (v342.value > 1.06) ? 'gray' : (v342.value >= 0.94 && v342.value < 0.95) ? 'red' : (v342.value <= 1.06 && v342.value > 1.05) ? 'blue' : (v342.value >= 0.95) && (v342.value <= 1.05) ? 'green' : 'default' }"
    >
    </div>
    </ma-svg>
    <ma-get-point-value point-xid="demo1" point="v342"></ma-get-point-value>
    </div>
    

    This is ng-style which is the same equivalent as:

    if (condition1){
    
    fill:gray
    
    }else{
    
    if (condition3){
    
    fill:red
    
    }else{
    
    if (condition3){
    
    fill:blue
    
    }else{
    
    if (condition4){
    
    fill:green
    
    }else{
    
    fill:default
    
    }
    
    }
    
    }
    
    }
    

    posted in User help read more
  • ThomasEinasto

    This is because you have no variable assigned to ng-class and currently you probably have multiple same conditions on multiple classes. i.e 'red-fill', 'blue-fill and 'green-fill' are assigned currently as 0?.

    Correct way would be something like this:

    <style>
    .grey-fill {
    fill: grey;
    }
    .red-fill {
    fill: red;
    }
    .blue-fill {
    fill: blue;
    }
    .green-fill {
    fill: green;
    }
    </style>
    
    <div class="ma-designer-root" id="445b6000b-362e-407f-aa27-05545fea5884" style="width: inherit; height: inherit; position: relative; bottom: inherit; left: inherit;">
    <ma-svg ng-include="'/rest/v2/file-stores/default/sss/demo.svg'">
    <div ma-selector="#t1" ng-class="{'grey-fill': point.value == 1, 'red-fill': point.value == 2, 'blue-fill': point.value == 3, 'green-fill': point.value == 4}"></div>
    </ma-svg>
    </div>
    

    See /ui/examples/basics/style-via-value for a correct example on how to use ng-class or https://docs.angularjs.org/api/ng/directive/ngClass

    posted in User help read more
  • ThomasEinasto

    Hi @Phillip-Weeks ,

    One can create a new usermodule component to handle like ng-init.

    userModule.component('gettime', {
        bindings:{
            timestampIn: '@?',
            tsFormat: '@?',
            newDateo: '=?',
            newDates: '=?'
        },
        controller:['$scope',
            function($scope){
    
                $scope.$watch('$ctrl.timestampIn', () => {
    
                    let dateobject = moment(this.timestampIn);
                    
                    let datestring = moment(this.timestampIn).format(this.tsFormat);
                    
                    if (typeof this.timestampIn !== "undefined"){
                        
                            this.newDateo = dateobject;
                            this.newDates = datestring;
                            
                            //console.log(typeof(this.newDateo)); << returns dateobject
                            //console.log(typeof(this.newDates)); << returns string
                    }
                    
                }, true);
            
            
        }]
        
    });
    
    

    new-dateo is date object which you should be able to use as your date.from / date.to variable.
    new-dates is date string which is formatted like you want based on momentjs format function.

    Usage in dashboard:

    <gettime timestamp-in="10/05/2019 22:10:10" ts-format="DD/MM/YYYY HH:mm:ss" new-dateo="js" new-dates="jss"></gettime>
    
    {{js}}
    <br>
    {{jss}}
    

    Result in dashboard:

    Sat Oct 05 2019 22:10:10 GMT+0300
    05/10/2019 22:10:10
    

    posted in Dashboard Designer & Custom AngularJS Pages read more
  • ThomasEinasto

    @ORU_david To put 74 ° you should probably write 740 but I am not sure if the value put into the modbus request is actually a 2 byte integer or a floating point,

    i.e does Mango parseInt the value after multiplier + additive before putting it into the modbus request or not..

    IAS staff could be of more help on that.

    posted in How-To read more
  • ThomasEinasto

    If we are talking about MC6 Test Stat: MC6 Stat - Space temp point then following is related.

    Transcript from modbus documentation:
    See here for more info: http://www.simplymodbus.ca/exceptions.htm
    03 (03 hex) Illegal Data Value
    A value contained in the query data field is not an allowable value for the slave. This indicates a fault in the structure of remainder of a complex request, such as that the implied length is incorrect. It specifically does NOT mean that a data item submitted for storage in a register has a value outside the expectation of the application program, since the MODBUS protocol is unaware of the significance of any particular value of any particular register.

    Please see that your multiplier and additive is actually as it should. Device responds to mango that the value you want to write is not allowed.

    Edit: I looked at your previous point and it seems that we are actually talking about the same point. If you click on info icon on the datapoint edit page you can see documentation related to multiplier and additive.

    The Multiplier and Additive fields can be used when trivial value conversions are required. Numeric values read from the network are calculated as follows: (raw value) * multiplier + additive. The reverse is applied when a numeric value is written to the network.

    So generally speaking. You have to consider the multiplier you set to the point and also modbus 2 byte integers take integer values not floating values.

    posted in How-To read more