diff --git a/README.md b/README.md
index 80e33ea..c8d85fc 100644
--- a/README.md
+++ b/README.md
@@ -1,89 +1,104 @@
-KNX.net ![build status](https://travis-ci.org/lifeemotions/knx.net.svg?branch=master) ![nuget status](http://img.shields.io/nuget/v/KNX.net.svg?style=flat)
-=======
-
-KNX.net provides a [KNX](http://en.wikipedia.org/wiki/KNX_%28standard%29) API for C#
-
-This API allows to connect in both modes:
-* Tunneling
-* Routing
-
-After connecting you will be able to send actions to the bus and receive messages from it.
-
-The following datapoints are available in the API:
-
-| DPT | input type | input range | output type | output range | Description |
-| ------- |-------------------------------------------- | --------------- | ----------- | --------------- | ----------------------------------- |
-| `3.007` | `int`, `float`, `long`, `double`, `decimal` | `[-7,7]` | `int` | `[-7,7]` | Control blinds (steps) [`0` stops] |
-| `3.008` | `int`, `float`, `long`, `double`, `decimal` | `[-7,7]` | `int` | `[-7,7]` | Control dimming (steps) [`0` stops] |
-| `5.001` | `int`, `float`, `long`, `double`, `decimal` | `[0,100]` | `decimal` | `[0,100]` | Percentage (%) |
-| `5.003` | `int`, `float`, `long`, `double`, `decimal` | `[0,360]` | `decimal` | `[0,360]` | Angle (°) |
-| `5.004` | `int`, `float`, `long`, `double`, `decimal` | `[0,255]` | `int` | `[0,255]` | Percentage [0,255] (%) |
-| `5.010` | `int`, `float`, `long`, `double`, `decimal` | `[0,255]` | `int` | `[0,255]` | Counter Pulses |
-| `6.001` | `int`, `float`, `long`, `double`, `decimal` | `[-128,127]` | `int` | `[-128,127]` | Percentage (%) |
-| `6.010` | `int`, `float`, `long`, `double`, `decimal` | `[-128,127]` | `int` | `[-128,127]` | Counter Pulses |
-| `9.001` | `int`, `float`, `long`, `double`, `decimal` | `[-273,670760]` | `decimal` | `[-273,670760]` | Temperature in Celsius (°C) |
-
-Also working but no implemented as datapoints (see below for better explanation):
-* bit (lights, buttons)
-* byte (dimmers, temperature difference, RGB)
-
-Examples
---------
-
-### Connecting using Routing (turn off and on a light)
-
-```csharp
-static void Main(string[] args)
-{
- var connection = new KNXConnectionRouting();
- connection.Connect();
- connection.KNXEventDelegate += new KNXConnection.KNXEvent(Event);
- connection.Action("5/0/2", false);
- Thread.Sleep(5000);
- connection.Action("5/0/2", true);
- Thread.Sleep(5000);
-}
-static void Event(string address, string state)
-{
- Console.WriteLine("New Event: device " + address + " has status " + state);
-}
-```
-
-### Working with datapoints
-
-Sending an action
-
-```csharp
-connection.Action("1/1/16", connection.toDPT("9.001", 24.0f));
-connection.Action("1/1/17", connection.toDPT("5.001", 50));
-```
-
-Converting status from event
-
-```csharp
-float temp = (float)connection.fromDPT("9.001", state);
-```
-
-### Sending actions without using datapoints
-
-```csharp
-connection.Action("1/1/19", true);
-connection.Action("1/1/20", false);
-connection.Action("1/1/21", 60);
-```
-
-### Connecting using Tunneling
-
-The only difference is how the connection object is created
-
-```csharp
-connection = new KNXConnectionTunneling(remoteIP, remotePort, localIP, localPort);
-```
-
-### Notes
-
-If connecting in routing mode:
-* make sure the system firewall allows incoming connections to the routing port ()if not specified when connecting, default is `3671`)
-
-If connecting in tunneling mode:
-* make sure the system firewall allows incoming connections to the specified `localPort`
+KNX.net ![build status](https://travis-ci.org/lifeemotions/knx.net.svg?branch=master) ![nuget status](http://img.shields.io/nuget/v/KNX.net.svg?style=flat)
+=======
+
+KNX.net provides a [KNX](http://en.wikipedia.org/wiki/KNX_%28standard%29) API for C#
+
+This API allows to connect in both modes:
+* Tunneling
+* Routing
+
+After connecting you will be able to send actions to the bus and receive messages from it.
+
+The following datapoints are available in the API:
+
+| DPT | input type | input range | output type | output range | Description |
+| ------- |-------------------------------------------- | --------------- | ----------- | --------------- | ----------------------------------- |
+| `3.007` | `int`, `float`, `long`, `double`, `decimal` | `[-7,7]` | `int` | `[-7,7]` | Control blinds (steps) [`0` stops] |
+| `3.008` | `int`, `float`, `long`, `double`, `decimal` | `[-7,7]` | `int` | `[-7,7]` | Control dimming (steps) [`0` stops] |
+| `5.001` | `int`, `float`, `long`, `double`, `decimal` | `[0,100]` | `decimal` | `[0,100]` | Percentage (%) |
+| `5.003` | `int`, `float`, `long`, `double`, `decimal` | `[0,360]` | `decimal` | `[0,360]` | Angle (°) |
+| `5.004` | `int`, `float`, `long`, `double`, `decimal` | `[0,255]` | `int` | `[0,255]` | Percentage [0,255] (%) |
+| `5.010` | `int`, `float`, `long`, `double`, `decimal` | `[0,255]` | `int` | `[0,255]` | Counter Pulses |
+| `6.001` | `int`, `float`, `long`, `double`, `decimal` | `[-128,127]` | `int` | `[-128,127]` | Percentage (%) |
+| `6.010` | `int`, `float`, `long`, `double`, `decimal` | `[-128,127]` | `int` | `[-128,127]` | Counter Pulses |
+| `9.001` | `int`, `float`, `long`, `double`, `decimal` | `[-273,670760]` | `decimal` | `[-273,670760]` | Temperature in Celsius (°C) |
+
+Also working but no implemented as datapoints (see below for better explanation):
+* bit (lights, buttons)
+* byte (dimmers, temperature difference, RGB)
+
+Examples
+--------
+
+### Connecting using Routing (turn off and on a light)
+
+```csharp
+static void Main(string[] args)
+{
+ var connection = new KNXConnectionRouting();
+ connection.Connect();
+ connection.KNXEventDelegate += new KNXConnection.KNXEvent(Event);
+ connection.Action("5/0/2", false);
+ Thread.Sleep(5000);
+ connection.Action("5/0/2", true);
+ Thread.Sleep(5000);
+}
+static void Event(string address, string state)
+{
+ Console.WriteLine("New Event: device " + address + " has status " + state);
+}
+```
+
+### Working with datapoints
+
+Sending an action
+
+```csharp
+connection.Action("1/1/16", connection.toDPT("9.001", 24.0f));
+connection.Action("1/1/17", connection.toDPT("5.001", 50));
+```
+
+Converting status from event
+
+```csharp
+static void Event(string address, string state)
+{
+ if (address == "1/1/16")
+ {
+ int temp = (int)connection.fromDPT("9.001", state);
+ Console.WriteLine("New Event: device " + address + " has status " + temp);
+ return;
+ }
+ if (address == "1/1/17")
+ {
+ int perc = (int)connection.fromDPT("5.001", state);
+ Console.WriteLine("New Event: device " + address + " has status " + perc);
+ return;
+ }
+}
+
+```
+
+### Sending actions without using datapoints
+
+```csharp
+connection.Action("1/1/19", true);
+connection.Action("1/1/20", false);
+connection.Action("1/1/21", 60);
+```
+
+### Connecting using Tunneling
+
+The only difference is how the connection object is created
+
+```csharp
+connection = new KNXConnectionTunneling(remoteIP, remotePort, localIP, localPort);
+```
+
+### Notes
+
+If connecting in routing mode:
+* make sure the system firewall allows incoming connections to the routing port ()if not specified when connecting, default is `3671`)
+
+If connecting in tunneling mode:
+* make sure the system firewall allows incoming connections to the specified `localPort`
diff --git a/src/KNXLib/DPT/DataPoint2ByteFloatTemperature.cs b/src/KNXLib/DPT/DataPoint2ByteFloatTemperature.cs
new file mode 100644
index 0000000..9ee66e7
--- /dev/null
+++ b/src/KNXLib/DPT/DataPoint2ByteFloatTemperature.cs
@@ -0,0 +1,129 @@
+using System;
+using System.Globalization;
+using KNXLib.Log;
+
+namespace KNXLib.DPT
+{
+ internal sealed class DataPoint2ByteFloatTemperature : DataPoint
+ {
+ public override string[] Ids
+ {
+ get
+ {
+ return new[] { "9.001" };
+ }
+ }
+
+ public override object FromDataPoint(string data)
+ {
+ var dataConverted = new byte[data.Length];
+ for (var i = 0; i < data.Length; i++)
+ dataConverted[i] = (byte) data[i];
+
+ return FromDataPoint(dataConverted);
+ }
+
+ public override object FromDataPoint(byte[] data)
+ {
+ // DPT bits high byte: MEEEEMMM, low byte: MMMMMMMM
+ // first M is signed state from two's complement notation
+
+ int val = 0;
+ uint m = (uint) ((data[0] & 0x07) << 8) | (data[1]);
+ bool signed = ((data[0] & 0x80) >> 7) == 1;
+
+ if (signed)
+ {
+ // change for two's complement notation and use only mantissa bytes
+ m = m - 1;
+ m = ~(m);
+ m = m & (0 | 0x07FF);
+ val = (int) (m * -1);
+ }
+ else
+ {
+ val = (int) m;
+ }
+
+ int power = (data[0] & 0x78) >> 3;
+
+ double calc = 0.01d * val;
+
+ return (decimal) Math.Round(calc * Math.Pow(2, power), 2);
+ }
+
+ public override byte[] ToDataPoint(string value)
+ {
+ return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
+ }
+
+ public override byte[] ToDataPoint(object val)
+ {
+ var dataPoint = new byte[] { 0x00, 0x00, 0x00 };
+
+ decimal value;
+ if (val is int)
+ value = (int) val;
+ else if (val is float)
+ value = (decimal) ((float) val);
+ else if (val is long)
+ value = (long) val;
+ else if (val is double)
+ value = (decimal) ((double) val);
+ else if (val is decimal)
+ value = (decimal) val;
+ else
+ {
+ Logger.Error("9.001", "input value received is not a valid type");
+ return dataPoint;
+ }
+
+ if (value < -273 || value > +670760)
+ {
+ Logger.Error("9.001", "input value received is not in a valid range");
+ return dataPoint;
+ }
+
+ // value will be multiplied by 0.01
+ decimal v = Math.Round(value * 100m);
+ // mantissa only holds 11 bits for value, so, check if exponet is required
+ int e = 0;
+ while (v < -2048m)
+ {
+ v = v / 2;
+ e++;
+ }
+ while (v > 2047m)
+ {
+ v = v / 2;
+ e++;
+ }
+
+ int mantissa;
+ bool signed;
+ if (v < 0)
+ {
+ // negative value > two's complement
+ signed = true;
+ mantissa = ((int) v * -1);
+ mantissa = ~mantissa;
+ mantissa = mantissa + 1;
+ }
+ else
+ {
+ signed = false;
+ mantissa = (int) v;
+ }
+
+ // signed value > enable first bit
+ if (signed)
+ dataPoint[1] = 0x80;
+
+ dataPoint[1] = ((byte) (dataPoint[1] | ((e & 0x0F) << 3)));
+ dataPoint[1] = ((byte) (dataPoint[1] | ((mantissa >> 8) & 0x07)));
+ dataPoint[2] = ((byte) mantissa);
+
+ return dataPoint;
+ }
+ }
+}
diff --git a/src/KNXLib/DPT/ThreeBitWithControl.cs b/src/KNXLib/DPT/DataPoint3BitControl.cs
similarity index 83%
rename from src/KNXLib/DPT/ThreeBitWithControl.cs
rename to src/KNXLib/DPT/DataPoint3BitControl.cs
index f7ac7e9..7415a7f 100644
--- a/src/KNXLib/DPT/ThreeBitWithControl.cs
+++ b/src/KNXLib/DPT/DataPoint3BitControl.cs
@@ -1,78 +1,85 @@
-using System;
-using System.Globalization;
-using System.Linq;
-
-namespace KNXLib.DPT
-{
- internal sealed class ThreeBitWithControl : DataPoint
- {
- public override string[] Ids
- {
- get { return new[] { "3.008", "3.007" }; }
- }
-
- public override object FromDataPoint(string data)
- {
- var dataConverted = new byte[data.Length];
- for (var i = 0; i < data.Length; i++)
- dataConverted[i] = (byte)data[i];
-
- return FromDataPoint(dataConverted);
- }
-
- public override object FromDataPoint(byte[] data)
- {
- if (data == null || data.Length != 1)
- return 0;
-
- int input = data[0] & 0x0F;
-
- bool direction = (input >> 3) == 1;
- int step = input & 0x07;
-
- return direction ? step : (step * -1);
- }
-
- public override byte[] ToDataPoint(string value)
- {
- return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
- }
-
- public override byte[] ToDataPoint(object val)
- {
- var dataPoint = new byte[1];
- dataPoint[0] = 0x00;
-
- int input = 0;
- if (val is int)
- input = ((int) val);
- else if (val is float)
- input = (int) ((float) val);
- else if (val is long)
- input = (int) ((long) val);
- else if (val is double)
- input = (int) ((double) val);
- else if (val is decimal)
- input = (int) ((decimal) val);
- else
- return dataPoint;
-
- if (input > 7 || input < -7)
- return dataPoint;
-
- var direction = 8; // binary 1000
-
- if (input <= 0)
- {
- direction = 0;
- input = input * -1;
- }
-
- int step = (input & 7);
-
- dataPoint[0] = (byte)(step | direction);
-
- return dataPoint;
- }
- }
+using System;
+using System.Globalization;
+using System.Linq;
+using KNXLib.Log;
+
+namespace KNXLib.DPT
+{
+ internal sealed class DataPoint3BitControl : DataPoint
+ {
+ public override string[] Ids
+ {
+ get { return new[] { "3.008", "3.007" }; }
+ }
+
+ public override object FromDataPoint(string data)
+ {
+ var dataConverted = new byte[data.Length];
+ for (var i = 0; i < data.Length; i++)
+ dataConverted[i] = (byte)data[i];
+
+ return FromDataPoint(dataConverted);
+ }
+
+ public override object FromDataPoint(byte[] data)
+ {
+ if (data == null || data.Length != 1)
+ return 0;
+
+ int input = data[0] & 0x0F;
+
+ bool direction = (input >> 3) == 1;
+ int step = input & 0x07;
+
+ return direction ? step : (step * -1);
+ }
+
+ public override byte[] ToDataPoint(string value)
+ {
+ return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
+ }
+
+ public override byte[] ToDataPoint(object val)
+ {
+ var dataPoint = new byte[1];
+ dataPoint[0] = 0x00;
+
+ int input = 0;
+ if (val is int)
+ input = ((int) val);
+ else if (val is float)
+ input = (int) ((float) val);
+ else if (val is long)
+ input = (int) ((long) val);
+ else if (val is double)
+ input = (int) ((double) val);
+ else if (val is decimal)
+ input = (int) ((decimal) val);
+ else
+ {
+ Logger.Error("6.xxx", "input value received is not a valid type");
+ return dataPoint;
+ }
+
+ if (input > 7 || input < -7)
+ {
+ Logger.Error("3.xxx", "input value received is not in a valid range");
+ return dataPoint;
+ }
+
+ var direction = 8; // binary 1000
+
+ if (input <= 0)
+ {
+ direction = 0;
+ input = input * -1;
+ }
+
+ int step = (input & 7);
+
+ dataPoint[0] = (byte)(step | direction);
+
+ return dataPoint;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/KNXLib/DPT/EightBitWithoutSignNonScaledValue1UCount.cs b/src/KNXLib/DPT/DataPoint8BitNoSignNonScaledValue1UCount.cs
similarity index 81%
rename from src/KNXLib/DPT/EightBitWithoutSignNonScaledValue1UCount.cs
rename to src/KNXLib/DPT/DataPoint8BitNoSignNonScaledValue1UCount.cs
index 900218a..03712c5 100644
--- a/src/KNXLib/DPT/EightBitWithoutSignNonScaledValue1UCount.cs
+++ b/src/KNXLib/DPT/DataPoint8BitNoSignNonScaledValue1UCount.cs
@@ -1,63 +1,70 @@
-using System;
-using System.Globalization;
-using System.Linq;
-
-namespace KNXLib.DPT
-{
- internal sealed class EightBitWithoutSignNonScaledValue1UCount : DataPoint
- {
- public override string[] Ids
- {
- get { return new[] { "5.010" }; }
- }
-
- public override object FromDataPoint(string data)
- {
- var dataConverted = new byte[data.Length];
- for (var i = 0; i < data.Length; i++)
- dataConverted[i] = (byte) data[i];
-
- return FromDataPoint(dataConverted);
- }
-
- public override object FromDataPoint(byte[] data)
- {
- if (data == null || data.Length != 1)
- return 0;
-
- return (int) data[0];
- }
-
- public override byte[] ToDataPoint(string value)
- {
- return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
- }
-
- public override byte[] ToDataPoint(object val)
- {
- var dataPoint = new byte[1];
- dataPoint[0] = 0x00;
-
- int input = 0;
- if (val is int)
- input = ((int) val);
- else if (val is float)
- input = (int) ((float) val);
- else if (val is long)
- input = (int) ((long) val);
- else if (val is double)
- input = (int) ((double) val);
- else if (val is decimal)
- input = (int) ((decimal) val);
- else
- return dataPoint;
-
- if (input < 0 || input > 255)
- return dataPoint;
-
- dataPoint[0] = (byte) input;
-
- return dataPoint;
- }
- }
+using System;
+using System.Globalization;
+using System.Linq;
+using KNXLib.Log;
+
+namespace KNXLib.DPT
+{
+ internal sealed class DataPoint8BitNoSignNonScaledValue1UCount : DataPoint
+ {
+ public override string[] Ids
+ {
+ get { return new[] { "5.010" }; }
+ }
+
+ public override object FromDataPoint(string data)
+ {
+ var dataConverted = new byte[data.Length];
+ for (var i = 0; i < data.Length; i++)
+ dataConverted[i] = (byte) data[i];
+
+ return FromDataPoint(dataConverted);
+ }
+
+ public override object FromDataPoint(byte[] data)
+ {
+ if (data == null || data.Length != 1)
+ return 0;
+
+ return (int) data[0];
+ }
+
+ public override byte[] ToDataPoint(string value)
+ {
+ return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
+ }
+
+ public override byte[] ToDataPoint(object val)
+ {
+ var dataPoint = new byte[1];
+ dataPoint[0] = 0x00;
+
+ int input = 0;
+ if (val is int)
+ input = ((int) val);
+ else if (val is float)
+ input = (int) ((float) val);
+ else if (val is long)
+ input = (int) ((long) val);
+ else if (val is double)
+ input = (int) ((double) val);
+ else if (val is decimal)
+ input = (int) ((decimal) val);
+ else
+ {
+ Logger.Error("5.010", "input value received is not a valid type");
+ return dataPoint;
+ }
+
+ if (input < 0 || input > 255)
+ {
+ Logger.Error("5.010", "input value received is not in a valid range");
+ return dataPoint;
+ }
+
+ dataPoint[0] = (byte) input;
+
+ return dataPoint;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/KNXLib/DPT/EightBitWithoutSignScaledAngle.cs b/src/KNXLib/DPT/DataPoint8BitNoSignScaledAngle.cs
similarity index 82%
rename from src/KNXLib/DPT/EightBitWithoutSignScaledAngle.cs
rename to src/KNXLib/DPT/DataPoint8BitNoSignScaledAngle.cs
index e1384ba..9e441e0 100644
--- a/src/KNXLib/DPT/EightBitWithoutSignScaledAngle.cs
+++ b/src/KNXLib/DPT/DataPoint8BitNoSignScaledAngle.cs
@@ -1,71 +1,78 @@
-using System;
-using System.Globalization;
-using System.Linq;
-
-namespace KNXLib.DPT
-{
- internal sealed class EightBitWithoutSignScaledAngle : DataPoint
- {
- public override string[] Ids
- {
- get { return new[] { "5.003" }; }
- }
-
- public override object FromDataPoint(string data)
- {
- var dataConverted = new byte[data.Length];
- for (var i = 0; i < data.Length; i++)
- dataConverted[i] = (byte) data[i];
-
- return FromDataPoint(dataConverted);
- }
-
- public override object FromDataPoint(byte[] data)
- {
- if (data == null || data.Length != 1)
- return 0;
-
- var value = (int) data[0];
-
- decimal result = value * 360;
- result = result / 255;
-
- return result;
- }
-
- public override byte[] ToDataPoint(string value)
- {
- return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
- }
-
- public override byte[] ToDataPoint(object val)
- {
- var dataPoint = new byte[1];
- dataPoint[0] = 0x00;
-
- decimal input = 0;
- if (val is int)
- input = (decimal) ((int) val);
- else if (val is float)
- input = (decimal) ((float) val);
- else if (val is long)
- input = (decimal) ((long) val);
- else if (val is double)
- input = (decimal) ((double) val);
- else if (val is decimal)
- input = (decimal) val;
- else
- return dataPoint;
-
- if (input < 0 || input > 360)
- return dataPoint;
-
- input = input * 255;
- input = input / 360;
-
- dataPoint[0] = (byte) ((int) input);
-
- return dataPoint;
- }
- }
+using System;
+using System.Globalization;
+using System.Linq;
+using KNXLib.Log;
+
+namespace KNXLib.DPT
+{
+ internal sealed class DataPoint8BitNoSignScaledAngle : DataPoint
+ {
+ public override string[] Ids
+ {
+ get { return new[] { "5.003" }; }
+ }
+
+ public override object FromDataPoint(string data)
+ {
+ var dataConverted = new byte[data.Length];
+ for (var i = 0; i < data.Length; i++)
+ dataConverted[i] = (byte) data[i];
+
+ return FromDataPoint(dataConverted);
+ }
+
+ public override object FromDataPoint(byte[] data)
+ {
+ if (data == null || data.Length != 1)
+ return 0;
+
+ var value = (int) data[0];
+
+ decimal result = value * 360;
+ result = result / 255;
+
+ return result;
+ }
+
+ public override byte[] ToDataPoint(string value)
+ {
+ return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
+ }
+
+ public override byte[] ToDataPoint(object val)
+ {
+ var dataPoint = new byte[1];
+ dataPoint[0] = 0x00;
+
+ decimal input = 0;
+ if (val is int)
+ input = (decimal) ((int) val);
+ else if (val is float)
+ input = (decimal) ((float) val);
+ else if (val is long)
+ input = (decimal) ((long) val);
+ else if (val is double)
+ input = (decimal) ((double) val);
+ else if (val is decimal)
+ input = (decimal) val;
+ else
+ {
+ Logger.Error("5.003", "input value received is not a valid type");
+ return dataPoint;
+ }
+
+ if (input < 0 || input > 360)
+ {
+ Logger.Error("5.003", "input value received is not in a valid range");
+ return dataPoint;
+ }
+
+ input = input * 255;
+ input = input / 360;
+
+ dataPoint[0] = (byte) ((int) input);
+
+ return dataPoint;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/KNXLib/DPT/EightBitWithoutSignScaledPercentU8.cs b/src/KNXLib/DPT/DataPoint8BitNoSignScaledPercentU8.cs
similarity index 81%
rename from src/KNXLib/DPT/EightBitWithoutSignScaledPercentU8.cs
rename to src/KNXLib/DPT/DataPoint8BitNoSignScaledPercentU8.cs
index 91839d3..c121b8a 100644
--- a/src/KNXLib/DPT/EightBitWithoutSignScaledPercentU8.cs
+++ b/src/KNXLib/DPT/DataPoint8BitNoSignScaledPercentU8.cs
@@ -1,63 +1,70 @@
-using System;
-using System.Globalization;
-using System.Linq;
-
-namespace KNXLib.DPT
-{
- internal sealed class EightBitWithoutSignScaledPercentU8 : DataPoint
- {
- public override string[] Ids
- {
- get { return new[] { "5.004" }; }
- }
-
- public override object FromDataPoint(string data)
- {
- var dataConverted = new byte[data.Length];
- for (var i = 0; i < data.Length; i++)
- dataConverted[i] = (byte) data[i];
-
- return FromDataPoint(dataConverted);
- }
-
- public override object FromDataPoint(byte[] data)
- {
- if (data == null || data.Length != 1)
- return 0;
-
- return (int) data[0];
- }
-
- public override byte[] ToDataPoint(string value)
- {
- return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
- }
-
- public override byte[] ToDataPoint(object val)
- {
- var dataPoint = new byte[1];
- dataPoint[0] = 0x00;
-
- int input = 0;
- if (val is int)
- input = ((int) val);
- else if (val is float)
- input = (int) ((float) val);
- else if (val is long)
- input = (int) ((long) val);
- else if (val is double)
- input = (int) ((double) val);
- else if (val is decimal)
- input = (int) ((decimal) val);
- else
- return dataPoint;
-
- if (input < 0 || input > 255)
- return dataPoint;
-
- dataPoint[0] = (byte) input;
-
- return dataPoint;
- }
- }
+using System;
+using System.Globalization;
+using System.Linq;
+using KNXLib.Log;
+
+namespace KNXLib.DPT
+{
+ internal sealed class DataPoint8BitNoSignScaledPercentU8 : DataPoint
+ {
+ public override string[] Ids
+ {
+ get { return new[] { "5.004" }; }
+ }
+
+ public override object FromDataPoint(string data)
+ {
+ var dataConverted = new byte[data.Length];
+ for (var i = 0; i < data.Length; i++)
+ dataConverted[i] = (byte) data[i];
+
+ return FromDataPoint(dataConverted);
+ }
+
+ public override object FromDataPoint(byte[] data)
+ {
+ if (data == null || data.Length != 1)
+ return 0;
+
+ return (int) data[0];
+ }
+
+ public override byte[] ToDataPoint(string value)
+ {
+ return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
+ }
+
+ public override byte[] ToDataPoint(object val)
+ {
+ var dataPoint = new byte[1];
+ dataPoint[0] = 0x00;
+
+ int input = 0;
+ if (val is int)
+ input = ((int) val);
+ else if (val is float)
+ input = (int) ((float) val);
+ else if (val is long)
+ input = (int) ((long) val);
+ else if (val is double)
+ input = (int) ((double) val);
+ else if (val is decimal)
+ input = (int) ((decimal) val);
+ else
+ {
+ Logger.Error("5.004", "input value received is not a valid type");
+ return dataPoint;
+ }
+
+ if (input < 0 || input > 255)
+ {
+ Logger.Error("5.004", "input value received is not in a valid range");
+ return dataPoint;
+ }
+
+ dataPoint[0] = (byte) input;
+
+ return dataPoint;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/KNXLib/DPT/EightBitWithoutSignScaledScaling.cs b/src/KNXLib/DPT/DataPoint8BitNoSignScaledScaling.cs
similarity index 82%
rename from src/KNXLib/DPT/EightBitWithoutSignScaledScaling.cs
rename to src/KNXLib/DPT/DataPoint8BitNoSignScaledScaling.cs
index 937a267..f3fb4c4 100644
--- a/src/KNXLib/DPT/EightBitWithoutSignScaledScaling.cs
+++ b/src/KNXLib/DPT/DataPoint8BitNoSignScaledScaling.cs
@@ -1,71 +1,78 @@
-using System;
-using System.Globalization;
-using System.Linq;
-
-namespace KNXLib.DPT
-{
- internal sealed class EightBitWithoutSignScaledScaling : DataPoint
- {
- public override string[] Ids
- {
- get { return new[] { "5.001" }; }
- }
-
- public override object FromDataPoint(string data)
- {
- var dataConverted = new byte[data.Length];
- for (var i = 0; i < data.Length; i++)
- dataConverted[i] = (byte) data[i];
-
- return FromDataPoint(dataConverted);
- }
-
- public override object FromDataPoint(byte[] data)
- {
- if (data == null || data.Length != 1)
- return 0;
-
- var value = (int) data[0];
-
- decimal result = value * 100;
- result = result / 255;
-
- return result;
- }
-
- public override byte[] ToDataPoint(string value)
- {
- return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
- }
-
- public override byte[] ToDataPoint(object val)
- {
- var dataPoint = new byte[1];
- dataPoint[0] = 0x00;
-
- decimal input = 0;
- if (val is int)
- input = (decimal) ((int) val);
- else if (val is float)
- input = (decimal) ((float) val);
- else if (val is long)
- input = (decimal) ((long) val);
- else if (val is double)
- input = (decimal) ((double) val);
- else if (val is decimal)
- input = (decimal) val;
- else
- return dataPoint;
-
- if (input < 0 || input > 100)
- return dataPoint;
-
- input = input * 255;
- input = input / 100;
-
- dataPoint[0] = (byte) (input);
-
- return dataPoint;
- }
- }
+using System;
+using System.Globalization;
+using System.Linq;
+using KNXLib.Log;
+
+namespace KNXLib.DPT
+{
+ internal sealed class DataPoint8BitNoSignScaledScaling : DataPoint
+ {
+ public override string[] Ids
+ {
+ get { return new[] { "5.001" }; }
+ }
+
+ public override object FromDataPoint(string data)
+ {
+ var dataConverted = new byte[data.Length];
+ for (var i = 0; i < data.Length; i++)
+ dataConverted[i] = (byte) data[i];
+
+ return FromDataPoint(dataConverted);
+ }
+
+ public override object FromDataPoint(byte[] data)
+ {
+ if (data == null || data.Length != 1)
+ return 0;
+
+ var value = (int) data[0];
+
+ decimal result = value * 100;
+ result = result / 255;
+
+ return result;
+ }
+
+ public override byte[] ToDataPoint(string value)
+ {
+ return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
+ }
+
+ public override byte[] ToDataPoint(object val)
+ {
+ var dataPoint = new byte[1];
+ dataPoint[0] = 0x00;
+
+ decimal input = 0;
+ if (val is int)
+ input = (decimal) ((int) val);
+ else if (val is float)
+ input = (decimal) ((float) val);
+ else if (val is long)
+ input = (decimal) ((long) val);
+ else if (val is double)
+ input = (decimal) ((double) val);
+ else if (val is decimal)
+ input = (decimal) val;
+ else
+ {
+ Logger.Error("5.001", "input value received is not a valid type");
+ return dataPoint;
+ }
+
+ if (input < 0 || input > 100)
+ {
+ Logger.Error("5.001", "input value received is not in a valid range");
+ return dataPoint;
+ }
+
+ input = input * 255;
+ input = input / 100;
+
+ dataPoint[0] = (byte) (input);
+
+ return dataPoint;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/KNXLib/DPT/EightBitWithSignRelativeValue.cs b/src/KNXLib/DPT/DataPoint8BitSignRelativeValue.cs
similarity index 81%
rename from src/KNXLib/DPT/EightBitWithSignRelativeValue.cs
rename to src/KNXLib/DPT/DataPoint8BitSignRelativeValue.cs
index 0aa211f..8818ca0 100644
--- a/src/KNXLib/DPT/EightBitWithSignRelativeValue.cs
+++ b/src/KNXLib/DPT/DataPoint8BitSignRelativeValue.cs
@@ -1,63 +1,70 @@
-using System;
-using System.Globalization;
-using System.Linq;
-
-namespace KNXLib.DPT
-{
- internal sealed class EightBitWithSignRelativeValue : DataPoint
- {
- public override string[] Ids
- {
- get { return new[] { "6.001", "6.010" }; }
- }
-
- public override object FromDataPoint(string data)
- {
- var dataConverted = new byte[data.Length];
- for (var i = 0; i < data.Length; i++)
- dataConverted[i] = (byte) data[i];
-
- return FromDataPoint(dataConverted);
- }
-
- public override object FromDataPoint(byte[] data)
- {
- if (data == null || data.Length != 1)
- return 0;
-
- return (int) ((sbyte) data[0]);
- }
-
- public override byte[] ToDataPoint(string value)
- {
- return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
- }
-
- public override byte[] ToDataPoint(object val)
- {
- var dataPoint = new byte[1];
- dataPoint[0] = 0x00;
-
- int input = 0;
- if (val is int)
- input = ((int) val);
- else if (val is float)
- input = (int) ((float) val);
- else if (val is long)
- input = (int) ((long) val);
- else if (val is double)
- input = (int) ((double) val);
- else if (val is decimal)
- input = (int) ((decimal) val);
- else
- return dataPoint;
-
- if (input < -128 || input > 127)
- return dataPoint;
-
- dataPoint[0] = (byte) ((sbyte) ((int) input));
-
- return dataPoint;
- }
- }
+using System;
+using System.Globalization;
+using System.Linq;
+using KNXLib.Log;
+
+namespace KNXLib.DPT
+{
+ internal sealed class DataPoint8BitSignRelativeValue : DataPoint
+ {
+ public override string[] Ids
+ {
+ get { return new[] { "6.001", "6.010" }; }
+ }
+
+ public override object FromDataPoint(string data)
+ {
+ var dataConverted = new byte[data.Length];
+ for (var i = 0; i < data.Length; i++)
+ dataConverted[i] = (byte) data[i];
+
+ return FromDataPoint(dataConverted);
+ }
+
+ public override object FromDataPoint(byte[] data)
+ {
+ if (data == null || data.Length != 1)
+ return 0;
+
+ return (int) ((sbyte) data[0]);
+ }
+
+ public override byte[] ToDataPoint(string value)
+ {
+ return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
+ }
+
+ public override byte[] ToDataPoint(object val)
+ {
+ var dataPoint = new byte[1];
+ dataPoint[0] = 0x00;
+
+ int input = 0;
+ if (val is int)
+ input = ((int) val);
+ else if (val is float)
+ input = (int) ((float) val);
+ else if (val is long)
+ input = (int) ((long) val);
+ else if (val is double)
+ input = (int) ((double) val);
+ else if (val is decimal)
+ input = (int) ((decimal) val);
+ else
+ {
+ Logger.Error("6.xxx", "input value received is not a valid type");
+ return dataPoint;
+ }
+
+ if (input < -128 || input > 127)
+ {
+ Logger.Error("6.xxx", "input value received is not in a valid range");
+ return dataPoint;
+ }
+
+ dataPoint[0] = (byte) ((sbyte) ((int) input));
+
+ return dataPoint;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/KNXLib/DPT/Temperature.cs b/src/KNXLib/DPT/Temperature.cs
deleted file mode 100644
index d983cd5..0000000
--- a/src/KNXLib/DPT/Temperature.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using System;
-using System.Globalization;
-
-namespace KNXLib.DPT
-{
- internal sealed class Temperature : DataPoint
- {
- public override string[] Ids
- {
- get
- {
- return new[] {"9.001"};
- }
- }
-
- public override object FromDataPoint(string data)
- {
- var dataConverted = new byte[data.Length];
- for (var i = 0; i < data.Length; i++)
- dataConverted[i] = (byte) data[i];
-
- return FromDataPoint(dataConverted);
- }
-
- public override object FromDataPoint(byte[] data)
- {
- // DPT bits high byte: MEEEEMMM, low byte: MMMMMMMM
- // left align all mantissa bits
- int v = ((data[0] & 0x80) << 24) | ((data[0] & 0x7) << 28) | (data[1] << 20);
-
- // normalize
- v >>= 20;
- int exp = (data[0] & 0x78) >> 3;
- return (1 << exp)*v*0.01m;
- }
-
- public override byte[] ToDataPoint(string value)
- {
- return ToDataPoint(float.Parse(value, CultureInfo.InvariantCulture));
- }
-
- public override byte[] ToDataPoint(object val)
- {
- var dataPoint = new byte[] {0x00, 0x00, 0x00};
-
- decimal value;
- if (val is int)
- value = (int) val;
- else if (val is float)
- value = (decimal) ((float) val);
- else if (val is long)
- value = (long) val;
- else if (val is double)
- value = (decimal) ((double) val);
- else if (val is decimal)
- value = (decimal) val;
- else
- return dataPoint;
-
- if (value < -273 || value > +670760)
- return null;
-
- // encoding: value = (0.01*M)*2^E
- decimal v = (value/2m)*100.0m;
- var e = 1;
- for (; v < -2048.0m; v /= 2)
- e++;
- for (; v > 2047.0m; v /= 2)
- e++;
-
- int m = ((int) Math.Round(v)) & 0x7FF;
- var msb = (short) (e << 3 | m >> 8);
- if (value < 0.0m)
- msb |= 0x80;
-
- dataPoint[0] = 0x00;
- dataPoint[1] = (byte) msb;
- dataPoint[2] = (byte) m;
-
- return dataPoint;
- }
- }
-}
diff --git a/src/KNXLib/Exceptions/InvalidHostException.cs b/src/KNXLib/Exceptions/InvalidHostException.cs
index 1fb18ca..5c35584 100644
--- a/src/KNXLib/Exceptions/InvalidHostException.cs
+++ b/src/KNXLib/Exceptions/InvalidHostException.cs
@@ -2,15 +2,28 @@
namespace KNXLib.Exceptions
{
+ ///
+ /// Exception thrown when trying to connect to an invalid host
+ ///
public class InvalidHostException : Exception
{
private readonly string _host;
+ ///
+ /// Initializes a new instance of the InvalidHostException class
+ ///
+ ///
public InvalidHostException(string host)
{
_host = host;
}
+ ///
+ /// Creates and returns a string representation of the current exception.
+ ///
+ ///
+ /// A string representation of the current exception.
+ ///
public override string ToString()
{
return string.Format("InvalidHostException: Host {0} is invalid.", _host);
diff --git a/src/KNXLib/Exceptions/InvalidKnxAddressException.cs b/src/KNXLib/Exceptions/InvalidKnxAddressException.cs
index ad97f04..d2b4a9b 100644
--- a/src/KNXLib/Exceptions/InvalidKnxAddressException.cs
+++ b/src/KNXLib/Exceptions/InvalidKnxAddressException.cs
@@ -2,15 +2,28 @@
namespace KNXLib.Exceptions
{
+ ///
+ /// Exception thrown when an invalid KNX address is used to perform an action or status query
+ ///
public class InvalidKnxAddressException : Exception
{
private readonly string _address;
+ ///
+ /// Initializes a new instance of the InvalidKnxAddressException class.
+ ///
+ ///
public InvalidKnxAddressException(string address)
{
_address = address;
}
+ ///
+ /// Creates and returns a string representation of the current exception.
+ ///
+ ///
+ /// A string representation of the current exception.
+ ///
public override string ToString()
{
return string.Format("InvalidKnxAddressException: Address {0} is invalid.", _address);
diff --git a/src/KNXLib/Exceptions/InvalidKnxDataException.cs b/src/KNXLib/Exceptions/InvalidKnxDataException.cs
index b50e62a..86c3975 100644
--- a/src/KNXLib/Exceptions/InvalidKnxDataException.cs
+++ b/src/KNXLib/Exceptions/InvalidKnxDataException.cs
@@ -2,15 +2,28 @@
namespace KNXLib.Exceptions
{
+ ///
+ /// Exception is thrown when invalid data has been provided to an action method
+ ///
public class InvalidKnxDataException : Exception
{
private readonly string _data;
+ ///
+ /// Initializes a new instance of the InvalidKnxDataException class.
+ ///
+ ///
public InvalidKnxDataException(string data)
{
_data = data;
}
+ ///
+ /// Creates and returns a string representation of the current exception.
+ ///
+ ///
+ /// A string representation of the current exception.
+ ///
public override string ToString()
{
return string.Format("InvalidKnxDataException: Data {0} is invalid.", _data);
diff --git a/src/KNXLib/Exceptions/InvalidValueException.cs b/src/KNXLib/Exceptions/InvalidValueException.cs
deleted file mode 100644
index cf15273..0000000
--- a/src/KNXLib/Exceptions/InvalidValueException.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-
-namespace KNXLib.Exceptions
-{
- public class InvalidValueException : Exception
- {
- private readonly string _value;
- private readonly string _dpt;
-
- public InvalidValueException(string value, string dpt)
- {
- _value = value;
- _dpt = dpt;
- }
-
- public override string ToString()
- {
- return string.Format("InvalidValueException: Value {0} is invalid for datapoint type {1}.", _value, _dpt);
- }
- }
-}
\ No newline at end of file
diff --git a/src/KNXLib/Exceptions/MultipleLocalInterfacesException.cs b/src/KNXLib/Exceptions/MultipleLocalInterfacesException.cs
deleted file mode 100644
index 2aa55b4..0000000
--- a/src/KNXLib/Exceptions/MultipleLocalInterfacesException.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-
-namespace KNXLib.Exceptions
-{
- public class MultipleLocalInterfacesException : Exception
- {
- public override string ToString()
- {
- return "MultipleLocalInterfacesException: With IP Tunneling you can only have a single network interface or you must provide the local interface addres you are using to connect!";
- }
- }
-}
\ No newline at end of file
diff --git a/src/KNXLib/KNXLib.csproj b/src/KNXLib/KNXLib.csproj
index 54a00b1..da46a7d 100644
--- a/src/KNXLib/KNXLib.csproj
+++ b/src/KNXLib/KNXLib.csproj
@@ -38,24 +38,22 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
diff --git a/src/KNXLib/KNXLib.nuspec b/src/KNXLib/KNXLib.nuspec
index eda104d..423a934 100644
--- a/src/KNXLib/KNXLib.nuspec
+++ b/src/KNXLib/KNXLib.nuspec
@@ -1,17 +1,17 @@
-
-
-
- $title$
- $version$
- $title$
- $author$
- $author$
- http://lifeemotions.github.io/knx.net/ref/license.txt
- http://lifeemotions.github.io/knx.net/
- false
- $description$
- Added 3 bit with control datapoint for dimming and blinds control.
- Copyright 2012
- knx .net c#
-
+
+
+
+ $title$
+ $version$
+ $title$
+ $author$
+ $author$
+ http://lifeemotions.github.io/knx.net/ref/license.txt
+ http://lifeemotions.github.io/knx.net/
+ false
+ $description$
+ Added datapoints 5.xxx and 6.xxx. Updated documentation. Fixed issues with 9.001 datapoint.
+ Copyright 2012
+ knx .net c#
+
\ No newline at end of file
diff --git a/src/KNXLib/KnxConnection.cs b/src/KNXLib/KnxConnection.cs
index 99ea7e5..dc39197 100644
--- a/src/KNXLib/KnxConnection.cs
+++ b/src/KNXLib/KnxConnection.cs
@@ -3,60 +3,65 @@
using System.Text;
using KNXLib.DPT;
using KNXLib.Exceptions;
+using KNXLib.Log;
namespace KNXLib
{
///
- ///
+ /// Base class that controls the KNX connection, implemented by KnxConnectionRouting and KnxConnetionTunneling
///
public abstract class KnxConnection
{
private static readonly string ClassName = typeof(KnxConnection).ToString();
///
- ///
+ /// Delegate function for connection established trigger
///
public delegate void KnxConnected();
+
///
- ///
+ /// Event triggered when connection is established
///
public KnxConnected KnxConnectedDelegate = null;
///
- ///
+ /// Delegate function for disconnection trigger
///
public delegate void KnxDisconnected();
+
///
- ///
+ /// Event triggered when connection drops
///
public KnxDisconnected KnxDisconnectedDelegate = null;
///
- ///
+ /// Delegate function for KNX events
///
///
///
public delegate void KnxEvent(string address, string state);
+
///
- ///
+ /// Event triggered when there is a new KNX event
///
public KnxEvent KnxEventDelegate = (address, state) => { };
///
- ///
+ /// Delegate function for KNX status queries
///
///
///
public delegate void KnxStatus(string address, string state);
+
///
- ///
+ /// Event triggered when received a status after a query
///
public KnxStatus KnxStatusDelegate = (address, state) => { };
private readonly KnxLockManager _lockManager = new KnxLockManager();
///
- /// Create a new KNX Connection to specified host and port
+ /// Create a new KNX Connection to specified host and port
///
/// Host to connect
/// Port to use
@@ -72,11 +77,14 @@ protected KnxConnection(string host, int port)
internal KnxConnectionConfiguration ConnectionConfiguration { get; private set; }
///
- ///
+ /// Get the IPEndPoint instance representing the remote KNX gateway
///
- protected IPEndPoint RemoteEndpoint
+ public IPEndPoint RemoteEndpoint
{
- get { return ConnectionConfiguration.EndPoint; }
+ get
+ {
+ return ConnectionConfiguration.EndPoint;
+ }
}
internal KnxReceiver KnxReceiver { get; set; }
@@ -84,36 +92,36 @@ protected IPEndPoint RemoteEndpoint
internal KnxSender KnxSender { get; set; }
///
- /// Configure this paramenter based on the KNX installation:
- /// - true: 3-level group address: main/middle/sub(5/3/8 bits)
- /// - false: 2-level group address: main/sub (5/11 bits)
- /// Default: true
+ /// Configure this paramenter based on the KNX installation:
+ /// - true: 3-level group address: main/middle/sub(5/3/8 bits)
+ /// - false: 2-level group address: main/sub (5/11 bits)
+ /// Default: true
///
public bool ThreeLevelGroupAddressing { get; set; }
///
- /// Set to true to receive debug log messages
+ /// Set to true to receive debug log messages
///
public bool Debug { get; set; }
///
- /// Some KNX Routers/Interfaces might need this parameter defined, some of them need this to be 0x29.
- /// Default: 0x00
+ /// Some KNX Routers/Interfaces might need this parameter defined, some need this to be 0x29.
+ /// Default: 0x00
///
public byte ActionMessageCode { get; set; }
///
- /// Start the connection
+ /// Start the connection
///
public abstract void Connect();
///
- /// Stop the connection
+ /// Stop the connection
///
public abstract void Disconnect();
///
- /// Event triggered by implementing class to notify that the connection has been established
+ /// Event triggered by implementing class to notify that the connection has been established
///
internal virtual void Connected()
{
@@ -127,14 +135,14 @@ internal virtual void Connected()
//ignore
}
- Log.Logger.Info(ClassName, "KNX is connected");
- Log.Logger.Debug(ClassName, "Unlocking send - {0} free locks", _lockManager.LockCount);
+ Logger.Info(ClassName, "KNX is connected");
+ Logger.Debug(ClassName, "Unlocking send - {0} free locks", _lockManager.LockCount);
_lockManager.UnlockConnection();
}
///
- /// Event triggered by implementing class to notify that the connection has been established
+ /// Event triggered by implementing class to notify that the connection has been established
///
internal virtual void Disconnected()
{
@@ -150,8 +158,8 @@ internal virtual void Disconnected()
//ignore
}
- Log.Logger.Debug(ClassName, "KNX is disconnected");
- Log.Logger.Debug(ClassName, "Send locked - {0} free locks", _lockManager.LockCount);
+ Logger.Debug(ClassName, "KNX is disconnected");
+ Logger.Debug(ClassName, "Send locked - {0} free locks", _lockManager.LockCount);
}
internal void Event(string address, string state)
@@ -165,7 +173,7 @@ internal void Event(string address, string state)
//ignore
}
- Log.Logger.Debug(ClassName, "Device {0} sent event {1}", address, state);
+ Logger.Debug(ClassName, "Device {0} sent event {1}", address, state);
}
internal void Status(string address, string state)
@@ -179,11 +187,11 @@ internal void Status(string address, string state)
//ignore
}
- Log.Logger.Debug(ClassName, "Device {0} has status {1}", address, state);
+ Logger.Debug(ClassName, "Device {0} has status {1}", address, state);
}
///
- /// Send a bit value as data to specified address
+ /// Send a bit value as data to specified address
///
/// KNX Address
/// Bit value
@@ -194,7 +202,7 @@ public void Action(string address, bool data)
try
{
- val = new[] { Convert.ToByte(data) };
+ val = new[] {Convert.ToByte(data)};
}
catch
{
@@ -208,7 +216,7 @@ public void Action(string address, bool data)
}
///
- /// Send a string value as data to specified address
+ /// Send a string value as data to specified address
///
/// KNX Address
/// String value
@@ -232,8 +240,7 @@ public void Action(string address, string data)
}
///
- ///
- /// Send an int value as data to specified address
+ /// Send an int value as data to specified address
///
/// KNX Address
/// Int value
@@ -244,12 +251,12 @@ public void Action(string address, int data)
if (data <= 255)
{
val[0] = 0x00;
- val[1] = (byte)data;
+ val[1] = (byte) data;
}
else if (data <= 65535)
{
- val[0] = (byte)data;
- val[1] = (byte)(data >> 8);
+ val[0] = (byte) data;
+ val[1] = (byte) (data >> 8);
}
else
{
@@ -264,46 +271,46 @@ public void Action(string address, int data)
}
///
- /// Send a byte value as data to specified address
+ /// Send a byte value as data to specified address
///
/// KNX Address
/// byte value
public void Action(string address, byte data)
{
- Action(address, new byte[] { 0x00, data });
+ Action(address, new byte[] {0x00, data});
}
///
- /// Send a byte array value as data to specified address
+ /// Send a byte array value as data to specified address
///
/// KNX Address
/// Byte array value
public void Action(string address, byte[] data)
{
- Log.Logger.Debug(ClassName, "Sending {0} to {1}.", data, address);
+ Logger.Debug(ClassName, "Sending {0} to {1}.", data, address);
_lockManager.PerformLockedOperation(() => KnxSender.Action(address, data));
- Log.Logger.Debug(ClassName, "Sent {0} to {1}.", data, address);
+ Logger.Debug(ClassName, "Sent {0} to {1}.", data, address);
}
// TODO: It would be good to make a type for address, to make sure not any random string can be passed in
///
- /// Send a request to KNX asking for specified address current status
+ /// Send a request to KNX asking for specified address current status
///
///
public void RequestStatus(string address)
{
- Log.Logger.Debug(ClassName, "Sending request status to {0}.", address);
+ Logger.Debug(ClassName, "Sending request status to {0}.", address);
_lockManager.PerformLockedOperation(() => KnxSender.RequestStatus(address));
- Log.Logger.Debug(ClassName, "Sent request status to {0}.", address);
+ Logger.Debug(ClassName, "Sent request status to {0}.", address);
}
///
- /// Convert a value received from KNX using datapoint translator, e.g.,
- /// get a temperature value in Celsius
+ /// Convert a value received from KNX using datapoint translator, e.g.,
+ /// get a temperature value in Celsius
///
/// Datapoint type, e.g.: 9.001
/// Data to convert
@@ -314,8 +321,8 @@ public object FromDataPoint(string type, string data)
}
///
- /// Convert a value received from KNX using datapoint translator, e.g.,
- /// get a temperature value in Celsius
+ /// Convert a value received from KNX using datapoint translator, e.g.,
+ /// get a temperature value in Celsius
///
/// Datapoint type, e.g.: 9.001
/// Data to convert
@@ -326,8 +333,8 @@ public object FromDataPoint(string type, byte[] data)
}
///
- /// Convert a value to send to KNX using datapoint translator, e.g.,
- /// get a temperature value in Celsius in a byte representation
+ /// Convert a value to send to KNX using datapoint translator, e.g.,
+ /// get a temperature value in Celsius in a byte representation
///
/// Datapoint type, e.g.: 9.001
/// Value to convert
@@ -338,8 +345,8 @@ public byte[] ToDataPoint(string type, string value)
}
///
- /// Convert a value to send to KNX using datapoint translator, e.g.,
- /// get a temperature value in Celsius in a byte representation
+ /// Convert a value to send to KNX using datapoint translator, e.g.,
+ /// get a temperature value in Celsius in a byte representation
///
/// Datapoint type, e.g.: 9.001
/// Value to convert
@@ -349,4 +356,4 @@ public byte[] ToDataPoint(string type, object value)
return DataPointTranslator.Instance.ToDataPoint(type, value);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/KNXLib/KnxConnectionConfiguration.cs b/src/KNXLib/KnxConnectionConfiguration.cs
index b95fd23..383a37b 100644
--- a/src/KNXLib/KnxConnectionConfiguration.cs
+++ b/src/KNXLib/KnxConnectionConfiguration.cs
@@ -1,5 +1,5 @@
-using System.Net;
-using System.Net.Sockets;
+using System;
+using System.Net;
using KNXLib.Exceptions;
namespace KNXLib
@@ -22,8 +22,9 @@ public KnxConnectionConfiguration(string host, int port)
{
IpAddress = Dns.GetHostEntry(host).AddressList[0];
}
- catch (SocketException)
+ catch (Exception)
{
+ throw new InvalidHostException(host);
}
}
@@ -41,4 +42,4 @@ public KnxConnectionConfiguration(string host, int port)
public IPEndPoint EndPoint { get; private set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/KNXLib/KnxConnectionRouting.cs b/src/KNXLib/KnxConnectionRouting.cs
index 4ef772e..37ddbc5 100644
--- a/src/KNXLib/KnxConnectionRouting.cs
+++ b/src/KNXLib/KnxConnectionRouting.cs
@@ -6,6 +6,11 @@
namespace KNXLib
{
+ ///
+ /// Class that controls a Routing KNX connection, a routing connection is UDP based and has no state.
+ /// This class will bind to a multicast address to listen for events and send actions and requests to
+ /// that same address
+ ///
public class KnxConnectionRouting : KnxConnection
{
private const string DefaultMulticastAddress = "224.0.23.12";
@@ -14,37 +19,60 @@ public class KnxConnectionRouting : KnxConnection
private readonly IPEndPoint _localEndpoint;
private readonly IList _udpClients = new List();
+ ///
+ /// Initializes a new KNX routing connection with default values. The default multicast address is
+ /// 224.0.23.12 and the default port is 3671. Make sure the local system allows UDP messages to this port
+ ///
public KnxConnectionRouting()
: this(DefaultMulticastAddress, DefaultMulticastPort)
{
}
+ ///
+ /// Initializes a new KNX routing connection with default address and provided port. The default multicast
+ /// address is 224.0.23.12. Make sure the local system allows UDP messages to the provided port
+ ///
+ /// UDP port to send/receive KNX messages
public KnxConnectionRouting(int port)
: this(DefaultMulticastAddress, port)
{
}
+ ///
+ /// Initializes a new KNX routing connection with provided address and default port. The default port is
+ /// 3671. Make sure the local system allows UDP messages to this port
+ ///
+ /// UDP multicast address to send/receive KNX messages
public KnxConnectionRouting(string host)
: this(host, DefaultMulticastPort)
{
}
+ ///
+ /// Initializes a new KNX routing connection with provided address and port. Make sure the local system
+ /// allows UDP messages to the provided port
+ ///
+ /// UDP multicast address to send/receive KNX messages
+ /// UDP port to send/receive KNX messages
public KnxConnectionRouting(string host, int port)
: base(host, port)
{
_localEndpoint = new IPEndPoint(IPAddress.Any, port);
}
+ ///
+ /// Start the connection
+ ///
public override void Connect()
{
try
{
- var ipv4Addresses =
+ IEnumerable ipv4Addresses =
Dns
- .GetHostAddresses(Dns.GetHostName())
- .Where(i => i.AddressFamily == AddressFamily.InterNetwork);
+ .GetHostAddresses(Dns.GetHostName())
+ .Where(i => i.AddressFamily == AddressFamily.InterNetwork);
- foreach (var localIp in ipv4Addresses)
+ foreach (IPAddress localIp in ipv4Addresses)
{
var client = new UdpClient(new IPEndPoint(localIp, _localEndpoint.Port));
_udpClients.Add(client);
@@ -66,10 +94,13 @@ public override void Connect()
Connected();
}
+ ///
+ /// Stop the connection
+ ///
public override void Disconnect()
{
KnxReceiver.Stop();
- foreach (var client in _udpClients)
+ foreach (UdpClient client in _udpClients)
{
client.DropMulticastGroup(ConnectionConfiguration.IpAddress);
client.Close();
diff --git a/src/KNXLib/KnxConnectionTunneling.cs b/src/KNXLib/KnxConnectionTunneling.cs
index 8f65edc..a778e49 100644
--- a/src/KNXLib/KnxConnectionTunneling.cs
+++ b/src/KNXLib/KnxConnectionTunneling.cs
@@ -5,6 +5,11 @@
namespace KNXLib
{
+ ///
+ /// Class that controls a Tunneling KNX connection, a tunneling connection is UDP based and has state.
+ /// This class will connect to the remote gateway provided and create an endpoint for the remote gateway
+ /// to connect back
+ ///
public class KnxConnectionTunneling : KnxConnection
{
private readonly IPEndPoint _localEndpoint;
@@ -12,6 +17,14 @@ public class KnxConnectionTunneling : KnxConnection
private UdpClient _udpClient;
private byte _sequenceNumber;
+ ///
+ /// Initializes a new KNX tunneling connection with provided values. Make sure the local system allows
+ /// UDP messages to the localIpAddress and localPort provided
+ ///
+ /// Remote gateway IP address
+ /// Remote gateway port
+ /// Local IP address to bind to
+ /// Local port to bind to
public KnxConnectionTunneling(string remoteIpAddress, int remotePort, string localIpAddress, int localPort)
: base(remoteIpAddress, remotePort)
{
@@ -19,7 +32,7 @@ public KnxConnectionTunneling(string remoteIpAddress, int remotePort, string loc
ChannelId = 0x00;
SequenceNumberLock = new object();
- _stateRequestTimer = new Timer(60000) { AutoReset = true }; // same time as ETS with group monitor open
+ _stateRequestTimer = new Timer(60000) {AutoReset = true}; // same time as ETS with group monitor open
_stateRequestTimer.Elapsed += StateRequest;
}
@@ -42,6 +55,9 @@ internal void ResetSequenceNumber()
_sequenceNumber = 0x00;
}
+ ///
+ /// Start the connection
+ ///
public override void Connect()
{
try
@@ -61,7 +77,7 @@ public override void Connect()
_udpClient = new UdpClient(_localEndpoint)
{
- Client = { DontFragment = true, SendBufferSize = 0 }
+ Client = {DontFragment = true, SendBufferSize = 0}
};
}
catch (SocketException ex)
@@ -76,8 +92,8 @@ public override void Connect()
}
else
{
- ((KnxReceiverTunneling)KnxReceiver).SetClient(_udpClient);
- ((KnxSenderTunneling)KnxSender).SetClient(_udpClient);
+ ((KnxReceiverTunneling) KnxReceiver).SetClient(_udpClient);
+ ((KnxSenderTunneling) KnxSender).SetClient(_udpClient);
}
KnxReceiver.Start();
@@ -92,6 +108,9 @@ public override void Connect()
}
}
+ ///
+ /// Stop the connection
+ ///
public override void Disconnect()
{
try
@@ -154,22 +173,22 @@ private void ConnectRequest()
datagram[09] = _localEndpoint.Address.GetAddressBytes()[1];
datagram[10] = _localEndpoint.Address.GetAddressBytes()[2];
datagram[11] = _localEndpoint.Address.GetAddressBytes()[3];
- datagram[12] = (byte)(_localEndpoint.Port >> 8);
- datagram[13] = (byte)_localEndpoint.Port;
+ datagram[12] = (byte) (_localEndpoint.Port >> 8);
+ datagram[13] = (byte) _localEndpoint.Port;
datagram[14] = 0x08;
datagram[15] = 0x01;
datagram[16] = _localEndpoint.Address.GetAddressBytes()[0];
datagram[17] = _localEndpoint.Address.GetAddressBytes()[1];
datagram[18] = _localEndpoint.Address.GetAddressBytes()[2];
datagram[19] = _localEndpoint.Address.GetAddressBytes()[3];
- datagram[20] = (byte)(_localEndpoint.Port >> 8);
- datagram[21] = (byte)_localEndpoint.Port;
+ datagram[20] = (byte) (_localEndpoint.Port >> 8);
+ datagram[21] = (byte) _localEndpoint.Port;
datagram[22] = 0x04;
datagram[23] = 0x04;
datagram[24] = 0x02;
datagram[25] = 0x00;
- ((KnxSenderTunneling)KnxSender).SendDataSingle(datagram);
+ ((KnxSenderTunneling) KnxSender).SendDataSingle(datagram);
}
private void StateRequest(object sender, ElapsedEventArgs e)
@@ -191,8 +210,8 @@ private void StateRequest(object sender, ElapsedEventArgs e)
datagram[11] = _localEndpoint.Address.GetAddressBytes()[1];
datagram[12] = _localEndpoint.Address.GetAddressBytes()[2];
datagram[13] = _localEndpoint.Address.GetAddressBytes()[3];
- datagram[14] = (byte)(_localEndpoint.Port >> 8);
- datagram[15] = (byte)_localEndpoint.Port;
+ datagram[14] = (byte) (_localEndpoint.Port >> 8);
+ datagram[15] = (byte) _localEndpoint.Port;
try
{
@@ -223,8 +242,8 @@ private void DisconnectRequest()
datagram[11] = _localEndpoint.Address.GetAddressBytes()[1];
datagram[12] = _localEndpoint.Address.GetAddressBytes()[2];
datagram[13] = _localEndpoint.Address.GetAddressBytes()[3];
- datagram[14] = (byte)(_localEndpoint.Port >> 8);
- datagram[15] = (byte)_localEndpoint.Port;
+ datagram[14] = (byte) (_localEndpoint.Port >> 8);
+ datagram[15] = (byte) _localEndpoint.Port;
KnxSender.SendData(datagram);
}
diff --git a/src/KNXLib/Properties/AssemblyInfo.cs b/src/KNXLib/Properties/AssemblyInfo.cs
index 867b01c..ddcdcb0 100644
--- a/src/KNXLib/Properties/AssemblyInfo.cs
+++ b/src/KNXLib/Properties/AssemblyInfo.cs
@@ -36,6 +36,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.1.1")]
-[assembly: AssemblyFileVersion("1.1.1.0")]
-[assembly: AssemblyInformationalVersion("1.1.1")]
+[assembly: AssemblyVersion("1.1.2")]
+[assembly: AssemblyFileVersion("1.1.2.0")]
+[assembly: AssemblyInformationalVersion("1.1.2")]
diff --git a/tests/KNXLibTests/KNXLibTests.csproj b/tests/KNXLibTests/KNXLibTests.csproj
index d634215..2dd9809 100644
--- a/tests/KNXLibTests/KNXLibTests.csproj
+++ b/tests/KNXLibTests/KNXLibTests.csproj
@@ -1,110 +1,110 @@
-
-
-
- Debug
- AnyCPU
- {90D08CB2-37FE-450A-82C0-063E0B4802EC}
- Library
- Properties
- KNXLibTests
- KNXLibTests
- v4.5
- 512
- {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 10.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
- $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
- False
- UnitTest
-
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- false
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- false
-
-
-
- ..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll
- True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {cd1911ad-1967-40cb-a1c3-ec2fa562872b}
- KNXLib
-
-
-
-
-
-
-
-
-
- False
-
-
- False
-
-
- False
-
-
- False
-
-
-
-
-
-
-
+
+
+
+ Debug
+ AnyCPU
+ {90D08CB2-37FE-450A-82C0-063E0B4802EC}
+ Library
+ Properties
+ KNXLibTests
+ KNXLibTests
+ v4.5
+ 512
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 10.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
+ False
+ UnitTest
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ false
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ false
+
+
+
+ ..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {cd1911ad-1967-40cb-a1c3-ec2fa562872b}
+ KNXLib
+
+
+
+
+
+
+
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/KNXLibTests/Unit/DataPoint/Temperature.cs b/tests/KNXLibTests/Unit/DataPoint/DataPoint2ByteFloatTemperature.cs
similarity index 71%
rename from tests/KNXLibTests/Unit/DataPoint/Temperature.cs
rename to tests/KNXLibTests/Unit/DataPoint/DataPoint2ByteFloatTemperature.cs
index b45d6e7..afe227f 100644
--- a/tests/KNXLibTests/Unit/DataPoint/Temperature.cs
+++ b/tests/KNXLibTests/Unit/DataPoint/DataPoint2ByteFloatTemperature.cs
@@ -4,7 +4,7 @@
namespace KNXLibTests.Unit.DataPoint
{
[TestFixture]
- internal class Temperature
+ internal class DataPoint2ByteFloatTemperature
{
[TestFixtureSetUp]
public void SetUp()
@@ -16,38 +16,43 @@ public void TearDown()
{
}
- [Category("KNXLib.Unit.DataPoint.9.xxx"), Test]
- public void DataPointTemperatureTest()
+ [Category("KNXLib.Unit.DataPoint.2ByteFloat"), Test]
+ public void DataPoint2ByteFloatTemperatureTest()
{
var dptType = "9.001";
-
+
+ var temp30N = -30f;
+ var temp30NBytes = new byte[] { 0x8A, 0x24 };
var temp23Float = 23.0f;
- var temp23Bytes = new byte[] { 12, 126 };
+ var temp23Bytes = new byte[] { 0x0C, 0x7E };
var temp19Float = 19.5f;
- var temp19Bytes = new byte[] { 11, 207 };
+ var temp19Bytes = new byte[] { 0x07, 0x9E };
var temp5Float = 5.8f;
- var temp5Bytes = new byte[] { 9, 34 };
+ var temp5Bytes = new byte[] { 0x02, 0x44 };
var tempMinus6Float = -6.5f;
- var tempMinus6Bytes = new byte[] { 142, 187 };
+ var tempMinus6Bytes = new byte[] { 0x85, 0x76 };
var temp36Float = 36.7f;
- var temp36Bytes = new byte[] { 15, 43 };
+ var temp36Bytes = new byte[] { 0x0F, 0x2B };
var temp0Float = 0f;
- var temp0Bytes = new byte[] { 8, 0 };
+ var temp0Bytes = new byte[] { 0x00, 0x00 };
+ Assert.AreEqual(temp30N, DataPointTranslator.Instance.FromDataPoint(dptType, temp30NBytes));
Assert.AreEqual(temp23Float, DataPointTranslator.Instance.FromDataPoint(dptType, temp23Bytes));
Assert.AreEqual(temp19Float, DataPointTranslator.Instance.FromDataPoint(dptType, temp19Bytes));
Assert.AreEqual(temp5Float, DataPointTranslator.Instance.FromDataPoint(dptType, temp5Bytes));
Assert.AreEqual(tempMinus6Float, DataPointTranslator.Instance.FromDataPoint(dptType, tempMinus6Bytes));
Assert.AreEqual(temp36Float, DataPointTranslator.Instance.FromDataPoint(dptType, temp36Bytes));
Assert.AreEqual(temp0Float, DataPointTranslator.Instance.FromDataPoint(dptType, temp0Bytes));
-
+
+ temp30NBytes = new byte[] { 00, temp30NBytes[0], temp30NBytes[1] };
temp23Bytes = new byte[] { 00, temp23Bytes[0], temp23Bytes[1] };
temp19Bytes = new byte[] { 00, temp19Bytes[0], temp19Bytes[1] };
temp5Bytes = new byte[] { 00, temp5Bytes[0], temp5Bytes[1] };
tempMinus6Bytes = new byte[] { 00, tempMinus6Bytes[0], tempMinus6Bytes[1] };
temp36Bytes = new byte[] { 00, temp36Bytes[0], temp36Bytes[1] };
temp0Bytes = new byte[] { 00, temp0Bytes[0], temp0Bytes[1] };
-
+
+ Assert.AreEqual(temp30NBytes, DataPointTranslator.Instance.ToDataPoint(dptType, temp30N));
Assert.AreEqual(temp23Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, temp23Float));
Assert.AreEqual(temp19Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, temp19Float));
Assert.AreEqual(temp5Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, temp5Float));
diff --git a/tests/KNXLibTests/Unit/DataPoint/ThreeBitWithControl.cs b/tests/KNXLibTests/Unit/DataPoint/DataPoint3BitControl.cs
similarity index 90%
rename from tests/KNXLibTests/Unit/DataPoint/ThreeBitWithControl.cs
rename to tests/KNXLibTests/Unit/DataPoint/DataPoint3BitControl.cs
index 6c1af1b..08a7fa8 100644
--- a/tests/KNXLibTests/Unit/DataPoint/ThreeBitWithControl.cs
+++ b/tests/KNXLibTests/Unit/DataPoint/DataPoint3BitControl.cs
@@ -1,77 +1,77 @@
-using KNXLib.DPT;
-using NUnit.Framework;
-
-namespace KNXLibTests.Unit.DataPoint
-{
- [TestFixture]
- internal class ThreeBitWithControl
- {
- [TestFixtureSetUp]
- public void SetUp()
- {
- }
-
- [TestFixtureTearDown]
- public void TearDown()
- {
- }
-
- [Category("KNXLib.Unit.DataPoint.3.xxx"), Test]
- public void DataPointControlDimmingTest()
- {
- var dptType = "3.007";
-
- var incr4 = 4;
- var incr4Bytes = new byte[] { 0x0C };
- var incr1 = 1;
- var incr1Bytes = new byte[] { 0x09 };
- var stop = 0;
- var stopBytes = new byte[] { 0x00 };
- var decr3 = -3;
- var decr3Bytes = new byte[] { 0x03 };
- var decr7 = -7;
- var decr7Bytes = new byte[] { 0x07 };
-
- Assert.AreEqual(incr4, DataPointTranslator.Instance.FromDataPoint(dptType, incr4Bytes));
- Assert.AreEqual(incr1, DataPointTranslator.Instance.FromDataPoint(dptType, incr1Bytes));
- Assert.AreEqual(stop, DataPointTranslator.Instance.FromDataPoint(dptType, stopBytes));
- Assert.AreEqual(decr3, DataPointTranslator.Instance.FromDataPoint(dptType, decr3Bytes));
- Assert.AreEqual(decr7, DataPointTranslator.Instance.FromDataPoint(dptType, decr7Bytes));
-
- Assert.AreEqual(incr4Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, incr4));
- Assert.AreEqual(incr1Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, incr1));
- Assert.AreEqual(stopBytes, DataPointTranslator.Instance.ToDataPoint(dptType, stop));
- Assert.AreEqual(decr3Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, decr3));
- Assert.AreEqual(decr7Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, decr7));
- }
-
- [Category("KNXLib.Unit.DataPoint.3.xxx"), Test]
- public void DataPointControlBlindsTest()
- {
- var dptType = "3.008";
-
- var incr7 = 7;
- var incr7Bytes = new byte[] { 0x0F };
- var incr2 = 2;
- var incr2Bytes = new byte[] { 0x0A };
- var stop = 0;
- var stopBytes = new byte[] { 0x00 };
- var decr5 = -5;
- var decr5Bytes = new byte[] { 0x05 };
- var decr6 = -6;
- var decr6Bytes = new byte[] { 0x06 };
-
- Assert.AreEqual(incr7, DataPointTranslator.Instance.FromDataPoint(dptType, incr7Bytes));
- Assert.AreEqual(incr2, DataPointTranslator.Instance.FromDataPoint(dptType, incr2Bytes));
- Assert.AreEqual(stop, DataPointTranslator.Instance.FromDataPoint(dptType, stopBytes));
- Assert.AreEqual(decr5, DataPointTranslator.Instance.FromDataPoint(dptType, decr5Bytes));
- Assert.AreEqual(decr6, DataPointTranslator.Instance.FromDataPoint(dptType, decr6Bytes));
-
- Assert.AreEqual(incr7Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, incr7));
- Assert.AreEqual(incr2Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, incr2));
- Assert.AreEqual(stopBytes, DataPointTranslator.Instance.ToDataPoint(dptType, stop));
- Assert.AreEqual(decr5Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, decr5));
- Assert.AreEqual(decr6Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, decr6));
- }
- }
+using KNXLib.DPT;
+using NUnit.Framework;
+
+namespace KNXLibTests.Unit.DataPoint
+{
+ [TestFixture]
+ internal class DataPoint3BitControl
+ {
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ }
+
+ [Category("KNXLib.Unit.DataPoint.3BitControl"), Test]
+ public void DataPoint3BitControlDimmingTest()
+ {
+ var dptType = "3.007";
+
+ var incr4 = 4;
+ var incr4Bytes = new byte[] { 0x0C };
+ var incr1 = 1;
+ var incr1Bytes = new byte[] { 0x09 };
+ var stop = 0;
+ var stopBytes = new byte[] { 0x00 };
+ var decr3 = -3;
+ var decr3Bytes = new byte[] { 0x03 };
+ var decr7 = -7;
+ var decr7Bytes = new byte[] { 0x07 };
+
+ Assert.AreEqual(incr4, DataPointTranslator.Instance.FromDataPoint(dptType, incr4Bytes));
+ Assert.AreEqual(incr1, DataPointTranslator.Instance.FromDataPoint(dptType, incr1Bytes));
+ Assert.AreEqual(stop, DataPointTranslator.Instance.FromDataPoint(dptType, stopBytes));
+ Assert.AreEqual(decr3, DataPointTranslator.Instance.FromDataPoint(dptType, decr3Bytes));
+ Assert.AreEqual(decr7, DataPointTranslator.Instance.FromDataPoint(dptType, decr7Bytes));
+
+ Assert.AreEqual(incr4Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, incr4));
+ Assert.AreEqual(incr1Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, incr1));
+ Assert.AreEqual(stopBytes, DataPointTranslator.Instance.ToDataPoint(dptType, stop));
+ Assert.AreEqual(decr3Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, decr3));
+ Assert.AreEqual(decr7Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, decr7));
+ }
+
+ [Category("KNXLib.Unit.DataPoint.3BitControl"), Test]
+ public void DataPoint3BitControlBlindsTest()
+ {
+ var dptType = "3.008";
+
+ var incr7 = 7;
+ var incr7Bytes = new byte[] { 0x0F };
+ var incr2 = 2;
+ var incr2Bytes = new byte[] { 0x0A };
+ var stop = 0;
+ var stopBytes = new byte[] { 0x00 };
+ var decr5 = -5;
+ var decr5Bytes = new byte[] { 0x05 };
+ var decr6 = -6;
+ var decr6Bytes = new byte[] { 0x06 };
+
+ Assert.AreEqual(incr7, DataPointTranslator.Instance.FromDataPoint(dptType, incr7Bytes));
+ Assert.AreEqual(incr2, DataPointTranslator.Instance.FromDataPoint(dptType, incr2Bytes));
+ Assert.AreEqual(stop, DataPointTranslator.Instance.FromDataPoint(dptType, stopBytes));
+ Assert.AreEqual(decr5, DataPointTranslator.Instance.FromDataPoint(dptType, decr5Bytes));
+ Assert.AreEqual(decr6, DataPointTranslator.Instance.FromDataPoint(dptType, decr6Bytes));
+
+ Assert.AreEqual(incr7Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, incr7));
+ Assert.AreEqual(incr2Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, incr2));
+ Assert.AreEqual(stopBytes, DataPointTranslator.Instance.ToDataPoint(dptType, stop));
+ Assert.AreEqual(decr5Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, decr5));
+ Assert.AreEqual(decr6Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, decr6));
+ }
+ }
}
\ No newline at end of file
diff --git a/tests/KNXLibTests/Unit/DataPoint/EightBitWithoutSignNonScaledValue1UCount.cs b/tests/KNXLibTests/Unit/DataPoint/DataPoint8BitNoSignNonScaledValue1UCount.cs
similarity index 88%
rename from tests/KNXLibTests/Unit/DataPoint/EightBitWithoutSignNonScaledValue1UCount.cs
rename to tests/KNXLibTests/Unit/DataPoint/DataPoint8BitNoSignNonScaledValue1UCount.cs
index 97dc27f..3b1b077 100644
--- a/tests/KNXLibTests/Unit/DataPoint/EightBitWithoutSignNonScaledValue1UCount.cs
+++ b/tests/KNXLibTests/Unit/DataPoint/DataPoint8BitNoSignNonScaledValue1UCount.cs
@@ -1,48 +1,48 @@
-using KNXLib.DPT;
-using NUnit.Framework;
-
-namespace KNXLibTests.Unit.DataPoint
-{
- [TestFixture]
- internal class EightBitWithoutSignNonScaledValue1UCount
- {
- [TestFixtureSetUp]
- public void SetUp()
- {
- }
-
- [TestFixtureTearDown]
- public void TearDown()
- {
- }
-
- [Category("KNXLib.Unit.DataPoint.5.xxx"), Test]
- public void DataPointNonScaledValue1UCountTest()
- {
- var dptType = "5.010";
-
- var count0 = 0;
- var count0Bytes = new byte[] { 0x00 };
- var count97 = 97;
- var count97Bytes = new byte[] { 0x61 };
- var count128 = 128;
- var count128Bytes = new byte[] { 0x80 };
- var count199 = 199;
- var count199Bytes = new byte[] { 0xC7 };
- var count255 = 255;
- var count255Bytes = new byte[] { 0xFF };
-
- Assert.AreEqual(count0, DataPointTranslator.Instance.FromDataPoint(dptType, count0Bytes));
- Assert.AreEqual(count97, DataPointTranslator.Instance.FromDataPoint(dptType, count97Bytes));
- Assert.AreEqual(count128, DataPointTranslator.Instance.FromDataPoint(dptType, count128Bytes));
- Assert.AreEqual(count199, DataPointTranslator.Instance.FromDataPoint(dptType, count199Bytes));
- Assert.AreEqual(count255, DataPointTranslator.Instance.FromDataPoint(dptType, count255Bytes));
-
- Assert.AreEqual(count0Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count0));
- Assert.AreEqual(count97Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count97));
- Assert.AreEqual(count128Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count128));
- Assert.AreEqual(count199Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count199));
- Assert.AreEqual(count255Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count255));
- }
- }
+using KNXLib.DPT;
+using NUnit.Framework;
+
+namespace KNXLibTests.Unit.DataPoint
+{
+ [TestFixture]
+ internal class DataPoint8BitNoSignNonScaledValue1UCount
+ {
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ }
+
+ [Category("KNXLib.Unit.DataPoint.8BitNoSign"), Test]
+ public void DataPoint8BitNoSignNonScaledValue1UCountTest()
+ {
+ var dptType = "5.010";
+
+ var count0 = 0;
+ var count0Bytes = new byte[] { 0x00 };
+ var count97 = 97;
+ var count97Bytes = new byte[] { 0x61 };
+ var count128 = 128;
+ var count128Bytes = new byte[] { 0x80 };
+ var count199 = 199;
+ var count199Bytes = new byte[] { 0xC7 };
+ var count255 = 255;
+ var count255Bytes = new byte[] { 0xFF };
+
+ Assert.AreEqual(count0, DataPointTranslator.Instance.FromDataPoint(dptType, count0Bytes));
+ Assert.AreEqual(count97, DataPointTranslator.Instance.FromDataPoint(dptType, count97Bytes));
+ Assert.AreEqual(count128, DataPointTranslator.Instance.FromDataPoint(dptType, count128Bytes));
+ Assert.AreEqual(count199, DataPointTranslator.Instance.FromDataPoint(dptType, count199Bytes));
+ Assert.AreEqual(count255, DataPointTranslator.Instance.FromDataPoint(dptType, count255Bytes));
+
+ Assert.AreEqual(count0Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count0));
+ Assert.AreEqual(count97Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count97));
+ Assert.AreEqual(count128Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count128));
+ Assert.AreEqual(count199Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count199));
+ Assert.AreEqual(count255Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count255));
+ }
+ }
}
\ No newline at end of file
diff --git a/tests/KNXLibTests/Unit/DataPoint/EightBitWithoutSignScaledAngle.cs b/tests/KNXLibTests/Unit/DataPoint/DataPoint8BitNoSignScaledAngle.cs
similarity index 89%
rename from tests/KNXLibTests/Unit/DataPoint/EightBitWithoutSignScaledAngle.cs
rename to tests/KNXLibTests/Unit/DataPoint/DataPoint8BitNoSignScaledAngle.cs
index 07f8342..110f978 100644
--- a/tests/KNXLibTests/Unit/DataPoint/EightBitWithoutSignScaledAngle.cs
+++ b/tests/KNXLibTests/Unit/DataPoint/DataPoint8BitNoSignScaledAngle.cs
@@ -1,48 +1,48 @@
-using KNXLib.DPT;
-using NUnit.Framework;
-
-namespace KNXLibTests.Unit.DataPoint
-{
- [TestFixture]
- internal class EightBitWithoutSignScaledAngle
- {
- [TestFixtureSetUp]
- public void SetUp()
- {
- }
-
- [TestFixtureTearDown]
- public void TearDown()
- {
- }
-
- [Category("KNXLib.Unit.DataPoint.5.xxx"), Test]
- public void DataPointScaledAngleTest()
- {
- var dptType = "5.003";
-
- var angle0 = 0;
- var angle0Bytes = new byte[] { 0x00 };
- var angle72 = 72;
- var angle72Bytes = new byte[] { 0x33 };
- var angle120 = 120;
- var angle120Bytes = new byte[] { 0x55 };
- var angle288 = 288;
- var angle288Bytes = new byte[] { 0xCC };
- var angle360 = 360;
- var angle360Bytes = new byte[] { 0xFF };
-
- Assert.AreEqual(angle0, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, angle0Bytes)));
- Assert.AreEqual(angle72, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, angle72Bytes)));
- Assert.AreEqual(angle120, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, angle120Bytes)));
- Assert.AreEqual(angle288, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, angle288Bytes)));
- Assert.AreEqual(angle360, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, angle360Bytes)));
-
- Assert.AreEqual(angle0Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, angle0));
- Assert.AreEqual(angle72Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, angle72));
- Assert.AreEqual(angle120Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, angle120));
- Assert.AreEqual(angle288Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, angle288));
- Assert.AreEqual(angle360Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, angle360));
- }
- }
+using KNXLib.DPT;
+using NUnit.Framework;
+
+namespace KNXLibTests.Unit.DataPoint
+{
+ [TestFixture]
+ internal class DataPoint8BitNoSignScaledAngle
+ {
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ }
+
+ [Category("KNXLib.Unit.DataPoint.8BitNoSign"), Test]
+ public void DataPoint8BitNoSignScaledAngleTest()
+ {
+ var dptType = "5.003";
+
+ var angle0 = 0;
+ var angle0Bytes = new byte[] { 0x00 };
+ var angle72 = 72;
+ var angle72Bytes = new byte[] { 0x33 };
+ var angle120 = 120;
+ var angle120Bytes = new byte[] { 0x55 };
+ var angle288 = 288;
+ var angle288Bytes = new byte[] { 0xCC };
+ var angle360 = 360;
+ var angle360Bytes = new byte[] { 0xFF };
+
+ Assert.AreEqual(angle0, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, angle0Bytes)));
+ Assert.AreEqual(angle72, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, angle72Bytes)));
+ Assert.AreEqual(angle120, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, angle120Bytes)));
+ Assert.AreEqual(angle288, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, angle288Bytes)));
+ Assert.AreEqual(angle360, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, angle360Bytes)));
+
+ Assert.AreEqual(angle0Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, angle0));
+ Assert.AreEqual(angle72Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, angle72));
+ Assert.AreEqual(angle120Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, angle120));
+ Assert.AreEqual(angle288Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, angle288));
+ Assert.AreEqual(angle360Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, angle360));
+ }
+ }
}
\ No newline at end of file
diff --git a/tests/KNXLibTests/Unit/DataPoint/EightBitWithoutSignScaledPercentU8.cs b/tests/KNXLibTests/Unit/DataPoint/DataPoint8BitNoSignScaledPercentU8.cs
similarity index 88%
rename from tests/KNXLibTests/Unit/DataPoint/EightBitWithoutSignScaledPercentU8.cs
rename to tests/KNXLibTests/Unit/DataPoint/DataPoint8BitNoSignScaledPercentU8.cs
index 7da9d4f..83549be 100644
--- a/tests/KNXLibTests/Unit/DataPoint/EightBitWithoutSignScaledPercentU8.cs
+++ b/tests/KNXLibTests/Unit/DataPoint/DataPoint8BitNoSignScaledPercentU8.cs
@@ -1,48 +1,48 @@
-using KNXLib.DPT;
-using NUnit.Framework;
-
-namespace KNXLibTests.Unit.DataPoint
-{
- [TestFixture]
- internal class EightBitWithoutSignScaledPercentU8
- {
- [TestFixtureSetUp]
- public void SetUp()
- {
- }
-
- [TestFixtureTearDown]
- public void TearDown()
- {
- }
-
- [Category("KNXLib.Unit.DataPoint.5.xxx"), Test]
- public void DataPointScaledPercentU8Test()
- {
- var dptType = "5.004";
-
- var perc0 = 0;
- var perc0Bytes = new byte[] { 0x00 };
- var perc97 = 97;
- var perc97Bytes = new byte[] { 0x61 };
- var perc128 = 128;
- var perc128Bytes = new byte[] { 0x80 };
- var perc199 = 199;
- var perc199Bytes = new byte[] { 0xC7 };
- var perc255 = 255;
- var perc255Bytes = new byte[] { 0xFF };
-
- Assert.AreEqual(perc0, DataPointTranslator.Instance.FromDataPoint(dptType, perc0Bytes));
- Assert.AreEqual(perc97, DataPointTranslator.Instance.FromDataPoint(dptType, perc97Bytes));
- Assert.AreEqual(perc128, DataPointTranslator.Instance.FromDataPoint(dptType, perc128Bytes));
- Assert.AreEqual(perc199, DataPointTranslator.Instance.FromDataPoint(dptType, perc199Bytes));
- Assert.AreEqual(perc255, DataPointTranslator.Instance.FromDataPoint(dptType, perc255Bytes));
-
- Assert.AreEqual(perc0Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc0));
- Assert.AreEqual(perc97Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc97));
- Assert.AreEqual(perc128Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc128));
- Assert.AreEqual(perc199Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc199));
- Assert.AreEqual(perc255Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc255));
- }
- }
+using KNXLib.DPT;
+using NUnit.Framework;
+
+namespace KNXLibTests.Unit.DataPoint
+{
+ [TestFixture]
+ internal class DataPoint8BitNoSignScaledPercentU8
+ {
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ }
+
+ [Category("KNXLib.Unit.DataPoint.8BitNoSign"), Test]
+ public void DataPoint8BitNoSignScaledPercentU8Test()
+ {
+ var dptType = "5.004";
+
+ var perc0 = 0;
+ var perc0Bytes = new byte[] { 0x00 };
+ var perc97 = 97;
+ var perc97Bytes = new byte[] { 0x61 };
+ var perc128 = 128;
+ var perc128Bytes = new byte[] { 0x80 };
+ var perc199 = 199;
+ var perc199Bytes = new byte[] { 0xC7 };
+ var perc255 = 255;
+ var perc255Bytes = new byte[] { 0xFF };
+
+ Assert.AreEqual(perc0, DataPointTranslator.Instance.FromDataPoint(dptType, perc0Bytes));
+ Assert.AreEqual(perc97, DataPointTranslator.Instance.FromDataPoint(dptType, perc97Bytes));
+ Assert.AreEqual(perc128, DataPointTranslator.Instance.FromDataPoint(dptType, perc128Bytes));
+ Assert.AreEqual(perc199, DataPointTranslator.Instance.FromDataPoint(dptType, perc199Bytes));
+ Assert.AreEqual(perc255, DataPointTranslator.Instance.FromDataPoint(dptType, perc255Bytes));
+
+ Assert.AreEqual(perc0Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc0));
+ Assert.AreEqual(perc97Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc97));
+ Assert.AreEqual(perc128Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc128));
+ Assert.AreEqual(perc199Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc199));
+ Assert.AreEqual(perc255Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc255));
+ }
+ }
}
\ No newline at end of file
diff --git a/tests/KNXLibTests/Unit/DataPoint/EightBitWithoutSignScaledScaling.cs b/tests/KNXLibTests/Unit/DataPoint/DataPoint8BitNoSignScaledScaling.cs
similarity index 89%
rename from tests/KNXLibTests/Unit/DataPoint/EightBitWithoutSignScaledScaling.cs
rename to tests/KNXLibTests/Unit/DataPoint/DataPoint8BitNoSignScaledScaling.cs
index 910e2b3..eac6889 100644
--- a/tests/KNXLibTests/Unit/DataPoint/EightBitWithoutSignScaledScaling.cs
+++ b/tests/KNXLibTests/Unit/DataPoint/DataPoint8BitNoSignScaledScaling.cs
@@ -1,48 +1,48 @@
-using KNXLib.DPT;
-using NUnit.Framework;
-
-namespace KNXLibTests.Unit.DataPoint
-{
- [TestFixture]
- internal class EightBitWithoutSignScaledScaling
- {
- [TestFixtureSetUp]
- public void SetUp()
- {
- }
-
- [TestFixtureTearDown]
- public void TearDown()
- {
- }
-
- [Category("KNXLib.Unit.DataPoint.5.xxx"), Test]
- public void DataPointScaledScalingTest()
- {
- var dptType = "5.001";
-
- var scale0 = 0;
- var scale0Bytes = new byte[] { 0x00 };
- var scale20 = 20;
- var scale20Bytes = new byte[] { 0x33 };
- var scale60 = 60;
- var scale60Bytes = new byte[] { 0x99 };
- var scale80 = 80;
- var scale80Bytes = new byte[] { 0xCC };
- var scale100 = 100;
- var scale100Bytes = new byte[] { 0xFF };
-
- Assert.AreEqual(scale0, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, scale0Bytes)));
- Assert.AreEqual(scale20, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, scale20Bytes)));
- Assert.AreEqual(scale60, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, scale60Bytes)));
- Assert.AreEqual(scale80, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, scale80Bytes)));
- Assert.AreEqual(scale100, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, scale100Bytes)));
-
- Assert.AreEqual(scale0Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, scale0));
- Assert.AreEqual(scale20Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, scale20));
- Assert.AreEqual(scale60Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, scale60));
- Assert.AreEqual(scale80Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, scale80));
- Assert.AreEqual(scale100Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, scale100));
- }
- }
+using KNXLib.DPT;
+using NUnit.Framework;
+
+namespace KNXLibTests.Unit.DataPoint
+{
+ [TestFixture]
+ internal class DataPoint8BitNoSignScaledScaling
+ {
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ }
+
+ [Category("KNXLib.Unit.DataPoint.8BitNoSign"), Test]
+ public void DataPoint8BitNoSignScaledScalingTest()
+ {
+ var dptType = "5.001";
+
+ var scale0 = 0;
+ var scale0Bytes = new byte[] { 0x00 };
+ var scale20 = 20;
+ var scale20Bytes = new byte[] { 0x33 };
+ var scale60 = 60;
+ var scale60Bytes = new byte[] { 0x99 };
+ var scale80 = 80;
+ var scale80Bytes = new byte[] { 0xCC };
+ var scale100 = 100;
+ var scale100Bytes = new byte[] { 0xFF };
+
+ Assert.AreEqual(scale0, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, scale0Bytes)));
+ Assert.AreEqual(scale20, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, scale20Bytes)));
+ Assert.AreEqual(scale60, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, scale60Bytes)));
+ Assert.AreEqual(scale80, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, scale80Bytes)));
+ Assert.AreEqual(scale100, ((int) (decimal) DataPointTranslator.Instance.FromDataPoint(dptType, scale100Bytes)));
+
+ Assert.AreEqual(scale0Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, scale0));
+ Assert.AreEqual(scale20Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, scale20));
+ Assert.AreEqual(scale60Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, scale60));
+ Assert.AreEqual(scale80Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, scale80));
+ Assert.AreEqual(scale100Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, scale100));
+ }
+ }
}
\ No newline at end of file
diff --git a/tests/KNXLibTests/Unit/DataPoint/DataPoint8BitSignRelativeValue.cs b/tests/KNXLibTests/Unit/DataPoint/DataPoint8BitSignRelativeValue.cs
new file mode 100644
index 0000000..dd372b6
--- /dev/null
+++ b/tests/KNXLibTests/Unit/DataPoint/DataPoint8BitSignRelativeValue.cs
@@ -0,0 +1,77 @@
+using KNXLib.DPT;
+using NUnit.Framework;
+
+namespace KNXLibTests.Unit.DataPoint
+{
+ [TestFixture]
+ internal class DataPoint8BitSignRelativeValue
+ {
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ }
+
+ [Category("KNXLib.Unit.DataPoint.8BitSign"), Test]
+ public void DataPoint8BitSignRelativeValuePercentTest()
+ {
+ var dptType = "6.001";
+
+ var perc128N = -128;
+ var perc128NBytes = new byte[] { 0x80 };
+ var perc1N = -1;
+ var perc1NBytes = new byte[] { 0xFF };
+ var perc0 = 0;
+ var perc0Bytes = new byte[] { 0x00 };
+ var perc55 = 55;
+ var perc55Bytes = new byte[] { 0x37 };
+ var perc127 = 127;
+ var perc127Bytes = new byte[] { 0x7F };
+
+ Assert.AreEqual(perc128N, DataPointTranslator.Instance.FromDataPoint(dptType, perc128NBytes));
+ Assert.AreEqual(perc1N, DataPointTranslator.Instance.FromDataPoint(dptType, perc1NBytes));
+ Assert.AreEqual(perc0, DataPointTranslator.Instance.FromDataPoint(dptType, perc0Bytes));
+ Assert.AreEqual(perc55, DataPointTranslator.Instance.FromDataPoint(dptType, perc55Bytes));
+ Assert.AreEqual(perc127, DataPointTranslator.Instance.FromDataPoint(dptType, perc127Bytes));
+
+ Assert.AreEqual(perc128NBytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc128N));
+ Assert.AreEqual(perc1NBytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc1N));
+ Assert.AreEqual(perc0Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc0));
+ Assert.AreEqual(perc55Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc55));
+ Assert.AreEqual(perc127Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc127));
+ }
+
+ [Category("KNXLib.Unit.DataPoint.8BitSign"), Test]
+ public void DataPoint8BitSignRelativeValueCountTest()
+ {
+ var dptType = "6.010";
+
+ var count128N = -128;
+ var count128NBytes = new byte[] { 0x80 };
+ var count1N = -1;
+ var count1NBytes = new byte[] { 0xFF };
+ var count0 = 0;
+ var count0Bytes = new byte[] { 0x00 };
+ var count55 = 55;
+ var count55Bytes = new byte[] { 0x37 };
+ var count127 = 127;
+ var count127Bytes = new byte[] { 0x7F };
+
+ Assert.AreEqual(count128N, DataPointTranslator.Instance.FromDataPoint(dptType, count128NBytes));
+ Assert.AreEqual(count1N, DataPointTranslator.Instance.FromDataPoint(dptType, count1NBytes));
+ Assert.AreEqual(count0, DataPointTranslator.Instance.FromDataPoint(dptType, count0Bytes));
+ Assert.AreEqual(count55, DataPointTranslator.Instance.FromDataPoint(dptType, count55Bytes));
+ Assert.AreEqual(count127, DataPointTranslator.Instance.FromDataPoint(dptType, count127Bytes));
+
+ Assert.AreEqual(count128NBytes, DataPointTranslator.Instance.ToDataPoint(dptType, count128N));
+ Assert.AreEqual(count1NBytes, DataPointTranslator.Instance.ToDataPoint(dptType, count1N));
+ Assert.AreEqual(count0Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count0));
+ Assert.AreEqual(count55Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count55));
+ Assert.AreEqual(count127Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, count127));
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/KNXLibTests/Unit/DataPoint/EightBitWithSignRelativeValue.cs b/tests/KNXLibTests/Unit/DataPoint/EightBitWithSignRelativeValue.cs
deleted file mode 100644
index d91d247..0000000
--- a/tests/KNXLibTests/Unit/DataPoint/EightBitWithSignRelativeValue.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using KNXLib.DPT;
-using NUnit.Framework;
-
-namespace KNXLibTests.Unit.DataPoint
-{
- [TestFixture]
- internal class EightBitWithSignRelativeValue
- {
- [TestFixtureSetUp]
- public void SetUp()
- {
- }
-
- [TestFixtureTearDown]
- public void TearDown()
- {
- }
-
- [Category("KNXLib.Unit.DataPoint.6.xxx"), Test]
- public void DataPointRelativeValuePercent()
- {
- var dptType = "6.001";
-
- var perc128N = -128;
- var perc128NBytes = new byte[] { 0x80 };
- var perc1N = -1;
- var perc1NBytes = new byte[] { 0xFF };
- var perc0 = 0;
- var perc0Bytes = new byte[] { 0x00 };
- var perc55 = 55;
- var perc55Bytes = new byte[] { 0x37 };
- var perc127 = 127;
- var perc127Bytes = new byte[] { 0x7F };
-
- Assert.AreEqual(perc128N, DataPointTranslator.Instance.FromDataPoint(dptType, perc128NBytes));
- Assert.AreEqual(perc1N, DataPointTranslator.Instance.FromDataPoint(dptType, perc1NBytes));
- Assert.AreEqual(perc0, DataPointTranslator.Instance.FromDataPoint(dptType, perc0Bytes));
- Assert.AreEqual(perc55, DataPointTranslator.Instance.FromDataPoint(dptType, perc55Bytes));
- Assert.AreEqual(perc127, DataPointTranslator.Instance.FromDataPoint(dptType, perc127Bytes));
-
- Assert.AreEqual(perc128NBytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc128N));
- Assert.AreEqual(perc1NBytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc1N));
- Assert.AreEqual(perc0Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc0));
- Assert.AreEqual(perc55Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc55));
- Assert.AreEqual(perc127Bytes, DataPointTranslator.Instance.ToDataPoint(dptType, perc127));
- }
- }
-}
\ No newline at end of file