private void createSignals() { try { // Device Arrival Signal AdapterSignal deviceArrivalSignal = new AdapterSignal(Constants.DEVICE_ARRIVAL_SIGNAL); AdapterValue deviceHandle_arrival = new AdapterValue( Constants.DEVICE_ARRIVAL__DEVICE_HANDLE, null); deviceArrivalSignal.Params.Add(deviceHandle_arrival); // Device Removal Signal AdapterSignal deviceRemovalSignal = new AdapterSignal(Constants.DEVICE_REMOVAL_SIGNAL); AdapterValue deviceHandle_removal = new AdapterValue( Constants.DEVICE_REMOVAL__DEVICE_HANDLE, null); deviceRemovalSignal.Params.Add(deviceHandle_removal); // Add Signals to the Adapter Signals this.Signals.Add(deviceArrivalSignal); this.Signals.Add(deviceRemovalSignal); } catch (OutOfMemoryException ex) { throw; } }
private void createSignals() { try { // Device Arrival Signal AdapterSignal deviceArrivalSignal = new AdapterSignal(Constants.DEVICE_ARRIVAL_SIGNAL); AdapterValue deviceHandle_arrival = new AdapterValue(Constants.DEVICE_ARRIVAL__DEVICE_HANDLE, null); deviceArrivalSignal.Params.Add(deviceHandle_arrival); // Device Removal Signal AdapterSignal deviceRemovalSignal = new AdapterSignal(Constants.DEVICE_REMOVAL_SIGNAL); AdapterValue deviceHandle_removal = new AdapterValue(Constants.DEVICE_REMOVAL__DEVICE_HANDLE, null); deviceRemovalSignal.Params.Add(deviceHandle_removal); // Add Signals to the Adapter Signals this.Signals.Add(deviceArrivalSignal); this.Signals.Add(deviceRemovalSignal); // change of value signal AdapterSignal changeOfAttributeValue = new AdapterSignal(Constants.CHANGE_OF_VALUE_SIGNAL); changeOfAttributeValue.AddParam(Constants.COV__PROPERTY_HANDLE); changeOfAttributeValue.AddParam(Constants.COV__ATTRIBUTE_HANDLE); this.Signals.Add(changeOfAttributeValue); } catch (OutOfMemoryException ex) { Debug.WriteLine("Out of memory while trying to create signals." + ex.Message); throw; } }
internal void AddChangeOfValueSignal( IAdapterProperty Property, IAdapterValue Attribute) { try { AdapterSignal covSignal = new AdapterSignal(Constants.CHANGE_OF_VALUE_SIGNAL); // Property Handle AdapterValue propertyHandle = new AdapterValue( Constants.COV__PROPERTY_HANDLE, Property); // Attribute Handle AdapterValue attrHandle = new AdapterValue( Constants.COV__ATTRIBUTE_HANDLE, Attribute); covSignal.Params.Add(propertyHandle); covSignal.Params.Add(attrHandle); this.Signals.Add(covSignal); } catch (OutOfMemoryException ex) { throw; } }
internal void AddChangeOfValueSignal(IAdapterProperty Property, IAdapterValue Attribute) { try { AdapterSignal covSignal = new AdapterSignal(Constants.CHANGE_OF_VALUE_SIGNAL); AdapterValue propertyHandle = new AdapterValue(Constants.COV__PROPERTY_HANDLE, Property); AdapterValue attrHandle = new AdapterValue(Constants.COV__ATTRIBUTE_HANDLE, Attribute); covSignal.Params.Add(propertyHandle); covSignal.Params.Add(attrHandle); this.Signals.Add(covSignal); } catch (OutOfMemoryException ex) { Debug.WriteLine("Out of memory while trying to change the value of the signal." + ex.Message); throw; } }
internal void AddChangeOfValueSignal( IAdapterProperty Property, IAdapterValue Attribute) { try { AdapterSignal covSignal = new AdapterSignal(Constants.CHANGE_OF_VALUE_SIGNAL); // Property Handle AdapterValue propertyHandle = new AdapterValue( Constants.COV__PROPERTY_HANDLE, Property); // Attribute Handle AdapterValue attrHandle = new AdapterValue( Constants.COV__ATTRIBUTE_HANDLE, Attribute); covSignal.Params.Add(propertyHandle); covSignal.Params.Add(attrHandle); this.Signals.Add(covSignal); try { ((AdapterValue)Attribute).SignalHashCode = covSignal.GetHashCode(); this.SignalsDict.Add(covSignal.GetHashCode(), covSignal); //this.SignalsDict.Add(Attribute.GetHashCode().ToString(), covSignal); } catch (ArgumentException ex) { //ex.Message System.Diagnostics.Debug.WriteLine("ex.Message.............." + ex.Message); } } catch (OutOfMemoryException ex) { throw; } }
internal AdapterValue(AdapterValue Other) { this.Name = Other.Name; this.Data = Other.Data; }
public uint Initialize() { AdapterDevice devicePin5 = new AdapterDevice("Switch 1", "Rohit Narayan", "Testing Model", "0.0.1", "000000001", "Controls Pin 5"); AdapterDevice devicePin6 = new AdapterDevice("Switch 2", "Rohit Narayan", "Testing Model", "0.0.1", "000000001", "Controls Pin 6"); AdapterDevice devicePin12 = new AdapterDevice("Switch 3", "Rohit Narayan", "Testing Model", "0.0.1", "000000001", "Controls Pin 12"); AdapterDevice devicePin16 = new AdapterDevice("Switch 4", "Rohit Narayan", "Testing Model", "0.0.1", "000000001", "Controls Pin 16"); // Define GPIO Pin-5 as device property. Device contains properties AdapterProperty gpioPin_Property5 = new AdapterProperty(PIN_NAME5, PIN_INTERFACE_HINT5); // Define and set GPIO Pin-5 value. Device contains properties that have one or more attributes. pinValueData5 = (int)pin5.Read(); AdapterValue pinValueAttr5 = new AdapterValue(PIN_VALUE_NAME5, pinValueData5); gpioPin_Property5.Attributes.Add(pinValueAttr5); // Define GPIO Pin-6 as device property. Device contains properties AdapterProperty gpioPin_Property6 = new AdapterProperty(PIN_NAME6, PIN_INTERFACE_HINT6); // Define and set GPIO Pin-6 value. Device contains properties that have one or more attributes. pinValueData6 = (int)pin6.Read(); AdapterValue pinValueAttr6 = new AdapterValue(PIN_VALUE_NAME6, pinValueData6); gpioPin_Property6.Attributes.Add(pinValueAttr6); // Define GPIO Pin-12 as device property. Device contains properties AdapterProperty gpioPin_Property12 = new AdapterProperty(PIN_NAME12, PIN_INTERFACE_HINT12); // Define and set GPIO Pin-12 value. Device contains properties that have one or more attributes. pinValueData12 = (int)pin12.Read(); AdapterValue pinValueAttr12 = new AdapterValue(PIN_VALUE_NAME12, pinValueData12); gpioPin_Property12.Attributes.Add(pinValueAttr12); // Define GPIO Pin-16 as device property. Device contains properties AdapterProperty gpioPin_Property16 = new AdapterProperty(PIN_NAME16, PIN_INTERFACE_HINT16); // Define and set GPIO Pin-16 value. Device contains properties that have one or more attributes. pinValueData16 = (int)pin16.Read(); AdapterValue pinValueAttr16 = new AdapterValue(PIN_VALUE_NAME16, pinValueData16); gpioPin_Property16.Attributes.Add(pinValueAttr16); devicePin5.Properties.Add(gpioPin_Property5); devicePin6.Properties.Add(gpioPin_Property6); devicePin12.Properties.Add(gpioPin_Property12); devicePin16.Properties.Add(gpioPin_Property16); devices.Add(devicePin5); devices.Add(devicePin6); devices.Add(devicePin12); devices.Add(devicePin16); return ERROR_SUCCESS; }
internal uint Initialize() { // Sensor property. ModbusSensorProperty sensorProperty = new ModbusSensorProperty(this, "T/H/CO2 Sensor", ""); // Current Temperature Reading attribute. ModbusSensorAttribute tempAttr = new ModbusSensorAttribute( this, "Temperature", Windows.Foundation.PropertyValue.CreateDouble(0), E_ACCESS_TYPE.ACCESS_READ ); tempAttr.COVBehavior = SignalBehavior.Always; sensorProperty.Attributes.Add(tempAttr); // Temperature Adjustment attribute. ModbusSensorAttribute tempAdjAttr = new ModbusSensorAttribute( this, "Temperature Adjustment", Windows.Foundation.PropertyValue.CreateDouble(0), E_ACCESS_TYPE.ACCESS_READ ); tempAdjAttr.COVBehavior = SignalBehavior.Always; sensorProperty.Attributes.Add(tempAdjAttr); //Set Temperature Adjustment method. ModbusSensorMethod tempAdjCommand = new ModbusSensorMethod( this, "setTempAdj", "Sets the value of Temperature Adjustment to adjust the temperature reading. The input value must be between -20.0 to +20.0.", "Temperature Adjustment", 0); var tempAdjParam = new AdapterValue("value", Windows.Foundation.PropertyValue.CreateDouble(0)); tempAdjCommand.InputParams.Add(tempAdjParam); this.Methods.Add(tempAdjCommand); // Currernt Humidity Reading attribute. ModbusSensorAttribute humidAttr = new ModbusSensorAttribute( this, "Humidity", Windows.Foundation.PropertyValue.CreateDouble(0), E_ACCESS_TYPE.ACCESS_READ ); humidAttr.COVBehavior = SignalBehavior.Always; sensorProperty.Attributes.Add(humidAttr); // Humidity Adjustment attribute. ModbusSensorAttribute humidAdjAttr = new ModbusSensorAttribute( this, "Humidity Adjustment", Windows.Foundation.PropertyValue.CreateDouble(0), E_ACCESS_TYPE.ACCESS_READ ); humidAdjAttr.COVBehavior = SignalBehavior.Always; sensorProperty.Attributes.Add(humidAdjAttr); //Set Humidity Adjustment method. ModbusSensorMethod humidAdjCommand = new ModbusSensorMethod( this, "setHumidAdj", "Sets the value of Humidity Adjustment to adjust the humidity reading. The input value must be between -20.0 to +20.0.", "Humidity Adjustment", 0); var humidAdjParam = new AdapterValue("value", Windows.Foundation.PropertyValue.CreateDouble(0)); humidAdjCommand.InputParams.Add(humidAdjParam); this.Methods.Add(humidAdjCommand); // Temperature/Humidity Reading Interval attribute. ModbusSensorAttribute THIntervalAttr = new ModbusSensorAttribute( this, "T/H Reading Interval", Windows.Foundation.PropertyValue.CreateUInt16(1), E_ACCESS_TYPE.ACCESS_READ ); THIntervalAttr.COVBehavior = SignalBehavior.Always; sensorProperty.Attributes.Add(THIntervalAttr); //Set Temperature/Humidity Reading Interval method. ModbusSensorMethod THIntervalCommand = new ModbusSensorMethod( this, "setTHInterval", "Sets the value of temperature and humidity reading interval. The input value must be between 1 to 10.", "T/H Reading Interval", 0); var THIntervalParam = new AdapterValue("value", Windows.Foundation.PropertyValue.CreateUInt16(1)); THIntervalCommand.InputParams.Add(THIntervalParam); this.Methods.Add(THIntervalCommand); // Current CO2 Concentration attribute. ModbusSensorAttribute CO2Attr = new ModbusSensorAttribute( this, "CO2 Concentration", Windows.Foundation.PropertyValue.CreateUInt16(0), E_ACCESS_TYPE.ACCESS_READ ); CO2Attr.COVBehavior = SignalBehavior.Always; sensorProperty.Attributes.Add(CO2Attr); // CO2 Adjustment attribute. ModbusSensorAttribute CO2AdjAttr = new ModbusSensorAttribute( this, "CO2 Adjustment", Windows.Foundation.PropertyValue.CreateInt16(0), E_ACCESS_TYPE.ACCESS_READ ); CO2AdjAttr.COVBehavior = SignalBehavior.Always; sensorProperty.Attributes.Add(CO2AdjAttr); //Set CO2 Concentration Adjustment method. ModbusSensorMethod CO2AdjCommand = new ModbusSensorMethod( this, "setCO2Adj", "Sets the value of CO2 concentration Adjustment to adjust the CO2 concentration reading. The input value must be between -1500 to +1500", "CO2 Adjustment", 0); var CO2AdjParam = new AdapterValue("value", Windows.Foundation.PropertyValue.CreateInt16(0)); CO2AdjCommand.InputParams.Add(CO2AdjParam); this.Methods.Add(CO2AdjCommand); // CO2 Reading Interval attribute. ModbusSensorAttribute CO2IntervalAttr = new ModbusSensorAttribute( this, "CO2 Reading Interval", Windows.Foundation.PropertyValue.CreateUInt16(1), E_ACCESS_TYPE.ACCESS_READ ); CO2IntervalAttr.COVBehavior = SignalBehavior.Always; sensorProperty.Attributes.Add(CO2IntervalAttr); //Set CO2 Reading Interval method. ModbusSensorMethod CO2IntervalCommand = new ModbusSensorMethod( this, "setCO2Interval", "Sets the value of temperature and humidity reading interval. The input value must be between 1 to 10.", "CO2 Reading Interval", 0); var CO2IntervalParam = new AdapterValue("value", Windows.Foundation.PropertyValue.CreateUInt16(1)); CO2IntervalCommand.InputParams.Add(CO2IntervalParam); this.Methods.Add(CO2IntervalCommand); // Create Change of Value Signal for the Temperature Attribute AdapterSignal covSignal = new AdapterSignal(Constants.CHANGE_OF_VALUE_SIGNAL); AdapterValue propertyHandle = new AdapterValue(Constants.COV__PROPERTY_HANDLE, sensorProperty); AdapterValue attrHandle = new AdapterValue(Constants.COV__ATTRIBUTE_HANDLE, tempAttr.Value); covSignal.Params.Add(propertyHandle); covSignal.Params.Add(attrHandle); this.Signals.Add(covSignal); this.Properties.Add(sensorProperty); return(ERROR_SUCCESS); }