Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        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;
            }
        }
 public MockLightingServiceHandler(string name, string id, bool isDimmable, bool supportsColor, bool supportsTemperature, Windows.UI.Core.CoreDispatcher dispatcher)
 {
     this.dispatcher = dispatcher;
     Name = name;
     Id = id;
     LampDetails_Color = supportsColor;
     LampDetails_ColorRenderingIndex = 80;
     LampDetails_Dimmable = isDimmable;
     LampDetails_HasEffects = true;
     LampDetails_IncandescentEquivalent = 60;
     LampDetails_LampBaseType = (uint)1;
     LampDetails_LampBeamAngle = 130;
     LampDetails_LampID = id;
     LampDetails_LampType = (uint) 1;
     LampDetails_Make = (uint)AdapterLib.LsfEnums.LampMake.MAKE_OEM1;
     LampDetails_MaxLumens = 1000;
     LampDetails_MaxTemperature = (uint)(supportsTemperature ? 9000 : 2800);
     LampDetails_MaxVoltage = 120;
     LampDetails_MinTemperature = 2800;
     colorTemp = kelvinToUInt(LampDetails_MinTemperature);
     LampDetails_MinVoltage = 100;
     LampDetails_Model = 1;
     LampDetails_Type = (uint)AdapterLib.LsfEnums.DeviceType.TYPE_LAMP;
     LampDetails_VariableColorTemp = supportsTemperature;
     LampDetails_Version = 1;
     LampDetails_Wattage = 7;
     if (!supportsColor) saturation = 0;
     _LampStateChanged = new AdapterSignal(Constants.LAMP_STATE_CHANGED_SIGNAL_NAME);
     _LampStateChanged.Params.Add(new AdapterValue("LampID", id));
 }
Exemplo n.º 4
0
        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;
            }
        }
Exemplo n.º 5
0
        private void CreateSignals()
        {
            // 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);
            Signals.Add(changeOfAttributeValue);
        }
Exemplo n.º 6
0
        internal AdapterSignal(AdapterSignal Other)
        {
            this.Name = Other.Name;

            try
            {
                this.Params = new List <IAdapterValue>(Other.Params);
            }
            catch (OutOfMemoryException ex)
            {
                throw;
            }
        }
Exemplo n.º 7
0
        internal AdapterSignal(AdapterSignal Other)
        {
            Name = Other.Name;

            try
            {
                Params = new List <IAdapterValue>(Other.Params);
            }
            catch (OutOfMemoryException ex)
            {
                Debug.WriteLine(ex);
                throw;
            }
        }
Exemplo n.º 8
0
        internal AdapterSignal(AdapterSignal Other)
        {
            this.Name = Other.Name;

            try
            {
                this.Params = new List <IAdapterValue>(Other.Params);
            }
            catch (OutOfMemoryException ex)
            {
                Debug.WriteLine("Out of memory while trying to allocate adapter signal parameter containers." + ex.Message);
                throw;
            }
        }
        internal AdapterSignal(AdapterSignal Other)
        {
            Name = Other.Name;

            try
            {
                Params = new List<IAdapterValue>(Other.Params);
            }
            catch (OutOfMemoryException ex)
            {
                Debug.WriteLine(ex);
                throw;
            }
        }
Exemplo n.º 10
0
        private uint CreateSignals()
        {
            // create device arrival signal and add it to list
            AdapterSignal deviceArrival = new AdapterSignal(Constants.DEVICE_ARRIVAL_SIGNAL);

            deviceArrival.AddParam(Constants.DEVICE_ARRIVAL__DEVICE_HANDLE);
            Signals.Add(deviceArrival);

            // create device removal signal and add it to list
            AdapterSignal deviceRemoval = new AdapterSignal(Constants.DEVICE_REMOVAL_SIGNAL);

            deviceRemoval.AddParam(Constants.DEVICE_REMOVAL__DEVICE_HANDLE);
            Signals.Add(deviceRemoval);

            return(ERROR_SUCCESS);
        }
Exemplo n.º 11
0
        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;
            }
        }
Exemplo n.º 12
0
        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 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;
            }
        }
Exemplo n.º 14
0
        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);
        }
 private void CreateSignals()
 {
     // 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);
     Signals.Add(changeOfAttributeValue);
 }
Exemplo n.º 16
0
        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;
            }
        }
        internal AdapterSignal(AdapterSignal Other)
        {
            this.Name = Other.Name;

            try
            {
                this.Params = new List<IAdapterValue>(Other.Params);
            }
            catch (OutOfMemoryException ex)
            {
                throw;
            }
        }