• E
    etantonio

    Thanks Phil for your help,
    for me is important to learn deeper all complex functions offered by Mango.
    In this case I think the best solution will be to use a scripting datasource with about 10 seconds poll on variable "update".
    The scripting datasource is a singleton? I mean if I have a long script inside (1 minute) while the script is called every 5 seconds, what happens?

    posted in Mango Automation general Discussion read more
  • E
    etantonio

    Thanks Phil,
    yes, I'm using Mango 2.8.8, I'm following your suggestion so I created a metapoint named "updateInProgress",

    0_1557826003514_c8bc3473-93eb-4530-a614-c5ffbd6286aa-immagine.png

    it is activated by the modbus datapoint named "update" infact the event choise is "contextupdate"

    0_1557826154172_a121e25e-b855-4cd4-819e-e5444e08820b-immagine.png

    the script associated to the metapoint is the following:

    LOG.info("upgrade.value: " + upgrade.value );
    if (upgrade.value === 1) {
        LOG.info("Update required!" );
        upgrade.set(0);
        java.lang.Thread.sleep(15000);
        LOG.info("upgrade.value: " + upgrade.value + "Disabled" );        
            
        LOG.info( "Start shutdown datasource" );
        RuntimeManager.disableDataSource('FML01-main');
        RuntimeManager.disableDataSource('FML01-conf'); 
        LOG.info( "End shutdown datasource" );
    
        LOG.info( "Start Script Update target" );
        var response = com.serotonin.m2m2.rt.maint.work.ProcessWorkItem.executeProcessCommand("/home/solergy/./tracker_upgrade_IP.sh S07E-MCU-3AX.bin upload 172.16.9.12", 300);
        LOG.info( response.key );
        LOG.info( "Fine Script Update target" );
    
        java.lang.Thread.sleep(30000);
        
        LOG.info( "Start power-on datasource" );
        RuntimeManager.enableDataSource('FML01-main');
        RuntimeManager.enableDataSource('FML01-conf'); 
        LOG.info( "Fine power-on datasource" );
        
        java.lang.Thread.sleep(30000);
        
        LOG.info("Start reset board");
        manualAct.set(8);
        return 0;
    }
    

    but I'ven't clear the following:

    1. upgrade.set(0); seems not to work inside the script, there is some reason for this? Maybe this is the difference with the scripting datasource, I can change only the value of "FML01 Meta - upgradeInProgress" at the end of the associated script, is it true?

    2. why is the script called always instead of just when "upgrade" changes:
      0_1557835800902_8ef5d27f-d2ad-41eb-93ac-97d86e7e2b55-immagine.png

    3. it is not possible to add this metapoint "FML01 Meta - upgradeInProgress" to the context, why?

    4. the var "isUpgradeInProgress" is the same than "FML01 Meta - upgradeInProgress" or what else?

    5. My requirement is that during the script execution the "updateInProgress" datapoint value is 1 or true , instead otherwise its value have to be 0 or false, is it possible to achieve this behaviour?

    6. it is possible to catch generic exception to be sure that I can re-enable the datasources

    Thanks,
    Antonio

    posted in Mango Automation general Discussion read more
  • E
    etantonio

    Good morning,
    my idea is to upgrade some STM32 board monitored with Mango,
    about this I've a flag named "upgrade" , when upgrade=1 then I want to disable datasources, update the firmware with a Python script then enable the datasources and send a reboot signal.

    My idea was about using a scripting datasource, but it is not possible to specify less than 1 minute with cron.

    Looking instead at an alarm associated to "upgrade" it seems that it is only possible to run OS processes and so it is not possible to enable and disable the datasources as I need.

    Any idea about how to fire a Mango script using a point event handler
    or
    how to set a scripting datasource execution every five seconds.
    thanks,
    Antonio

    iif (upgrade.value === 1) {
        print( "Update required!" );
        print( "Start datasource shutdown " );
        RuntimeManager.disableDataSource('FML01-main');
        RuntimeManager.disableDataSource('FML01-conf'); 
        print( "End   datasource shutdown" );
        
        
        print( "START target Update Script" );
        var response = com.serotonin.m2m2.rt.maint.work.ProcessWorkItem.executeProcessCommand("/home/solergy/./tracker_upgrade_IP.sh S07E-MCU-3AX.bin upload 172.16.9.12", 300);
        print( response.key );
        print( "END   target Update Script" );
        
        
        print( "Start datasource power-on " );
        RuntimeManager.enableDataSource('FML01-main');
        RuntimeManager.enableDataSource('FML01-conf'); 
        print( "End datasource power-on" );
        
        java.lang.Thread.sleep(90000);
        
        print("Start board reset");
        manualAct.set(8);
    }else{
        print( "Update not required." );
    }
    

    posted in Mango Automation general Discussion read more
  • E
    etantonio

    Thanks Phil.
    the part regarding the script is ok, thanks.
    Concerning file upload the client side maybe I can use something like this
    https://www.folio3.com/blog/angularjs-file-upload-example-tutorial/
    instead for the server side maybe I can use the service pointed by the
    JSON File importer just adding a { character at beginning of file.
    Thanks

    posted in Mango Automation general Discussion read more
  • E
    etantonio

    Hy,
    I want to use Mango 2.8.8 also to update the firmware in the remote STM32 boards,
    for this I need just to upload the file to the server using the web interface and then call a python script that perform the upload from server to STM32 boards.
    Which is the best method to perform this upload and call the python script?

    posted in Mango Automation general Discussion read more
  • E
    etantonio

    on S1 I've the datapoint STM32_1_OnOff used to start/stop the algorithm on STM32_1, a publisher expose it to M,
    the same for S2 where I've the datapoint STM32_2_OnOff,
    so M can see the state of STM32_1 and of STM32_2
    but to start/stop the algorithm on STM32_1 from M I have 2 way:

    1. Directly from M to STM32_1 using a Modbus datasource, this solution is direct but no security (M is on the cloud ) and some interference using 2 master (M and S1) for the same slave (STM32_1)

    2. Pass through S1 with a publisher and use two different datapoint STM32_1_OnOff and STM32_1_OnOffFromMaster, this solution is undirect but is secure and just one master

    I'll try to complete implementation of solution 2) as you suggest.
    Thanks

    posted in Mango Automation general Discussion read more
  • E
    etantonio

    in my application M is the master that receive data from slave S1 and S2 using Mango Persistent TCP publisher

    M, S1 and S2 use Mango 2.8.8
    S1 control STM32_1 using Modbus TCP
    S2 control STM32_2 using Modbus TCP

    I've created on M a datasource with only one datapoint to start/stop STM32_1,
    so this board is exposed to a datasource on S1 and to a datasource on M,
    Is this a problem?

    This is to avoid using of a reverse publisher from M to S1 and S2

    posted in Mango Automation general Discussion read more
  • E
    etantonio

    Thanks,
    virtual serial server socket is completely new to me,
    there's always something new to learn about Mango!! :-)

    The modem offer also a reporting agent that I can configure in this way:

    0_1555581547940_31365830-d2b3-490c-84e8-b8bf855b0243-immagine.png

    so it can send it's data using TCP and HTTP.
    Here I still have problem to understand,

    I can't use a TCP datasource because it is based on a request from Mango,
    the only way to accept such data sent by the modem is using virtual serial server socket.

    Modem data are in this format:

    @IMEI=352948070039411,Lan 
    Status=Connected,Lan 
    IP(IPv4)=192.168.1.1,Lan Uptime(Seconds)=329501,Lan TX 
    bytes=572260469,Lan RX bytes=117212098,Wan Status=Connected,Wan 
    IP(IPv4)=192.16
    9.1.110,Wan Uptime(Seconds)=329389,Wan 
    Gateway=192.169.1.1,Wan DNS=27.109.1.2 27.109.1.3,Wan TX 
    bytes=75455301,Wan RX bytes=344481735,
    

    Instead if I choose HTTP messages sent from the modem

    0_1555582933908_ae59d3ce-1c38-42d6-a5fc-7218ad5b7e3e-immagine.png

    I can see the data in the "HTTP receiver listener" but the following datapoint for IMEI

    {
       "dataPoints":[
          {
             "xid":"DP_672952",
             "name":"IMEI",
             "enabled":true,
             "loggingType":"INTERVAL",
             "intervalLoggingPeriodType":"MINUTES",
             "intervalLoggingType":"INSTANT",
             "purgeType":"YEARS",
             "pointLocator":{
                "dataType":"ALPHANUMERIC",
                "binary0Value":"",
                "parameterName":"IMEI",
                "setPointName":"",
                "settable":false
             },
             "eventDetectors":[
             ],
             "plotType":"STEP",
             "unit":"",
             "chartColour":"black",
             "chartRenderer":null,
             "dataSourceXid":"MaestroHTTPReceiver",
             "defaultCacheSize":1,
             "deviceName":"MaestroHTTPReceiver",
             "discardExtremeValues":false,
             "discardHighLimit":1.7976931348623157E308,
             "discardLowLimit":-1.7976931348623157E308,
             "intervalLoggingPeriod":1,
             "intervalLoggingSampleWindowSize":0,
             "overrideIntervalLoggingSamples":false,
             "purgeOverride":false,
             "purgePeriod":1,
             "readPermission":"",
             "setPermission":"",
             "textRenderer":{
                "type":"PLAIN",
                "useUnitAsSuffix":true,
                "unit":"",
                "renderedUnit":"",
                "suffix":""
             },
             "tolerance":0.0
          }
       ]
    }
    

    0_1555583228550_32750db3-0bb0-43af-a4db-541499d459d8-immagine.png

    returns much more information

    how can I take in account the separating comma?
    Maybe the problem is the url setted in the modem :

    http://xxx.yyy.zz.ww:8xyz/httpds

    Thanks,
    Antonio

    posted in Mango Automation general Discussion read more
  • E
    etantonio

    Thanks,
    I've the following trouble concerning publisher configuration:

    I want that the publisher sends all the data every 10 seconds, also unchanged data

    0_1555517906726_f2035f2f-6339-411b-b521-50cd22115a72-immagine.png

    but how it relates to this other configuration?

    0_1555518002598_029556d0-5c8e-42ac-ba67-0f0b3a3895c2-immagine.png

    it seems to me that if I choose Send Regular snapshot, then it should not be allowed to select "Transmit real time data".

    Thanks,
    Antronio

    posted in Mango Automation general Discussion read more
  • E
    etantonio

    Hy,
    in my project I have the following:
    *) 1 modem with a gps interface that produce GPS packet and can send it over TCP (any port) to just one IP address
    *) an Ubuntu server running mango 2.8.8
    +) several STM32Nucleo each one with a different IP address and each one requires the same GPS packet produced by the modem

    So here it is my question,
    is it possible to use mango to receive such GPS packet and forward it to all the STM32Nucleo IP addresses?

    No data elaboration, just retransmit the packet to a list of IP address.

    I don't know if it possible to achieve the same result using some network feature (redirect or something else), but broadcast from the modem is not allowed in this network.

    Thanks,
    Antonio

    posted in Mango Automation general Discussion read more