Ejemplo n.º 1
0
        /// <summary>
        /// Processes the device not responding (V1 receiver only).
        /// </summary>
        /// <param name="operationCode">The operation code.</param>
        private void Process_HoguNotResponding(OpCodes operationCode)
        {
            DeviceId id = new DeviceId();

            switch (operationCode)
            {
            case OpCodes.ChungNotResponding:
                id = this.chungDeviceId;
                break;

            case OpCodes.HongNotResponding:
                id = this.hongDeviceId;
                break;
            }

            Trace.TraceInformation("{0}. Process_HoguNotResponding: {1} Id={2}", CLASSNAME, operationCode, id);

            if (id.IsValid())
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    this.OnDeviceStatusUpdate(new DeviceStatusEventArgs()
                    {
                        ReceiverId = this.Id, DeviceId = id, DeviceStatus = DeviceStatusEnum.NotResponding
                    });
                });
            }
        }
Ejemplo n.º 2
0
        void insteon_DeviceChanged(object sender, DeviceChangedEventArgs args)
        {
            DeviceId        id        = args.State.Device.Address;
            DeviceReference reference = new DeviceReference(id.ToString(), PluginName);
            BasicDevice     device    = callbacks.Devices.FindDevice(reference);

            if (device != null)
            {
                InsteonDeviceData deviceData = (InsteonDeviceData)device.AutomationData;
                if (args.State.Device is DimmingLight)
                {
                    DimmingLight onOffDevice = (DimmingLight)args.State.Device;
                    FroggyPlugin.Devices.PercentLevelDevice basicDevice = (FroggyPlugin.Devices.PercentLevelDevice)callbacks.Devices.FindDevice(reference);

                    // Update the value, this will automatically propogate events everywhere (even back to this plugin).
                    basicDevice.Level = onOffDevice.OnLevel * 100 / 255;
                }
                else if (args.State.Device is OnOffDevice)
                {
                    OnOffDevice onOffDevice = (OnOffDevice)args.State.Device;
                    FroggyPlugin.Devices.OnOffDevice basicDevice = (FroggyPlugin.Devices.OnOffDevice)callbacks.Devices.FindDevice(reference);

                    basicDevice.On = onOffDevice.OnLevel != 0;
                }
            }
        }
Ejemplo n.º 3
0
        public IActionResult UpdateDeviceInfos(
            [FromRoute, Required] string device,
            [FromBody, Required] DeviceInfo infos)
        {
            try
            {
                var deviceId = new DeviceId(device);

                Logger.LogWarning("Put Token: " + infos.FcmToken + " for device " + deviceId);
                var deviceInfogDto = _ConfigModel.UpdateDeviceInfo(deviceId, infos);



                return(Json(deviceInfogDto));
            }
            catch (UnknownDeviceIdException e)
            {
                Logger.LogError("Exception while execution:", e);
                return(FormattedNotFound($"Device id not found."));
            }
            catch (Exception e)
            {
                Logger.LogError("Exception while execution:", e);
                return(FormattedInternalServerError($"{nameof(e)} {e.Message}"));
            }
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (MsgType.Length != 0)
            {
                hash ^= MsgType.GetHashCode();
            }
            if (DeviceId.Length != 0)
            {
                hash ^= DeviceId.GetHashCode();
            }
            if (ModuleId.Length != 0)
            {
                hash ^= ModuleId.GetHashCode();
            }
            if (Id != 0L)
            {
                hash ^= Id.GetHashCode();
            }
            if (HeartbeatCreatedTicksUtc != 0L)
            {
                hash ^= HeartbeatCreatedTicksUtc.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 5
0
        protected override DeviceId ComputeDeviceID()
        {
            DeviceId dId;

            if (preferredIdMethod == DeviceIdMethodInternal.cpuId)
            {
                String cpuIDValue = OpenUDID.value;
                if (cpuIDValue != null)
                {
                    dId = new DeviceId(cpuIDValue, DeviceIdMethodInternal.cpuId);
                }
                else
                {
                    //fallback
                    dId = new DeviceId(DeviceIdHelper.GenerateId(), DeviceIdMethodInternal.multipleWindowsFields);
                }
            }
            else if (preferredIdMethod == DeviceIdMethodInternal.multipleWindowsFields)
            {
                dId = new DeviceId(DeviceIdHelper.GenerateId(), DeviceIdMethodInternal.multipleWindowsFields);
            }
            else if (preferredIdMethod == DeviceIdMethodInternal.windowsGUID)
            {
                dId = CreateGUIDDeviceId();
            }
            else
            {
                dId = CreateGUIDDeviceId();
            }

            return(dId);
        }
Ejemplo n.º 6
0
 public bool Equals(OclProgramSource other)
 {
     return(ContextId.Equals(other.ContextId) &&
            DeviceId.Equals(other.DeviceId) &&
            Source == other.Source &&
            Options == other.Options);
 }
        public BuiltInI2CBus(DeviceId id, ILogger logger)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            Id      = id;
            _logger = logger;

            string deviceSelector = I2cDevice.GetDeviceSelector();

            DeviceInformationCollection deviceInformation = DeviceInformation.FindAllAsync(deviceSelector).AsTask().Result;

            if (deviceInformation.Count == 0)
            {
                throw new InvalidOperationException("I2C bus not found.");
            }

            _i2CBusId = deviceInformation.First().Id;
        }
        public virtual void AddOrUpdateDeviceInfos(DeviceId deviceId, DeviceInfo deviceInfo)
        {
            if (_deviceInfos.ContainsKey(deviceId))
            {
                _deviceInfos[deviceId] = deviceInfo;
            }
            else
            {
                _deviceInfos.Add(deviceId, deviceInfo);
            }

            try
            {
                var devices  = "devices";
                var dirname  = Path.Combine(Directory.GetCurrentDirectory(), devices);
                var filename = Path.Combine(dirname, deviceId.FullId);

                if (!Directory.Exists(dirname))
                {
                    Directory.CreateDirectory(dirname);
                }

                var json = JsonConvert.SerializeObject(deviceInfo, Formatting.Indented);
                File.WriteAllLines(filename, new[] { json });
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
            }
        }
Ejemplo n.º 9
0
        protected async Task LoadDeviceIDFromStorage()
        {
            DeviceId dId = await Storage.Instance.LoadFromFile <DeviceId>(deviceFilename);

            bool saveAfterLoading = false;

            if (dId == null)
            {
                // if it's null then either there is no device Id saved or it's saved
                // in the legacy format as just a string. Try deserializing that
                String backupDeviceId = await Storage.Instance.LoadFromFile <string>(deviceFilename);

                if (backupDeviceId != null)
                {
                    //it was in the backup format, assume it's Guid
                    dId = new DeviceId(backupDeviceId, DeviceIdMethodInternal.windowsGUID);
                    saveAfterLoading = true;
                }
            }

            if (dId?.deviceId != null)
            {
                deviceId     = dId.deviceId;
                usedIdMethod = dId.deviceIdMethod;
            }

            if (saveAfterLoading)
            {
                //it must have been in the legacy format, save it before continueing
                await SaveDeviceIDToStorage();
            }
        }
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked
     {
         return((VendorId.GetHashCode() * 397) ^ DeviceId.GetHashCode());
     }
 }
Ejemplo n.º 11
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((DeviceId.GetHashCode() * 397) ^ (SecretToken != null ? SecretToken.GetHashCode() : 0));
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Returns true if DeviceData instances are equal
        /// </summary>
        /// <param name="other">Instance of DeviceData to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(DeviceData other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     DeviceId == other.DeviceId ||
                     DeviceId != null &&
                     DeviceId.Equals(other.DeviceId)
                     ) &&
                 (
                     Timestamp == other.Timestamp ||
                     Timestamp != null &&
                     Timestamp.Equals(other.Timestamp)
                 ) &&
                 (
                     Value == other.Value ||
                     Value != null &&
                     Value.Equals(other.Value)
                 ));
        }
Ejemplo n.º 13
0
 public IActionResult GetValues(
     [FromRoute, Required] string device,
     [FromQuery] PaginationRequestDto pagination,
     [FromQuery] FilterRequest filter,
     [FromQuery] SortRequestDto sort)
 {
     try
     {
         var deviceId = new DeviceId(device);
         var dataDto  = _DataModel.GetValueData(deviceId, pagination.PageNumber, pagination.PageSize,
                                                filter.FilterBy, filter.FilterString, filter.FilterExcluding,
                                                filter.FilterStateBy, filter.FilterStateExcluding,
                                                sort.SortBy, sort.SortOrderAscending);
         return(Json(dataDto));
     }
     catch (UnknownDeviceIdException e)
     {
         Logger.LogError("Exception while execution:", e);
         return(FormattedNotFound($"Device id not found."));
     }
     catch (Exception e)
     {
         Logger.LogError("Exception while execution:", e);
         return(FormattedInternalServerError($"{nameof(e)} {e.Message}"));
     }
 }
Ejemplo n.º 14
0
        void insteon_DeviceAdded(object sender, DeviceAddedEventArgs args)
        {
            DeviceId        id        = args.Device.Address;
            DeviceReference reference = new DeviceReference(id.ToString(), PluginName);
            BasicDevice     device    = callbacks.Devices.FindDevice(reference);

            if (device != null)
            {
                InsteonDeviceData deviceData = (InsteonDeviceData)device.AutomationData;
            }
            else
            {
                InsteonDeviceData deviceData = new InsteonDeviceData(args.Device.Category, args.Device.Subcategory);
                if (args.Device is DimmingLight)
                {
                    DimmingLight dimmer = (DimmingLight)args.Device;
                    FroggyPlugin.Devices.PercentLevelDevice basic = new FroggyPlugin.Devices.PercentLevelDevice();
                    basic.Address        = reference;
                    basic.Name           = args.Device.DeviceName;
                    basic.Level          = dimmer.OnLevel * 100 / 255;
                    basic.AutomationData = deviceData;
                    callbacks.Devices.AddDevice(basic);
                }
                else if (args.Device is OnOffDevice)
                {
                    OnOffDevice onOffDevice = (OnOffDevice)args.Device;
                    FroggyPlugin.Devices.OnOffDevice basic = new FroggyPlugin.Devices.OnOffDevice();
                    basic.Address        = reference;
                    basic.Name           = args.Device.DeviceName;
                    basic.On             = onOffDevice.OnLevel != 0;
                    basic.AutomationData = deviceData;
                    callbacks.Devices.AddDevice(basic);
                }
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Do any device updates based on this update.
        /// </summary>
        /// <param name="update">The update to apply</param>
        public void UpdateDevice(FroggyPlugin.Events.DeviceUpdate update)
        {
            DeviceId   id = new DeviceId(update.Device.Address.Address);
            DeviceBase device;

            if (insteon.FindDevice(id, out device))
            {
                switch (update.Type)
                {
                case FroggyPlugin.Events.DeviceUpdate.UpdateType.State:
                    if (device is DimmingLight)
                    {
                        DimmingLight      dimmer       = (DimmingLight)device;
                        DeviceState <int> percentLevel = (DeviceState <int>)update.State;
                        dimmer.OnLevel = (percentLevel.Value * 255 / 100);
                    }
                    else if (device is OnOffDevice)
                    {
                        OnOffDevice        onOffdevice = (OnOffDevice)device;
                        DeviceState <bool> boolUpdate  = (DeviceState <bool>)update.State;
                        onOffdevice.OnLevel = boolUpdate.Value ? 255 : 0;
                    }
                    break;
                }
            }
        }
Ejemplo n.º 16
0
    public override int GetHashCode()
    {
        int hash = 1;

        if (Control != 0)
        {
            hash ^= Control.GetHashCode();
        }
        if (Status != 0)
        {
            hash ^= Status.GetHashCode();
        }
        if (DeviceName.Length != 0)
        {
            hash ^= DeviceName.GetHashCode();
        }
        if (DeviceId.Length != 0)
        {
            hash ^= DeviceId.GetHashCode();
        }
        if (Operator.Length != 0)
        {
            hash ^= Operator.GetHashCode();
        }
        return(hash);
    }
Ejemplo n.º 17
0
 public FullUserAuth(string login, string gameRef, string facebookId, string vkontakteId, string deviceId)
 {
     m_LoginGameRef = new LoginGameRef(login, gameRef);
     m_Facebook     = new FacebookId(facebookId);
     m_Vkontakte    = new VkontakteId(vkontakteId);
     m_DeviceId     = new DeviceId(deviceId);
 }
Ejemplo n.º 18
0
        public IActionResult PutJob(
            [FromRoute][Required] string device,
            [FromBody][Required] Job job)
        {
            try
            {
                if (job == null)
                {
                    return(BadRequest("Body empty"));
                }

                var deviceId = new DeviceId(device);
                Logger.DebugLogMessage($"Received job from \"{deviceId}\":", job);
                _actionModel.PutJob(deviceId, job);

                return(FormattedOk());
            }
            catch (FormatException e)
            {
                Logger.Error(e);
                return(BadRequest("DeviceId fehlerhaft."));
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(FormattedInternalServerError());
            }
        }
Ejemplo n.º 19
0
 /// <inheritdoc/>
 public override int GetHashCode()
 => base.GetHashCode() ^
 DeviceId.GetHashCode() ^
 Function.GetHashCode() ^
 Address.GetHashCode() ^
 Count.GetHashCode() ^
 Data.GetHashCode();
Ejemplo n.º 20
0
        private void Parse()
        {
            //http://wiki.volkszaehler.org/hardware/channels/meters/power/edl-ehz/emh-ehz-h1
            ParseFirstTransactionId();
            ParseSeverId();
            CheckFirstCRC();
            ParseSecondTransactionId();
            ParseSecondServerId();

            byte[] sekundenIndex = ActSensorTime.Parse(_smlMessage, ref _position);
            CompanyName = CompanyInfo.Parse(_smlMessage, ref _position);
            Device      = DeviceId.Parse(_smlMessage, ref _position);

            ConsumedEnergy1_Wh = ConsumedEnergy.Parse(_smlMessage, ref _position);
            ProducedEnergy1_Wh = ProducedEnergy.Parse(_smlMessage, ref _position);

            byte[] seqConsumedEnergy = { 0x77, 0x07, 0x01, 0x00, 0x01, 0x08, 0x01, 0xFF, 0x01, 0x01 };
            byte[] seqProducedEnergy = { 0x77, 0x07, 0x01, 0x00, 0x02, 0x08, 0x01, 0xFF, 0x01, 0x01 };

            ConsumedEnergy2_Wh = Energy.Parse(_smlMessage, ref _position, seqConsumedEnergy);
            ProducedEnergy2_Wh = Energy.Parse(_smlMessage, ref _position, seqProducedEnergy);

            byte[] sequence3 = { 0x77, 0x07, 0x01, 0x00, 0x01, 0x08, 0x02, 0xFF, 0x01, 0x01 };
            byte[] sequence4 = { 0x77, 0x07, 0x01, 0x00, 0x02, 0x08, 0x02, 0xFF, 0x01, 0x01 };
            //double test3 = Energy.Parse(_smlMessage, ref _position, sequence3);
            //double test4 = Energy.Parse(_smlMessage, ref _position, sequence4);
            _isValid = true;
        }
        public virtual bool TryGetDeviceInfos(DeviceId deviceId, out DeviceInfo deviceInfo)
        {
            try
            {
                var res = _deviceInfos.TryGetValue(deviceId, out deviceInfo);

                if (res && deviceInfo?.FcmToken != null)
                {
                    return(true);
                }

                var devices  = "devices";
                var dirname  = Path.Combine(Directory.GetCurrentDirectory(), devices);
                var filename = Path.Combine(dirname, deviceId.FullId);
                var lines    = File.ReadAllLines(filename);

                if (lines != null && lines.Length > 0)
                {
                    var jsonString = string.Join("", lines);
                    deviceInfo = JsonConvert.DeserializeObject <DeviceInfo>(jsonString, new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    });

                    return(true);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
            }

            deviceInfo = null;
            return(false);
        }
Ejemplo n.º 22
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((DeviceId != null ? DeviceId.GetHashCode() : 0) * 397) ^ (Name != null ? Name.GetHashCode() : 0));
     }
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Returns the unique device identificator
        /// </summary>
        internal async Task <string> GetDeviceId()
        {
            try
            {
                if (deviceId != null)
                {
                    return(deviceId);
                }

                await LoadDeviceIDFromStorage();

                if (deviceId == null)
                {
                    DeviceId dId = ComputeDeviceID();
                    deviceId     = dId.deviceId;
                    usedIdMethod = dId.deviceIdMethod;

                    await SaveDeviceIDToStorage();
                }

                return(deviceId);
            }
            catch
            {
                //todo log
                return(String.Empty);
            }
        }
Ejemplo n.º 24
0
        public IActionResult GetTab(
            [FromRoute, Required] string device,
            [FromRoute, Required] string tab,
            [FromQuery] PaginationRequestDto paginationDto,
            [FromQuery] SortRequestDto sortDto,
            [FromQuery] AdvancedFilterRequestDto filterRequestDto)
        {
            try
            {
                var deviceId   = new DeviceId(device);
                var filter     = AdvancedFilterRequestDto.ParseFilterRequest(filterRequestDto);
                var pagination = PaginationRequestDto.MapPaginationRequest(paginationDto);
                var sort       = SortRequestDto.MapSortRequest(sortDto);

                var tabEntries = _DataModel.GetTab(deviceId, tab, pagination, sort, filter);

                return(Json(tabEntries));
            }
            catch (UnknownDeviceIdException e)
            {
                Logger.LogError("Exception while execution:", e);
                return(FormattedNotFound($"Device id not found."));
            }
            catch (UnknownKeyException e)
            {
                Logger.LogError("Exception while execution:", e);
                return(FormattedNotFound($"Key not found."));
            }
            catch (Exception e)
            {
                Logger.LogError("Exception while execution:", e);
                return(FormattedInternalServerError($"{nameof(e)} {e.Message}"));
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (DeviceId != null)
         {
             hashCode = hashCode * 59 + DeviceId.GetHashCode();
         }
         if (DeviceType != null)
         {
             hashCode = hashCode * 59 + DeviceType.GetHashCode();
         }
         if (Zone != null)
         {
             hashCode = hashCode * 59 + Zone.GetHashCode();
         }
         return(hashCode);
     }
 }
Ejemplo n.º 26
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Uid.Length != 0)
            {
                hash ^= Uid.GetHashCode();
            }
            if (DeviceId.Length != 0)
            {
                hash ^= DeviceId.GetHashCode();
            }
            if (Type != 0)
            {
                hash ^= Type.GetHashCode();
            }
            if (Msg.Length != 0)
            {
                hash ^= Msg.GetHashCode();
            }
            if (Time != 0L)
            {
                hash ^= Time.GetHashCode();
            }
            if (App.Length != 0)
            {
                hash ^= App.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 27
0
        public DbUserLogin GetUser(DeviceId deviceId)
        {
            string value = deviceId.Value;
            var    query = Query <DbUserLogin> .EQ(user => user.deviceId, value);

            return(UserLogins.FindOne(query));
        }
Ejemplo n.º 28
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is TerminalRefund other &&
                   ((Id == null && other.Id == null) || (Id?.Equals(other.Id) == true)) &&
                   ((RefundId == null && other.RefundId == null) || (RefundId?.Equals(other.RefundId) == true)) &&
                   ((PaymentId == null && other.PaymentId == null) || (PaymentId?.Equals(other.PaymentId) == true)) &&
                   ((OrderId == null && other.OrderId == null) || (OrderId?.Equals(other.OrderId) == true)) &&
                   ((AmountMoney == null && other.AmountMoney == null) || (AmountMoney?.Equals(other.AmountMoney) == true)) &&
                   ((Reason == null && other.Reason == null) || (Reason?.Equals(other.Reason) == true)) &&
                   ((DeviceId == null && other.DeviceId == null) || (DeviceId?.Equals(other.DeviceId) == true)) &&
                   ((DeadlineDuration == null && other.DeadlineDuration == null) || (DeadlineDuration?.Equals(other.DeadlineDuration) == true)) &&
                   ((Status == null && other.Status == null) || (Status?.Equals(other.Status) == true)) &&
                   ((CancelReason == null && other.CancelReason == null) || (CancelReason?.Equals(other.CancelReason) == true)) &&
                   ((CreatedAt == null && other.CreatedAt == null) || (CreatedAt?.Equals(other.CreatedAt) == true)) &&
                   ((UpdatedAt == null && other.UpdatedAt == null) || (UpdatedAt?.Equals(other.UpdatedAt) == true)));
        }
Ejemplo n.º 29
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (DeviceId != 0)
            {
                hash ^= DeviceId.GetHashCode();
            }
            if (ResourceId != 0)
            {
                hash ^= ResourceId.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (TimestampPs != 0UL)
            {
                hash ^= TimestampPs.GetHashCode();
            }
            if (DurationPs != 0UL)
            {
                hash ^= DurationPs.GetHashCode();
            }
            hash ^= Args.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 30
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Topic.Length != 0)
            {
                hash ^= Topic.GetHashCode();
            }
            if (MessageFormat.Length != 0)
            {
                hash ^= MessageFormat.GetHashCode();
            }
            if (IoType != global::Ubii.Devices.Component.Types.IOType.Publisher)
            {
                hash ^= IoType.GetHashCode();
            }
            if (DeviceId.Length != 0)
            {
                hash ^= DeviceId.GetHashCode();
            }
            hash ^= tags_.GetHashCode();
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 31
0
        public HSPE16InputOnly(DeviceId id, I2CSlaveAddress address, II2CBusService i2cBus)
            : base(id, new MAX7311Driver(address, i2cBus))
        {
            byte[] setupAsInputs = { 0x06, 0xFF, 0xFF };
            i2cBus.Execute(address, b => b.Write(setupAsInputs));

            FetchState();
        }
Ejemplo n.º 32
0
 internal DeviceBase(Plm plm, DeviceId deviceId, 
     byte deviceCategory, byte deviceSubcategory)
 {
     this.plm = plm;
     this.deviceId = deviceId;
     this.DeviceCategoryCode = deviceCategory;
     this.DeviceSubcategoryCode = deviceSubcategory;
 }
Ejemplo n.º 33
0
 public HSREL5(DeviceId id, I2CSlaveAddress i2CAddress, II2CBusService bus)
     : base(id, new PCF8574Driver(i2CAddress, bus))
 {
     // Ensure that all relays are off by default. The first 5 ports are hardware inverted! The other ports are not inverted but the
     // connected relays are inverted.
     SetState(new byte[] { 0xFF });
     CommitChanges(true);
 }
Ejemplo n.º 34
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Device"/> class.
        /// </summary>
        /// <param name="id">
        /// The id of the device.
        /// </param>
        protected Device(DeviceId id)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            Id = id;
        }
Ejemplo n.º 35
0
        public void ShouldNotFindDeviceByIdWhenNoDevicesAreRegistered(
            Devices devices,
             DeviceId anyDeviceId)
        {
            Device notFoundDevice = null;

            devices.FindDeviceById(anyDeviceId, out notFoundDevice).ShouldBeFalse();
            notFoundDevice.ShouldBeNull();
        }
Ejemplo n.º 36
0
        public void ShouldNotFindDeviceByIdWhenDeviceIsNotRegistered(
            Devices devices,
            Microphone aDevice,
            DeviceId anyDeviceId)
        {
            devices.RegisterNewDevice(aDevice);
            Device notFoundDevice = null;

            devices.FindDeviceById(anyDeviceId, out notFoundDevice).ShouldBeFalse();
            notFoundDevice.ShouldBeNull();
        }
Ejemplo n.º 37
0
        public bool Tick(out DeviceId wake)
        {
            _tickCount++;
            if (_sleepRegister.TryGetValue(_tickCount, out wake))
            {
                _sleepRegister.Remove(_tickCount);
                return true;
            }

            return false;
        }
Ejemplo n.º 38
0
        protected CCToolsBoardBase(DeviceId id, IPortExpanderDriver portExpanderDriver)
        {
            if (id == null) throw new ArgumentNullException(nameof(id));
            if (portExpanderDriver == null) throw new ArgumentNullException(nameof(portExpanderDriver));

            Id = id;
            _portExpanderDriver = portExpanderDriver;

            _committedState = new byte[portExpanderDriver.StateSize];
            _state = new byte[portExpanderDriver.StateSize];
        }
Ejemplo n.º 39
0
        public void Test_Equality()
        {
            var id_123456_1 = new DeviceId(0x12, 0x34, 0x56);
            var id_123456_2 = new DeviceId(0x12, 0x34, 0x56);
            var id_AABBCC = new DeviceId(0xAA, 0xBB, 0xCC);

            Assert.AreEqual(id_123456_1, id_123456_2);
            Assert.AreNotEqual(id_123456_1, id_AABBCC);
            Assert.AreNotEqual(null, id_AABBCC);
            Assert.AreNotEqual(3.14, id_AABBCC);
            Assert.AreNotEqual(id_123456_1.ToString(), id_AABBCC);
            Assert.IsTrue(id_123456_1 == id_123456_2);
            Assert.IsFalse(id_123456_1 == id_AABBCC);
            Assert.IsFalse(id_123456_1 != id_123456_2);
            Assert.IsTrue(id_123456_1 != id_AABBCC);
        }
Ejemplo n.º 40
0
 public void Can_connect_to_device_by_Id()
 {
     DeviceId peerId = new DeviceId(
         TestDeviceHelper.PEER_ID_HI,
         TestDeviceHelper.PEER_ID_MI,
         TestDeviceHelper.PEER_ID_LO);
     // can get using an existing DeviceId
     testGettingDevice(test =>
     {
         DeviceBase result;
         Assert.IsTrue(test.TryConnectToDevice(peerId, out result));
         Assert.IsNotNull(result);
         return result;
     });
     // convenience method: can get device using a string
     testGettingDevice(test =>
     {
         DeviceBase result;
         Assert.IsTrue(test.TryConnectToDevice(TestDeviceHelper.PEER_ID_STRING, out result));
         Assert.IsNotNull(result);
         return result;
     });
 }
Ejemplo n.º 41
0
        public void Can_create_from_id_string()
        {
            const string ID1 = "12.34.56";
            const string ID2 = "AA.BB.Cc";
            var id_123456 = new DeviceId(ID1);
            var id_AABBCC = new DeviceId(ID2);

            Assert.AreEqual(0x12, id_123456.IdHi);
            Assert.AreEqual(0x34, id_123456.IdMiddle);
            Assert.AreEqual(0x56, id_123456.IdLo);
            Assert.AreEqual(ID1.ToUpper(), id_123456.ToString());

            Assert.AreEqual(0xAA, id_AABBCC.IdHi);
            Assert.AreEqual(0xBB, id_AABBCC.IdMiddle);
            Assert.AreEqual(0xCC, id_AABBCC.IdLo);
            Assert.AreEqual(ID2.ToUpper(), id_AABBCC.ToString());

            Assert.Throws<ArgumentNullException>(() => { var id = new DeviceId((string)null); });
            Assert.Throws<ArgumentOutOfRangeException>(() => { var id = new DeviceId("12;34.56"); });
            Assert.Throws<ArgumentOutOfRangeException>(() => { var id = new DeviceId("12.34;56"); });
            Assert.Throws<ArgumentOutOfRangeException>(() => { var id = new DeviceId("12.34.5"); });
            Assert.Throws<ArgumentOutOfRangeException>(() => { var id = new DeviceId("12.34.5G"); });
        }
 internal HomeEntertainmentControl(Plm plm, DeviceId deviceId,
     byte deviceCategory, byte deviceSubcategory)
     : base(plm, deviceId, deviceCategory, deviceSubcategory)
 {
 }
Ejemplo n.º 43
0
 public Lock(DeviceId deviceId)
 {
     Handle = deviceId;
 }
Ejemplo n.º 44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VideoCamera"/> class.
 /// </summary>
 /// <param name="id">
 /// The id of the video camera device.
 /// </param>
 public VideoCamera(DeviceId id)
     : base(id)
 {
 }
 internal CommunicationControl(Plm plm, DeviceId deviceId,
     byte deviceCategory, byte deviceSubcategory)
     : base(plm, deviceId, deviceCategory, deviceSubcategory)
 {
 }
Ejemplo n.º 46
0
 public HSPE8InputOnly(DeviceId id, I2CSlaveAddress address, II2CBusService bus)
     : base(id, new PCF8574Driver(address, bus))
 {
     FetchState();
 }
 internal PoolAndSpaControl(Plm plm, DeviceId deviceId,
     byte deviceCategory, byte deviceSubcategory)
     : base(plm, deviceId, deviceCategory, deviceSubcategory)
 {
 }
 internal ClimateControl(Plm plm, DeviceId deviceId,
     byte deviceCategory, byte deviceSubcategory)
     : base(plm, deviceId, deviceCategory, deviceSubcategory)
 {
 }
Ejemplo n.º 49
0
 public HSPE16OutputOnly(DeviceId id, I2CSlaveAddress address, II2CBusService i2cBus)
     : base(id, new MAX7311Driver(address, i2cBus))
 {
     CommitChanges(true);
 }
 internal SecurityHealthOrSafetyControl(Plm plm, DeviceId deviceId,
     byte deviceCategory, byte deviceSubcategory)
     : base(plm, deviceId, deviceCategory, deviceSubcategory)
 {
 }
 internal BuiltInApplianceControl(Plm plm, DeviceId deviceId,
     byte deviceCategory, byte deviceSubcategory)
     : base(plm, deviceId, deviceCategory, deviceSubcategory)
 {
 }
 private StandardMessageReceivedArgs buildWithFlags(byte flags)
 {
     var deviceId = new DeviceId(0x10, 0x20, 0x30);
     return new StandardMessageReceivedArgs(deviceId, 0, flags, 0x11, 0x00);
 }
Ejemplo n.º 53
0
 public HSRT16(DeviceId id, I2CSlaveAddress address, II2CBusService i2CBus)
     : base(id, new MAX7311Driver(address, i2CBus))
 {
     SetState(new byte[] { 0x00, 0x00 });
     CommitChanges(true);
 }
 internal EnergyManagement(Plm plm, DeviceId deviceId,
     byte deviceCategory, byte deviceSubcategory)
     : base(plm, deviceId, deviceCategory, deviceSubcategory)
 {
 }
 internal NetworkBridge(Plm plm, DeviceId deviceId,
     byte deviceCategory, byte deviceSubcategory)
     : base(plm, deviceId, deviceCategory, deviceSubcategory)
 {
 }
Ejemplo n.º 56
0
 internal Toy(Plm plm, DeviceId deviceId,
     byte deviceCategory, byte deviceSubcategory)
     : base(plm, deviceId, deviceCategory, deviceSubcategory)
 {
 }
 internal DimmableLightingControl(Plm plm, DeviceId deviceId,
     byte deviceCategory, byte deviceSubcategory)
     : base(plm, deviceId, deviceCategory, deviceSubcategory)
 {
 }
 public CCToolsInputBoardBase(DeviceId id, IPortExpanderDriver portExpanderDriver)
     : base(id, portExpanderDriver)
 {
 }
 private StandardMessageReceivedArgs buildObjectForTest(byte group, byte flags, byte command1, byte command2)
 {
     var deviceId = new DeviceId(0x10, 0x20, 0x30);
     return new StandardMessageReceivedArgs(deviceId, group, flags, command1, command2);
 }
Ejemplo n.º 60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Microphone"/> class.
 /// </summary>
 /// <param name="id">
 /// The id of the microphone.
 /// </param>
 public Microphone(DeviceId id)
     : base(id)
 {
 }