Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cut-low cut-high in ecuxml

  • Loading branch information...
commit 4ad643fe987e88a260dcf7e511b84c6a62c72765 1 parent 10af7be
@cail authored
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/elm/ECUXMLSensorProvider.cs
View
12 src/elm/ECUXMLSensorProvider.cs
@@ -76,6 +76,8 @@ void init(SensorRegistry registry)
double scale = 1;
double offset = 0;
int bit = -1;
+ int? cutlow = null;
+ int? cuthigh = null;
while(reader.NodeType == XmlNodeType.Element)
{
@@ -151,6 +153,12 @@ void init(SensorRegistry registry)
case "bit":
bit = int.Parse(reader.ReadElementString());
break;
+ case "cut-low":
+ cutlow = int.Parse(reader.ReadElementString());
+ break;
+ case "cut-high":
+ cuthigh = int.Parse(reader.ReadElementString());
+ break;
case "description":
reader.ReadStartElement();
while(reader.NodeType == XmlNodeType.Element)
@@ -220,6 +228,10 @@ void init(SensorRegistry registry)
var res = v * scale + offset;
if (bit != -1)
res = ((int)res >> bit)&1;
+ if (cutlow != null)
+ res = res < cutlow ? 0 : res;
+ if (cuthigh != null)
+ res = res > cuthigh ? 0 : res;
return res;
};
Please sign in to comment.
Something went wrong with that request. Please try again.