<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Create a new numeric Datapoints from alphanumeric datapoint]]></title><description><![CDATA[<p dir="auto">There are 110 controller, where every data come with the units, I mean for example starting voltage battery: 13.7V,  engine temperature 47,0celsius, etc<br />
•	All data are SNMP<br />
•	The type of data is OctectString (it from MIB File)<br />
•	In Mango Scada every data points is configured as Alphanumeric type and Not Settable<br />
•	All information is getting with out problema.</p>
<p dir="auto">The problem is that with this kind of data (Alphanumeric), is not possible to get a graph also is not possible to configure limits alarms maximum or minimum. (Event detector)</p>
<p dir="auto">Question, If I have and get all information, ¿could I have any way to change all this information from Alphanumeric to Numeric??<br />
Im thinking or guess is possible to use some virtual datasources where datapoint values will be obtained from this alphanumeric information… <img src="https://camo.nodebb.org/8d5f0f1b152ccd9b8a81d1881400133578c3d97a?url=https%3A%2F%2Fi.imgur.com%2F4kX9OUp.png" alt="0_1544013662101_Alphanumeric Value.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.mango-os.com/topic/3940/create-a-new-numeric-datapoints-from-alphanumeric-datapoint</link><generator>RSS for Node</generator><lastBuildDate>Sat, 17 Oct 2026 03:20:13 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/3940.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 Dec 2018 12:35:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Create a new numeric Datapoints from alphanumeric datapoint on Tue, 11 Dec 2018 21:12:26 GMT]]></title><description><![CDATA[<p dir="auto">Thanks so much, You are right, we check it and it work. Thank You<br />
The other script... will be for the oficial integration.<br />
till now we are showing to the customer that the platform can work with their controller</p>
]]></description><link>https://forum.mango-os.com/post/20702</link><guid isPermaLink="true">https://forum.mango-os.com/post/20702</guid><dc:creator><![CDATA[Jorge Gonzalez]]></dc:creator><pubDate>Tue, 11 Dec 2018 21:12:26 GMT</pubDate></item><item><title><![CDATA[Reply to Create a new numeric Datapoints from alphanumeric datapoint on Tue, 11 Dec 2018 20:10:19 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">Phil. please what we need now to add something to the script to multiplying the final value x20. It is because the value is %, I think that will be better, if it is shown as a number i.e. 70% = 20x70=1400</p>
</blockquote>
<p dir="auto">If I'm understanding right, that's a simple modification to the script,</p>
<pre><code>var pieces = /(-?\d+?),(\d+).*/.exec(p.value);
return parseFloat( pieces[1] + "." + pieces[2] ) * 20; //multiply it by 20
</code></pre>
<p dir="auto">You could automate creating the meta points by doing something like I did in this thread, <a href="https://forum.infiniteautomation.com/topic/2473/how-to-bulk-import-event-detectors" rel="nofollow ugc">https://forum.infiniteautomation.com/topic/2473/how-to-bulk-import-event-detectors</a></p>
<p dir="auto">It's probably possible and perhaps easier through CSV export/import, but I would do it with a script like,</p>
<pre><code>var xidPrefix = "N_"; //used to create a unique XID from the XID of the data point, chose N for numeric
var snmpDataSourceXid = "DS_c4248bb3-9877-4ed7-b228-0bd08c3f77b6"; //Identify the points to add to, change to your SNMP DS's
var metaDataSourceXid = "DS_b9d9db6b-49f3-4c92-820d-7f2a65c39ea4"; //change to your meta DS

var dataPoints = JSON.parse(JsonEmport.getConfiguration("dataPoints")).dataPoints;
var snmpPoints = DataPointQuery.query('eq(dataSourceXid,'+snmpDataSourceXid+')&amp;limit(1000)');
var createdMetaPoints = [];

function findByXid(list, xid) {
    for( var k = 0; k &lt; list.length; k+=1 )
        if( list[k].xid === xid )
            return list[k];
    return undefined;
}

function createMetaPointForDataPoint(dp) {
    if(findByXid(dataPoints, xidPrefix + dp.xid) !== undefined)
		return; //ensure we don't create the meta point twice
                        // but it would just import and save again, no biggie
    
    var meta = { //Gotten by configuring one and exporting it
         "xid":xidPrefix + dp.xid,
         "name": dp.name,
         "enabled":true,
         "loggingType":"ALL",
         "intervalLoggingPeriodType":"MINUTES",
         "intervalLoggingType":"AVERAGE",
         "purgeType":"YEARS",
         "pointLocator":{
            "dataType":"NUMERIC",
            "updateEvent":"NONE",
            "contextUpdateEvent":"CONTEXT_UPDATE",
            "context":[
               {
                  "varName":"p",
                  "dataPointXid":dp.xid,
                  "updateContext":true
               }
            ],
            "logLevel":"NONE",
            "variableName":"my",
            "executionDelaySeconds":0,
            "logCount":5,
            "logSize":1.0,
            "script":"var pieces = \/(-?\\d+?),(\\d+).*\/.exec(p.value);\r\nreturn parseFloat( pieces[1] + \".\" + pieces[2] ) * 20;",
            "scriptPermissions":{
               "customPermissions":"",
               "dataPointReadPermissions":"superadmin, edit-ui-menus, edit-ui-pages, edit-ui-settings",
               "dataPointSetPermissions":"superadmin, edit-ui-menus, edit-ui-pages, edit-ui-settings",
               "dataSourcePermissions":"superadmin, edit-ui-menus, edit-ui-pages, edit-ui-settings"
            },
            "settable":false,
            "updateCronPattern":""
         },
         "eventDetectors":[
         ],
         "plotType":"SPLINE",
         "rollup":"NONE",
         "unit":"",
         "simplifyType":"NONE",
         "chartColour":"",
         "chartRenderer":{
            "type":"IMAGE",
            "timePeriodType":"DAYS",
            "numberOfPeriods":1
         },
         "dataSourceXid":metaDataSourceXid,
         "defaultCacheSize":1,
         "deviceName":"Parsed " + dp.deviceName,
         "discardExtremeValues":false,
         "discardHighLimit":1.7976931348623157E307,
         "discardLowLimit":-1.7976931348623157E307,
         "intervalLoggingPeriod":1,
         "intervalLoggingSampleWindowSize":0,
         "overrideIntervalLoggingSamples":false,
         "preventSetExtremeValues":false,
         "purgeOverride":false,
         "purgePeriod":1,
         "readPermission":"",
         "setExtremeHighLimit":1.7976931348623157E307,
         "setExtremeLowLimit":-1.7976931348623157E307,
         "setPermission":"",
         "tags":{
         },
         "textRenderer":{
            "type":"ANALOG",
            "useUnitAsSuffix":true,
            "unit":"",
            "renderedUnit":"",
            "format":"0.0"
         },
         "tolerance":0.0
      };
            
    createdMetaPoints.push(meta);
}

for(var k in snmpPoints) {
	var dpWrapper = snmpPoints[k];
	createMetaPointForDataPoint(dpWrapper);
}


//The next line allows this import to happen even if we're just clicking the validate checkbox on a script
JsonEmport.setImportDuringValidation( true );

JsonEmport.doImport(JSON.stringify({"dataPoints":createdMetaPoints}));
</code></pre>
]]></description><link>https://forum.mango-os.com/post/20697</link><guid isPermaLink="true">https://forum.mango-os.com/post/20697</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Tue, 11 Dec 2018 20:10:19 GMT</pubDate></item><item><title><![CDATA[Reply to Create a new numeric Datapoints from alphanumeric datapoint on Tue, 11 Dec 2018 13:36:32 GMT]]></title><description><![CDATA[<p dir="auto">Dear Phil, I made some tests with some values and it work.. even it must be done one by one value. (i think there are more than 800 different values).</p>
<p dir="auto">Phil. please what we need now to add something to the script to multiplying the final value x20. It is because the value is %, I think that will be better, if it is shown as a number i.e. 70% = 20x70=1400</p>
]]></description><link>https://forum.mango-os.com/post/20691</link><guid isPermaLink="true">https://forum.mango-os.com/post/20691</guid><dc:creator><![CDATA[Jorge Gonzalez]]></dc:creator><pubDate>Tue, 11 Dec 2018 13:36:32 GMT</pubDate></item><item><title><![CDATA[Reply to Create a new numeric Datapoints from alphanumeric datapoint on Mon, 10 Dec 2018 19:37:31 GMT]]></title><description><![CDATA[<p dir="auto">Thanks so much Phil, I will check Your sugestion, I guess that it may work... thanks again</p>
<p dir="auto">I will keep in touch about it</p>
]]></description><link>https://forum.mango-os.com/post/20682</link><guid isPermaLink="true">https://forum.mango-os.com/post/20682</guid><dc:creator><![CDATA[Jorge Gonzalez]]></dc:creator><pubDate>Mon, 10 Dec 2018 19:37:31 GMT</pubDate></item><item><title><![CDATA[Reply to Create a new numeric Datapoints from alphanumeric datapoint on Wed, 05 Dec 2018 17:34:28 GMT]]></title><description><![CDATA[<p dir="auto">Hi Jorge,</p>
<p dir="auto">Joel's suggestion would work if the value didn't have the unit encoded in the alphanumeric value, and if your locale is set for Double.parseDouble to expect commas for number formatting. One could create a meta point and parse out the value that way, i.e.</p>
<p dir="auto">where p is the variable name for a alphanumeric context point,</p>
<pre><code>var pieces = /(-?\d+?),(\d+).*/.exec(p.value);
return parseFloat( pieces[1] + "." + pieces[2] );
</code></pre>
<p dir="auto">Then you could generate history and whatnot for your existing data. That may not be exactly what you need (you may need to change the decimal delimiter on the second line back to a comma (if so, you could also just capture it all together in the first line)) but it's close.</p>
]]></description><link>https://forum.mango-os.com/post/20631</link><guid isPermaLink="true">https://forum.mango-os.com/post/20631</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Wed, 05 Dec 2018 17:34:28 GMT</pubDate></item><item><title><![CDATA[Reply to Create a new numeric Datapoints from alphanumeric datapoint on Wed, 05 Dec 2018 15:24:21 GMT]]></title><description><![CDATA[<p dir="auto">You will need to change the Data Type on the Data Point to Numeric if you want to chart and use statistics.  Other things in Mango are also affected by the data type such as the types of event detectors.</p>
]]></description><link>https://forum.mango-os.com/post/20627</link><guid isPermaLink="true">https://forum.mango-os.com/post/20627</guid><dc:creator><![CDATA[JoelHaggar]]></dc:creator><pubDate>Wed, 05 Dec 2018 15:24:21 GMT</pubDate></item></channel></rss>