Exemplo n.º 1
0
        public ThermostatModel(Device device)
        {
            _device = device;

            Core = new ThermostatCoreModel(_device);
            Fan = new ThermostatFanModel(_device);
            Setpoints = new ThermostatSetpointModel(_device);
        }
Exemplo n.º 2
0
        public void Add(Device device)
        {
            var model = DeviceModel.FromRepositoryType(device, _networks);

            _devices.Add(model);

            _save();

            device.SetId(model.Id);
        }
Exemplo n.º 3
0
        public static DeviceModel FromRepositoryType(Device model, DbSet<NetworkModel> networks)
        {
            var result = new DeviceModel
            {
                Address = model.Address,
                CurrentAction = model.CurrentAction,
                Id = model.Id,
                IsConnected = model.IsConnected,
                LastPing = model.LastPing,
                Name = model.Name,
                Network = (model.Network == null) ? null : networks.Find(model.Network.Id),
                Notes = model.ToXElement().ToString(),
                Type = model.Type
            };

            return result;
        }
Exemplo n.º 4
0
 public BinarySensorModel(Device device)
 {
     _device = device;
 }
Exemplo n.º 5
0
 public void Update(Device device)
 {
     _devices.Update(device);
 }
Exemplo n.º 6
0
 public void Remove(Device device)
 {
     _devices.Remove(device);
 }
Exemplo n.º 7
0
 public void Add(Device device)
 {
     _devices.Add(device);
 }
Exemplo n.º 8
0
 public ColorSwitchModel(Device deviceModel)
 {
     _device = deviceModel;
 }
Exemplo n.º 9
0
 public ThermostatFanModel(Device device)
 {
     _device = device;
 }
Exemplo n.º 10
0
        public void Remove(Device device)
        {
            var model = _devices.Find(device.Id);

            _devices.Remove(model);

            _save();
        }
Exemplo n.º 11
0
        public void Update(Device device)
        {
            var model = _devices.Find(device.Id);

            model.Name = device.Name;
            model.Type = device.Type;
            model.Notes = DeviceModel.FromRepositoryType(device, _networks).Notes;

            _save();
        }
Exemplo n.º 12
0
 public ThermostatCoreModel(Device device)
 {
     _device = device;
 }
Exemplo n.º 13
0
        public static Device Create(int id, IDeviceState state)
        {
            var result = new Device(
                address: null,
                lastPing: null,
                id: id,
                name: null,
                network: null,
                scripts: null,
                state: state,
                tasks: null,
                type: null
                );

            return result;
        }
Exemplo n.º 14
0
        public static Device Create(string address, bool? isConnected, string name, Network network, ILocation location, DeviceType type, string currentAction = null)
        {
            var result = new Device(
                address: address,
                lastPing: null,
                id: 0,
                name: name,
                network: network,
                scripts: null,
                state: null,
                tasks: null,
                type: type
                );

            result.CurrentAction = currentAction;

            return result;
        }
Exemplo n.º 15
0
 public ToggleSwitchModel(Device device)
 {
     _device = device;
 }
Exemplo n.º 16
0
        public Device ToRepositoryType(IScriptRepository scripts, ITaskRepository tasks)
        {
            IDeviceState state = null;

            if (!string.IsNullOrEmpty(Notes))
            {
                var element = XElement.Parse(Notes);
                state = element.ToDeviceState();
            }

            var result = new Device(
                address: Address,
                lastPing: LastPing,
                id: Id,
                name: Name,
                network: Network.ToRepositoryType(),
                scripts: scripts,
                state: state,
                tasks: tasks,
                type: Type
                );

            return result;
        }
Exemplo n.º 17
0
 public DimmerSwitchModel(Device device)
 {
     _device = device;
 }
Exemplo n.º 18
0
 private static Device GetSerializableVersion(Device device)
 {
     return Device.Create(device.Id, device);
 }