private void HandleCoilEvent(object sender, CoilEventArgs coilEvent) { if (_coilAssignments.ContainsKey(coilEvent.Id)) { foreach (var(itemName, isHoldCoil, deviceName) in _coilAssignments[coilEvent.Id]) { if (deviceName != null && _coilDevices.ContainsKey(deviceName)) { _coilDevices[deviceName].Coil(itemName).OnCoil(coilEvent.IsEnabled, isHoldCoil); } else if (_coils.ContainsKey(itemName)) { _coils[itemName].OnCoil(coilEvent.IsEnabled, isHoldCoil); } else { Logger.Warn($"Cannot trigger unknown coil item {itemName}."); } } } else { var what = coilEvent.IsEnabled ? "turn on" : "turn off"; Logger.Warn($"Should {what} unassigned coil {coilEvent.Id}."); } }
private void DebugPrintCoil(object sender, CoilEventArgs e) { Logger.Info("Coil {0} set to {1}.", e.Id, e.IsEnabled); }