public TurnOnOffDevice(string vendorName, string model, string version,
                               string serialNumber, string description, ITurnOnOffModule module)
            : base(module.Name, vendorName, model, version, serialNumber, description)
        {
            Module = module;
            AdapterBusObject busObject = new AdapterBusObject("Guybrush");

            Interface = new AdapterInterface("com.guybrush.devices.onoffcontrol");
            var attr = new AdapterAttribute("Status", module.Status)
            {
                COVBehavior = SignalBehavior.Always, Access = E_ACCESS_TYPE.ACCESS_READ
            };

            attr.Annotations.Add("com.guybrush.devices.onoffcontrol.status", "The device status");
            Interface.Properties.Add(attr);

            List <IAdapterValue> inputs = new List <IAdapterValue>(1);

            inputs.Add(new AdapterValue("TargetStatus", false));

            AdapterMethod method = new AdapterMethod("Switch", "Switches devices on or off.", ChangeStatus, inputs);

            Interface.Methods.Add(method);

            busObject.Interfaces.Add(Interface);
            BusObjects.Add(busObject);
            CreateEmitSignalChangedSignal();

            Module.ValueChanged += Module_ValueChanged;
        }
Пример #2
0
        public ReaderDevice(string vendorName, string model, string version,
                            string serialNumber, string description, IReaderModule module)
            : base(module.Name, vendorName, model, version, serialNumber, description)
        {
            Module = module;
            AdapterBusObject busObject = new AdapterBusObject("Guybrush");

            Interface = new AdapterInterface("com.guybrush.devices.reader");

            var attrValue = new AdapterAttribute("Value", module.Value)
            {
                COVBehavior = SignalBehavior.Always, Access = E_ACCESS_TYPE.ACCESS_READ
            };

            attrValue.Annotations.Add("com.guybrush.devices.reader.value", "The device value");
            Interface.Properties.Add(attrValue);

            var attrUnit = new AdapterAttribute("Unit", module.Unit)
            {
                COVBehavior = SignalBehavior.Always, Access = E_ACCESS_TYPE.ACCESS_READ
            };

            attrUnit.Annotations.Add("com.guybrush.devices.reader.unit", "The device unit");
            Interface.Properties.Add(attrUnit);

            busObject.Interfaces.Add(Interface);
            BusObjects.Add(busObject);
            CreateEmitSignalChangedSignal();

            Module.ValueChanged += Module_ValueChanged;
            Module.UnitChanged  += Module_UnitChanged;
        }
        public SmarthomeAdapter(BridgeConfiguration configuration, ConditionManager conditionMgr) : base(configuration)
        {
            _conditionManager = conditionMgr;

            _abo = new AdapterBusObject("Guybrush");
            AdapterInterface conditionInterface = new AdapterInterface("com.guybrush.station.conditions");

            var addConInputParams = new List <AdapterValue>();

            addConInputParams.Add(new AdapterValue("SourceDeviceType", -1));
            addConInputParams.Add(new AdapterValue("SourceDevice", ""));
            addConInputParams.Add(new AdapterValue("TargetDevice", ""));
            addConInputParams.Add(new AdapterValue("RequiredValue", -1));
            addConInputParams.Add(new AdapterValue("ConditionType", -1));
            addConInputParams.Add(new AdapterValue("TargetValue", -1));

            var addConOutParams = new List <AdapterValue>();

            addConOutParams.Add(new AdapterValue("Response", ""));

            AdapterMethod addCondAttr = new AdapterMethod("AddCondition", "Calling this method will add new condition.", AddCondition, addConInputParams, addConOutParams);

            conditionInterface.Methods.Add(addCondAttr);



            var getCondOutParams = new List <AdapterValue>();

            getCondOutParams.Add(new AdapterValue("SourceDeviceType", ""));
            getCondOutParams.Add(new AdapterValue("SourceDevice", ""));
            getCondOutParams.Add(new AdapterValue("TargetDevice", ""));
            getCondOutParams.Add(new AdapterValue("RequiredValue", ""));
            getCondOutParams.Add(new AdapterValue("ConditionType", ""));
            getCondOutParams.Add(new AdapterValue("TargetValue", ""));

            AdapterMethod getCondAttr = new AdapterMethod("GetConditions", "Calling this method returns list of conditions", GetConditions, null, getCondOutParams);

            conditionInterface.Methods.Add(getCondAttr);

            var removeCondInputParams = new List <AdapterValue>();

            removeCondInputParams.Add(new AdapterValue("SourceDevice", ""));
            removeCondInputParams.Add(new AdapterValue("TargetDevice", ""));

            var removeConOutParams = new List <AdapterValue>();

            removeConOutParams.Add(new AdapterValue("Response", ""));

            AdapterMethod removeCondAttr = new AdapterMethod("RemoveCondition", "Calling this method will remove a condition", RemoveCondition, removeCondInputParams, removeConOutParams);

            conditionInterface.Methods.Add(removeCondAttr);

            _abo.Interfaces.Add(conditionInterface);
            BusObjects.Add(_abo);
        }
Пример #4
0
        public DisplayDevice(string name, string vendorName, string model, string version,
                             string serialNumber, string description, IDisplayModule module)
            : base(name, vendorName, model, version, serialNumber, description)
        {
            Module = module;
            AdapterBusObject busObject = new AdapterBusObject("Guybrush");

            Interface = new AdapterInterface("com.guybrush.display");

            var attr = new AdapterAttribute("Text", module.Text)
            {
                COVBehavior = SignalBehavior.Always, Access = E_ACCESS_TYPE.ACCESS_READ
            };

            attr.Annotations.Add("com.guybrush.devices.display.text", "The device status");
            Interface.Properties.Add(attr);

            busObject.Interfaces.Add(Interface);
            BusObjects.Add(busObject);
            CreateEmitSignalChangedSignal();

            Module.TextChanged += Module_TextChanged;
        }