• J
    Jokke

    Hello,

    I created a metapoint for checking from multiple bits if any is on.

    Like this

    
    var value=false;
    
    if (p271.value==true ||
        p272.value==true ||
        p273.value==true ||
        p274.value==true ||
        p275.value==true ||
        p279.value==true ||
        p280.value==true )
       value=true;
    
    return value;
    
    

    The update event is context update.

    For some reason the update is never run. The datasource for the bits is Modbus TCP with 30s update interval.

    Please tell is there some trick needed.

    BR
    -Jokke

    posted in User help read more
  • J
    Jokke

    Hello,

    I have used some server side sripts on graphical views. Some are quite specific for the need. I have tried to make some in more generic way and here are some. I will check if i could clean some others and post here...

    These are used as server side script component.

    A drop down menu (select) which shows current value. Can set the value by selecting from menu.(edited the code and works now atleast on firefox and on Nokia mobile )

    
    //Select example
    var min = 1;
    var max = 8;
    var lead =""; //for leading zero or space
    var s="";
    
    s+="<select  onChange='mango.view.setPoint("+ point.id +", \""+ pointComponent.id +"\", this.selectedIndex+"+min+" )'>";
    
    for(var i = min; i <= max ;i++)
    { 
       if (i > 9) {lead = "";}
    
       s+= "<option value="+ i;
       if (value == i) { s+= " selected ";}
       s+= ">"+i+ "</option>";
    }
    s+="</select>";
    
    return s;
    
    

    checkbox for binary point

    
    var s = "";
    var arvo = "";
    
    if (value)
    {
         arvo = 0
         s += "<INPUT TYPE=CHECKBOX checked onclick='mango.view.setPoint("+ point.id +", \""+ pointComponent.id +"\", \"false\");return false;'/>";
    }
    else
    {
     s += "<INPUT TYPE=CHECKBOX onclick='mango.view.setPoint("+ point.id +", \""+ pointComponent.id +"\", \"true\");return false;'/>";
    
    }
     return s;
    
    

    Quite simple... a text box (which is printing BCD value as 24h clock time)

    
    var s ="<input type='text' size=5 value=' ";
    var minute ="";
    var hour ="";
    
    if(Math.round(value%100)<10)
    {
       minute += "0";
    }
    minute += Math.round(value%100);
    
    hour=Math.floor(value/100);
    if(hour == 0)
       s += "0";
    s += hour;
    s += ":";
    s += minute;
    s += " '>";
    
    return s;
    
    

    Lamp image, clicking on it is setting/resetting a bit in variable

    
    var s = "";
    var mask =1024; //1024 is bit 10, 8=bit 3
    var arvo = "";
    
    if (value & mask)
    {
         arvo = value - mask;
         arvo = arvo +"";
         s += "<img style='cursor:pointer;' src='graphics/LightBulb/light_on.gif' onclick='mango.view.setPoint("+ point.id +", \""+ pointComponent.id +"\","+ arvo+");return false;'/>";
    }
     else
    {
         arvo = value + mask;
         arvo = arvo +"";
         s += "<img style='cursor:pointer;' src='graphics/LightBulb/light_off.gif' onclick='mango.view.setPoint("+ point.id +", \""+ pointComponent.id +"\","+ arvo+");return true;'/>";
    }
     return s;
    
    
    

    Lamp image clicking on it sets a binary point(from an old example in some other thread)

    
    var s = "";
    
    if (value)
    {
         s += "<img style='cursor:pointer;' src='graphics/LightBulb/light_on.gif' onclick='mango.view.setPoint("+ point.id +", \""+ pointComponent.id +"\",false);return false;'/>";
    }
     else
    {
         s += "<img style='cursor:pointer;' src='graphics/LightBulb/light_off.gif' onclick='mango.view.setPoint("+ point.id +", \""+ pointComponent.id +"\",true);return true;'/>";
    }
     return s;
    
    
    

    I hope these are for some use

    BR
    -Jokke

    posted in User help read more
  • J
    Jokke

    Hello,

    I read on the online documentation about the available variables. It was not clearly documented how they can be used. made some tries like these.

    var s="";
    
    s += point.name;
    s += ": ";
    s += value;
    s += point.getTextRenderer().getSuffix();
    s += " = ";
    s += renderedText;
    
    return s;
    

    it prints out like this "Temperature: 21.375°C = 21,4°C"

    Are these variables supposed to be used like this? :) It seems easiest to figure out the interfaces/methods on different objects by digging around the source codes. Would be great to have some list/tree/doc about the different objects.(maybe some html help/pages generated automatically from sources)

    I have been thinking to make a small alarm panel on a graphical view, with selected events related to the view. I was looking for the event objects and trying to find out how I could get grab on the string which is printed on event list. Again diving into sources and ended up to this try and it does not work like supposed. And the next hop is missing :(

    var s="" 
    s +=events.get(0).message.key;
    return s;
    

    (I found out by trying and the error messages gave hint the "events" is a list type of object) The message is object type of LocalizableMessage.

    On the sources one essential file is missing and it seems to be used all around: "import com.serotonin.web.i18n.LocalizableMessage;"
    Please tell where to find this?

    Any hints how to make the alarm list?

    Thanks
    -Jokke

    posted in User help read more
  • J
    Jokke

    means mango speaking finnish.

    I know there are some finns using Mango. I made the translation for finnish language. There may be typos and incorrect translations. Here is something to start with. Please post your comments.

    Some datasources and emport message translations are missing as the messages are quite specific. It needs some testing to make correct translations. And the help files are not translated.

    Attached the files, just extract the zip to /WEB-INF/classes and restart tomcat to take into use.

    Same in finnish as it is relevant in this case

    Kun tiedän että on muitakin meikäläisiä Mango-käyttäjiä, niin tein käännökset suomeksi. Siinä voi olla kirjoitus- ja käännösvirheitä, mutta jotain mistä lähteä. Kommentoikaa vapaasti.

    Puuttuvia käännöksiä on, jotkin datasourcet ja emport viestit, kun muotoilu on aika tarkkaa, jottei asia häviä käännökseen. Pitäisi testata tarkemmin, jotta voi tehdä oikeat käännökset. Helppien käännökset puuttuvat myös.

    Tiedostot liitteenä. Pura zip kansioon /WEB-INF/classes käynnistä tomcat uudestaan niin siinäpä se.

    BR
    -Jokke

    posted in User help read more
  • J
    Jokke

    Now when there is the new process event handler (many thanks for a good feature). I made some experiments with it and came up with a way how to get from owfs data to mango. (see www.owfs.org)

    I have been using scripts to feed data from owfs to mysql and mango is then reading the data base with SQL data source. This works but it is not too easy to setup for beginners.

    Here comes an easier way using HTTP receiver datasource. It works quite twisted way with a simple script making calls with wget to the receiver. No mysql needed in between.

    Option A
    I made a virtual data source and a point with "alternate" change type. Then defined event detector to create events on change. So this point is periodically making events. The process handler is calling /var/lib/tomcat6/webapps/ROOT/test.sh

    I have made a text file named test.sh into the ROOT folder and which has the following content

    wget -q "http://127.0.0.1:8080/httpds?test1=cat /mnt/owfs/some_sensor/temperature"

    This method can be used also for witing to owfs (sending commands to 1 wire devices)

    option B

    make the script running all the time(launched in system start) and make a loop structure with sleep. This is not under control of mango but might be even easier. Something like this (not tested)

     
    
    #!/bin/bash
    
    while true; do
    
    wget -q "http://127.0.0.1:8080/httpds?test1=`cat /mnt/owfs/some_sensor/temperature`"
    
    wget -q "http://127.0.0.1:8080/httpds?test2=`cat /mnt/owfs/ampther_sensor/temperature`"
    
    sleep 30
    
    done
    
    
    
    
    

    Some notes.

    • the instruction works for linux(ubuntu). For windows it should be possible similar way but using .bat file. There is wget also for Windows, but some research needed.

    • The owfs needs to have "--allow_other" to make the ow filesystem readable for the tomcat process.

    • the .sh file properties needs to be set as executable and in option A have permission for the tomcat user(chmod 777, should do the trick)

    posted in Hardware read more
  • J
    Jokke

    Hello,

    I made a simple table for testing. The table has 2 columns named A and B. The values are 1 and 2. The data is readable with both column based and row based query.

    I used this statement for reading "SELECT A, B FROM deebee.Test LIMIT 0, 1000 ;"

    How should the update statement look like? Any examples?

    I tried some statements but they did nothing or caused the following alarm "Exception while setting point TestPoint: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0)."

    Regards
    Jokke

    posted in User help read more
  • J
    Jokke

    I tested the modbus IP data source with Twido PLC. All data type points possible are not supported in twido so i tested the ones which are supported.(2 byte datatypes). So i can tell Telemecanique Twido is one supported HW.

    Found a problem with Holding registers with binary data type. The data reading works well but setting such data point value there appears popup dialog with text "Error" (and nothing more). Could someone explaind what causing this or is there some bug?

    posted in Hardware read more
  • J
    Jokke

    Tried to search for owfs in topics. I could guess I'm not the only one who wants to have owfs in Mango. To support owfs it is enouht to have file as data source. Is there currently some way to do the trick?

    owfs is filesystem for Dallas 1-wire. The devices appear as files under the filesystem. When reading file you can see the value eg. temperature or input state. The same way when you write to some output file it is set to the device. owfs supports "all" 1-wire devices. http://owfs.org/

    posted in Wishlist read more
  • J
    Jokke

    Hi,

    answers: yes something and I think so.

    I have not tried but taken a look how it works.

    Please take a look on the help. It says:

    "The Dynamic graphic component is similar to the analog image renderer in that it can visualize a numeric point, but instead of choosing one out of a set of images it dynamically draws the indicator of the value. For example, the pointer can be drawn on a single dial image. To add a new dynamic renderer, add a new subdirectory to the graphics directory and put the static image and an appropriate info file there. Then, add a rendering function to the resources/view.js file. The function must be named according to the name given to the subdirectory. See the Dial graphic as an example. "

    In the view.js there is the code for the dynamic parts. It looks quite straight forward but requires some coding skills. If you can update rest of us after trying...

    BR
    -Jokke

    posted in How-To read more
  • J
    Jokke

    Hello,

    I created a metapoint for checking from multiple bits if any is on.

    Like this

    
    var value=false;
    
    if (p271.value==true ||
        p272.value==true ||
        p273.value==true ||
        p274.value==true ||
        p275.value==true ||
        p279.value==true ||
        p280.value==true )
       value=true;
    
    return value;
    
    

    The update event is context update.

    For some reason the update is never run. The datasource for the bits is Modbus TCP with 30s update interval.

    Please tell is there some trick needed.

    BR
    -Jokke

    posted in User help read more