public void _04_UnmanagedExceptionWithoutErrorCodeSerializationTest() { UnmanagedException exception1 = new UnmanagedException("Hello world!"); Assert.IsTrue(exception1.Message == "Hello world!"); Assert.IsTrue(exception1.ErrorCode == null); UnmanagedException exception2 = SerializeAndDeserializeException <UnmanagedException>(exception1); Assert.IsTrue(exception2.Message == exception1.Message); Assert.IsTrue(exception2.ErrorCode == exception1.ErrorCode); }
private int SensorUpdated( string protocol, string model, int id, int dataType, string val, int timestamp, int callbackId, object obj, UnmanagedException ex) { Console.WriteLine("TS: " + protocol + ", " + model + ", " + id + ", " + dataType + ", " + val + ", " + timestamp + ", " + callbackId); var module = interfaceModules.FirstOrDefault(i => i.Address == id.ToString()); if (module == null) { module = new InterfaceModule { Domain = Domain, Address = id.ToString(), Description = model + " - " + protocol, ModuleType = ModuleTypes.Sensor }; interfaceModules.Add(module); InterfaceModulesChangedAction(new InterfaceModulesChangedAction { Domain = Domain }); } var path = ModuleParameters.MODPAR_STATUS_LEVEL; if (dataType == (int)TelldusLib.DataType.TEMPERATURE) { path = ModuleParameters.MODPAR_SENSOR_TEMPERATURE; } else if (dataType == (int)TelldusLib.DataType.HUMIDITY) { path = ModuleParameters.MODPAR_SENSOR_HUMIDITY; } InterfacePropertyChangedAction(new InterfacePropertyChangedAction() { Domain = Domain, SourceId = module.Address, SourceType = "Tellstick Sensor", Path = path, Value = val }); //Sensor.Temperature //MODPAR_SENSOR_TEMPERATURE return(1); }
private int SensorUpdated( string protocol, string model, int id, int dataType, string val, int timestamp, int callbackId, object obj, UnmanagedException ex) { Console.WriteLine("TS: " + protocol + ", " + model + ", " + id + ", " + dataType + ", " + val + ", " + timestamp + ", " + callbackId); var module = interfaceModules.FirstOrDefault(i => i.Address == id.ToString()); if (module == null) { module = new InterfaceModule { Domain = Domain, Address = id.ToString(), Description = model + " - " + protocol, ModuleType = ModuleTypes.Sensor }; interfaceModules.Add(module); OnInterfaceModulesChanged(this.GetDomain()); } var path = ModuleEvents.Status_Level; if (dataType == (int)TelldusLib.DataType.TEMPERATURE) { path = ModuleEvents.Sensor_Temperature; } else if (dataType == (int)TelldusLib.DataType.HUMIDITY) { path = ModuleEvents.Sensor_Humidity; } OnInterfacePropertyChanged(this.GetDomain(), module.Address, Event_Sensor_Description, path, val); return(1); }
private int OnDeviceUpdated(int deviceId, int method, string data, int callbackId, object obj, UnmanagedException ex) { var path = ModuleEvents.Status_Level; int?value = null; if (method == (int)TelldusLib.Command.TURNON) { path = ModuleEvents.Status_Level; value = 1; } else if (method == (int)TelldusLib.Command.TURNOFF) { path = ModuleEvents.Status_Level; value = 0; } if (value.HasValue) { var module = interfaceModules.FirstOrDefault(i => i.Address == deviceId.ToString()); OnInterfacePropertyChanged(this.GetDomain(), module.Address, Event_Sensor_Description, path, value); } return(1); }