Permalink
Browse files

migration from MAXDebug to hacs started

  • Loading branch information...
1 parent d7ecbec commit 3a54c17aedb882606cdbbee1b4f5a9bd808bf051 @bietiekay committed Aug 25, 2012
Showing with 2,157 additions and 93 deletions.
  1. +0 −7 Code/MAXDebug/MAXDebug.userprefs
  2. +12 −0 Code/xs1-data-logging/ELVMAX/DiffSet/BatteryStatus.cs
  3. +12 −0 Code/xs1-data-logging/ELVMAX/DiffSet/DeviceDiffSet.cs
  4. +107 −0 Code/xs1-data-logging/ELVMAX/DiffSet/DiffHouse.cs
  5. +92 −0 Code/xs1-data-logging/ELVMAX/DiffSet/HeatingThermostatDiff.cs
  6. +80 −0 Code/xs1-data-logging/ELVMAX/DiffSet/ShutterContactDiff.cs
  7. +20 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Base64.cs
  8. +13 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/MAXMessageTypes.cs
  9. +41 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/MAX_Exception.cs
  10. +69 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/C_Message.cs
  11. +192 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/Devices/HeatingThermostat.cs
  12. +80 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/Devices/HeatingThermostatPlus.cs
  13. +14 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/Devices/IMAXDevice.cs
  14. +80 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/Devices/PushButton.cs
  15. +169 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/Devices/ShutterContact.cs
  16. +12 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/Devices/ShutterContactModes.cs
  17. +14 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/Devices/ThermostatModes.cs
  18. +80 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/Devices/UnknownDevice.cs
  19. +80 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/Devices/WallMountedThermostat.cs
  20. +88 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/H_Message.cs
  21. +10 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/IMAXMessage.cs
  22. +292 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/L_Message.cs
  23. +196 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/M_Message.cs
  24. +15 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/Metadata/DeviceTypes.cs
  25. +52 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/Metadata/House.cs
  26. +40 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/Messages/Metadata/Room.cs
  27. +47 −0 Code/xs1-data-logging/ELVMAX/ELVMAX_Data/TokenizeMessage.cs
  28. +34 −0 Code/xs1-data-logging/ELVMAX/MAXEncodeDecode.cs
  29. +145 −0 Code/xs1-data-logging/ELVMAX/MAXMonitoringThread.cs
  30. +38 −0 Code/xs1-data-logging/ELVMAX/Max_Threaded.cs
  31. +3 −3 Code/xs1-data-logging/LoggingThread.cs
  32. +0 −26 Code/xs1-data-logging/Max/MAXEncodeDecode.cs
  33. +0 −55 Code/xs1-data-logging/Max/MaxThread.cs
  34. +30 −2 Code/xs1-data-logging/xs1-data-logging.csproj
@@ -5,13 +5,6 @@
<Pad Id="ProjectPad">
<State expanded="True">
<Node name="MAXDebug" expanded="True">
- <Node name="ELVMAX_Data" expanded="True">
- <Node name="Messages" expanded="True">
- <Node name="Devices" expanded="True" />
- <Node name="Metadata" expanded="True" />
- </Node>
- </Node>
- <Node name="Notes" expanded="True" />
<Node name="MAXMonitoringThread.cs" selected="True" />
</Node>
</State>
@@ -0,0 +1,12 @@
+using System;
+
+namespace xs1_data_logging
+{
+ public enum BatteryStatus
+ {
+ unchanged,
+ ok,
+ lowbattery
+ }
+}
+
@@ -0,0 +1,12 @@
+using System;
+
+namespace xs1_data_logging
+{
+ public interface IDeviceDiffSet
+ {
+ DeviceTypes DeviceType { get;}
+ String DeviceName { get;}
+ Int32 RoomID { get;}
+ String RoomName { get;}
+ }
+}
@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+
+namespace xs1_data_logging
+{
+ public static class DiffHouse
+ {
+ /// <summary>
+ /// This method calculates the difference between house1 and house2 - whereas house1 is the old house2 the new one
+ /// </summary>
+ public static List<IDeviceDiffSet> CalculateDifferences(Dictionary<String,IMAXDevice> DevicesHouse1, Dictionary<String,IMAXDevice> DevicesHouse2)
+ {
+ List<IDeviceDiffSet> Differences = new List<IDeviceDiffSet>();
+
+ foreach(KeyValuePair<String,IMAXDevice> House1KVPair in DevicesHouse1)
+ {
+ // now we have a device from house 1 - we need to get that same device in house 2
+ if (DevicesHouse2.ContainsKey(House1KVPair.Key))
+ {
+ // we got it
+ IMAXDevice House2Device = DevicesHouse2[House1KVPair.Key];
+
+ if (House1KVPair.Value.Type == DeviceTypes.HeatingThermostat)
+ {
+ // HeatingThermostat
+ HeatingThermostatDiff Diff = null;
+
+ HeatingThermostat Device1 = (HeatingThermostat)House1KVPair.Value;
+ HeatingThermostat Device2 = (HeatingThermostat)House2Device;
+
+ if (Device1.LowBattery != Device2.LowBattery)
+ {
+ if (Diff == null)
+ Diff = new HeatingThermostatDiff(Device2.Name,Device2.AssociatedRoom.RoomID,Device2.AssociatedRoom.RoomName);
+
+ if (Device2.LowBattery)
+ Diff.LowBattery = BatteryStatus.lowbattery;
+ else
+ Diff.LowBattery = BatteryStatus.ok;
+ }
+
+ if (Device1.Mode != Device2.Mode)
+ {
+ if (Diff == null)
+ Diff = new HeatingThermostatDiff(Device2.Name,Device2.AssociatedRoom.RoomID,Device2.AssociatedRoom.RoomName);
+
+ Diff.Mode = Device2.Mode;
+ }
+
+ if (Device1.Temperature != Device2.Temperature)
+ {
+ if (Diff == null)
+ Diff = new HeatingThermostatDiff(Device2.Name,Device2.AssociatedRoom.RoomID,Device2.AssociatedRoom.RoomName);
+
+ Diff.Temperature = Device2.Temperature;
+ }
+
+ if (Diff != null)
+ {
+ Differences.Add(Diff);
+ }
+ }
+ else
+ if (House1KVPair.Value.Type == DeviceTypes.ShutterContact)
+ {
+ // ShutterContact
+ ShutterContactDiff Diff = null;
+
+ ShutterContact Device1 = (ShutterContact)House1KVPair.Value;
+ ShutterContact Device2 = (ShutterContact)House2Device;
+
+ if (Device1.LowBattery != Device2.LowBattery)
+ {
+ if (Diff == null)
+ Diff = new ShutterContactDiff(Device2.Name,Device2.AssociatedRoom.RoomID,Device2.AssociatedRoom.RoomName);
+
+ if (Device2.LowBattery)
+ Diff.LowBattery = BatteryStatus.lowbattery;
+ else
+ Diff.LowBattery = BatteryStatus.ok;
+
+ }
+
+ if (Device1.ShutterState != Device2.ShutterState)
+ {
+ if (Diff == null)
+ Diff = new ShutterContactDiff(Device2.Name,Device2.AssociatedRoom.RoomID,Device2.AssociatedRoom.RoomName);
+
+ Diff.ShutterState = Device2.ShutterState;
+ }
+
+ if (Diff != null)
+ {
+ Differences.Add(Diff);
+ }
+
+ }
+
+
+ }
+ }
+
+ return Differences;
+ }
+ }
+}
+
@@ -0,0 +1,92 @@
+using System;
+
+namespace xs1_data_logging
+{
+ public class HeatingThermostatDiff : IDeviceDiffSet
+ {
+ private DeviceTypes _DeviceType;
+ private String _DeviceName;
+ private Int32 _RoomID;
+ private String _RoomName;
+
+ #region device specific diff information
+ private ThermostatModes mode;
+ private Double temperature;
+ private BatteryStatus lowBattery;
+ #endregion
+
+ public HeatingThermostatDiff (String Name, Int32 Room_ID, String Room_Name)
+ {
+ _DeviceType = DeviceTypes.HeatingThermostat;
+ _DeviceName = Name;
+ _RoomID = Room_ID;
+ _RoomName = Room_Name;
+ lowBattery = BatteryStatus.unchanged;
+ temperature = Double.NaN;
+ mode = ThermostatModes.unchanged;
+ }
+
+ #region IDeviceDiffSet implementation
+ public DeviceTypes DeviceType {
+ get {
+ return _DeviceType;
+ }
+ }
+
+ public string DeviceName {
+ get {
+ return _DeviceName;
+ }
+ }
+
+ public int RoomID {
+ get {
+ return _RoomID;
+ }
+ }
+
+ public string RoomName {
+ get {
+ return _RoomName;
+ }
+ }
+ #endregion
+
+ #region device specific diff properties
+ public ThermostatModes Mode {
+ get {
+ return mode;
+ }
+ set {
+ mode = value;
+ }
+ }
+
+ public Double Temperature {
+ get {
+ return temperature;
+ }
+ set {
+ temperature = value;
+ }
+ }
+
+ public BatteryStatus LowBattery {
+ get {
+ return lowBattery;
+ }
+ set {
+ lowBattery = value;
+ }
+ }
+ #endregion
+
+ public override string ToString ()
+ {
+ return "\t"+lowBattery+"\t"+mode+"\t"+temperature;
+ //return string.Format ("[HeatingThermostatDiff: DeviceType={0}, DeviceName={1}, RoomID={2}, RoomName={3}, Mode={4}, Temperature={5}, LowBattery={6}]", DeviceType, DeviceName, RoomID, RoomName, Mode, Temperature, LowBattery);
+ }
+
+ }
+}
+
@@ -0,0 +1,80 @@
+using System;
+
+namespace xs1_data_logging
+{
+ public class ShutterContactDiff : IDeviceDiffSet
+ {
+ private DeviceTypes _DeviceType;
+ private String _DeviceName;
+ private Int32 _RoomID;
+ private String _RoomName;
+
+ #region device specific diff information
+ private ShutterContactModes state;
+ private BatteryStatus lowBattery;
+ #endregion
+
+ public ShutterContactDiff (String Name, Int32 Room_ID, String Room_Name)
+ {
+ _DeviceType = DeviceTypes.ShutterContact;
+ _DeviceName = Name;
+ _RoomID = Room_ID;
+ _RoomName = Room_Name;
+ lowBattery = BatteryStatus.unchanged;
+ state = ShutterContactModes.unchanged;
+ }
+
+ #region IDeviceDiffSet implementation
+ public DeviceTypes DeviceType {
+ get {
+ return _DeviceType;
+ }
+ }
+
+ public string DeviceName {
+ get {
+ return _DeviceName;
+ }
+ }
+
+ public int RoomID {
+ get {
+ return _RoomID;
+ }
+ }
+
+ public string RoomName {
+ get {
+ return _RoomName;
+ }
+ }
+ #endregion
+
+ #region device specific diff properties
+
+ public ShutterContactModes ShutterState {
+ get {
+ return state;
+ }
+ set {
+ state = value;
+ }
+ }
+
+ public BatteryStatus LowBattery {
+ get {
+ return lowBattery;
+ }
+ set {
+ lowBattery = value;
+ }
+ }
+ #endregion
+
+ public override string ToString ()
+ {
+ return "\t"+lowBattery+"\t"+state;
+ }
+ }
+}
+
@@ -0,0 +1,20 @@
+using System;
+
+namespace xs1_data_logging
+{
+ public static class Base64
+ {
+ #region Base64 encoding / decoding
+ public static string Encode(byte[] toEncode)
+ {
+ return Convert.ToBase64String(toEncode);
+ }
+
+ public static byte[] Decode(string encodedData)
+ {
+ return System.Convert.FromBase64String(encodedData);
+ }
+ #endregion
+ }
+}
+
@@ -0,0 +1,13 @@
+using System;
+
+namespace xs1_data_logging
+{
+ public enum MAXMessageType
+ {
+ H,
+ M,
+ C,
+ L
+ }
+}
+
@@ -0,0 +1,41 @@
+using System;
+
+namespace xs1_data_logging
+{
+ public abstract class AMAXException : Exception
+ {
+ protected AMAXException(Exception innerException = null) : base(String.Empty, innerException) { }
+
+ /// <summary>
+ /// The message which is associated to this Exception
+ /// </summary>
+ protected String _msg;
+
+ /// <summary>
+ /// The message property
+ /// </summary>
+ public override String Message
+ {
+ get { return _msg; }
+ }
+
+ /// <summary>
+ /// The error message
+ /// </summary>
+ /// <returns>The error message</returns>
+ public override string ToString()
+ {
+ return _msg;
+ }
+ }
+
+ public class MAXException: AMAXException
+ {
+ public MAXException(string Message)
+ {
+ _msg = Message;
+ }
+ }
+
+}
+
Oops, something went wrong.

0 comments on commit 3a54c17

Please sign in to comment.