예제 #1
0
        internal async Task <object> HandleGet(HandlerParameter handler, string deviceId)
        {
            if (DeviceIsInvalid(handler, deviceId))
            {
                _logger.LogDebug($"RequestHandler | handlerget failed for {deviceId}");
                throw new NEEOException("INVALID_GET_PARAMETER");
            }
            _logger.LogDebug($"RequestHandler | process get request for {deviceId}");

            object result = null;

            switch (handler.ComponentType)
            {
            case ComponentType.TYPE_BUTTON:
            case ComponentType.TYPE_TEXTLABEL:
            case ComponentType.TYPE_IMAGEURL:
            case ComponentType.TYPE_SENSOR:
            case ComponentType.TYPE_SLIDER:
            case ComponentType.TYPE_SWITCH:
                NEEOGetFunc handlerFunction = handler.Controller.Getter;
                if (handlerFunction != null)
                {
                    result = await handlerFunction(deviceId);
                }
                break;

            default:
                _logger.LogWarning($"RequestHandler | INVALID_GET_COMPONENT { handler.ComponentType }");
                break;
            }
            _logger.LogDebug($"RequestHandler | process get request for {deviceId} : {result}");
            return(result);
        }
예제 #2
0
        public DeviceBuilder AddButton(string name, string label, NEEOGetFunc function = null)
        {
            Parameter par = new Parameter(ComponentType.TYPE_BUTTON, name, label, function == null ? null : new Controller(function));

            CheckParamName(par);
            _logger.LogDebug($"Add button {par.Name}");
            _buttons.Add(par);
            return(this);
        }
예제 #3
0
        public DeviceBuilder AddTextLabel(string name, string label, NEEOGetFunc getterFunc)
        {
            Parameter param = new Parameter(ComponentType.TYPE_TEXTLABEL, name, label, new Controller(getterFunc));

            CheckParamName(param);
            _logger.LogDebug($"Add textlabel {param.Name}");
            _textLabels.Add(param);
            return(this);
        }
예제 #4
0
        public DeviceBuilder AddSwitch(string name, string label, NEEOGetFunc getterFunc, NEEOSetFunc setterFunc)
        {
            Parameter param = new Parameter(ComponentType.TYPE_SWITCH, name, label, new Controller(getterFunc, setterFunc));

            CheckParamName(param);
            _logger.LogDebug($"Add switch {param.Name}");
            _switches.Add(param);
            return(this);
        }
예제 #5
0
        public DeviceBuilder AddPowerStateSensor(NEEOGetFunc getterFunc)
        {
            _logger.LogDebug("add power sensor");
            var par = new Parameter(ComponentType.TYPE_POWER_SENSOR, "powerstate", "PowerState", new Controller(getterFunc));

            _sensors.Add(par);
            _hasPowerStateSensor = true;
            return(this);
        }
예제 #6
0
 public Controller(NEEOGetFunc getter, NEEOSetFunc setter = null)
 {
     Getter = getter;
     Setter = setter;
 }
예제 #7
0
 public DeviceBuilder AddButton(BUTTON button, string label, NEEOGetFunc function = null)
 {
     return(AddButton(NEEOButton.Get(button), label, function));
 }
예제 #8
0
        public DeviceBuilder AddImageUrl(string name, string label, string size, string imageUrl, NEEOGetFunc getterFunc)
        {
            Parameter param = new Parameter(ComponentType.TYPE_IMAGEURL, name, label, size, imageUrl, new Controller(getterFunc));

            CheckParamName(param);
            _logger.LogDebug($"Add imageUrl {param.Name}");
            _imageUrls.Add(param);
            return(this);
        }
예제 #9
0
        public DeviceBuilder AddSensor(string name, string label, double rangeLow, double rangeHigh, string unit, NEEOGetFunc getterFunc)
        {
            Parameter param = new Parameter(ComponentType.TYPE_SLIDER, name, rangeLow, rangeHigh, unit, label, new Controller(getterFunc));

            CheckParamName(param);
            _logger.LogDebug($"Add sensor {param.Name}");
            _sensors.Add(param);
            return(this);
        }