protected virtual void OnMessageReceivedInternal(MessageReceivedEventArgs e) { Match match = JablotronDeviceAddressRegex.Match(e.Message); string addressString = match.Groups["address"].Value; if (_jablotronDevices.ContainsKey(addressString)) { _jablotronDevices[addressString].OnMessageReceiverAsync(e.Message); } int deviceAddress = Convert.ToInt32(addressString); JablotronDevicType deviceType = JablotronDevice.GetDeviceType((byte)(deviceAddress / 65536)); bool lowBatteryNotification = e.Message.Contains(LowBatteryMessagePatern); bool tamperNotification = e.Message.Contains(TamperMessagePatern); if (lowBatteryNotification) { LowDeviceBatteryNotificationReceived?.Invoke(this, new LowDeviceBatteryNotificationEventArgs(deviceAddress, deviceType)); } if (tamperNotification) { DeviceTamperNotificationReceived?.Invoke(this, new DeviceTamperNotificationEventArgs(e.Message.Contains(ActActivePatern), deviceAddress, deviceType)); } }
public DeviceTamperNotificationEventArgs(bool isCircuitClosed, int deviceAddress, JablotronDevicType deviceType) : base(isCircuitClosed) { DeviceAddress = deviceAddress; DeviceType = deviceType; }
public LowDeviceBatteryNotificationEventArgs(int deviceAddress, JablotronDevicType deviceType) { DeviceAddress = deviceAddress; DeviceType = deviceType; }