// Metodo che aggiorna una zona interagibile quando la corrispondente zona del campo minato viene scoperta private void UpdateInteractableZone(object sender, ZoneEventArgs e) { if (e.Mined) { // si aggiorna lo stato della zona interagibile per indicare che la // corrispondente zona del campo minato è stata scoperta ed era minata _mainForm.SetInteractableZoneState(e.X, e.Y, InteractableZone.ZoneState.Exploded); // si riduce il numero di zone da contrassegnare come minate // aggiornando anche l'etichetta-contatore nel form di gioco UpdateMinesCounterLabel(--_zonesToFlag); } else { // si aggiorna lo stato della zona interagibile per indicare che la // corrispondente zona del campo minato è stata scoperta ed era sicura switch (e.AdjacentMines) { case 0: _mainForm.SetInteractableZoneState(e.X, e.Y, InteractableZone.ZoneState.Safe0); break; case 1: _mainForm.SetInteractableZoneState(e.X, e.Y, InteractableZone.ZoneState.Safe1); break; case 2: _mainForm.SetInteractableZoneState(e.X, e.Y, InteractableZone.ZoneState.Safe2); break; case 3: _mainForm.SetInteractableZoneState(e.X, e.Y, InteractableZone.ZoneState.Safe3); break; case 4: _mainForm.SetInteractableZoneState(e.X, e.Y, InteractableZone.ZoneState.Safe4); break; case 5: _mainForm.SetInteractableZoneState(e.X, e.Y, InteractableZone.ZoneState.Safe5); break; case 6: _mainForm.SetInteractableZoneState(e.X, e.Y, InteractableZone.ZoneState.Safe6); break; case 7: _mainForm.SetInteractableZoneState(e.X, e.Y, InteractableZone.ZoneState.Safe7); break; case 8: _mainForm.SetInteractableZoneState(e.X, e.Y, InteractableZone.ZoneState.Safe8); break; } } }
void mySwamp_ZoneChangeEvent(object sender, ZoneEventArgs args) { int e = args.EventId; Zone z = args.Zone; // Crestron.SimplSharpPro.AudioDistribution.Swamp.AllZonesDoorbellAudioOnFeedbackEventId? // EventIds are in Crestron.SimplSharpPro.AudioDistribution.ZoneEventIds if (e == ZoneEventIds.SourceFeedbackEventId) { // Source Changed? } else if (e == ZoneEventIds.DoorbellEnableFeedbackEventId) { // Doorbell enable } }
private async void GridZoneExited(object sender, ZoneEventArgs args) { Zone zone = _zones.Find(z => z.Id == args.GridBlock.ZoneId); var telemetryDataPoint = new ZoneDataPoint { DeviceId = zone.IoTDeviceInfo.DeviceId, Name = args.SimObject.Name, Type = "zone", Grid_x = args.GridBlock.Location.Rowx, Grid_y = args.GridBlock.Location.Columny, Operation = "zone_exited", InZone = args.GridBlock.IsZone, ZoneId = args.GridBlock.ZoneId, ZoneGrid_x = args.GridBlock.Location.Rowx, ZoneGrid_y = args.GridBlock.Location.Columny, ZoneName = _zones.Find(z => z.Id == args.GridBlock.ZoneId).Name }; await SendIoTHubMessage(zone, telemetryDataPoint).ConfigureAwait(false); }
private async void GridZoneEntered(object sender, ZoneEventArgs args) { Zone zone = _zones.Find(z => z.Id == args.GridBlock.ZoneId); var telemetryDataPoint = new ZoneDataPoint { DeviceId = zone.IoTDeviceInfo.DeviceId, Name = args.SimObject.Name, Type = zone.Type, Grid_x = args.GridBlock.Location.Rowx, Grid_y = args.GridBlock.Location.Columny, Operation = "zone_entered", InZone = args.GridBlock.IsZone, ZoneId = args.GridBlock.ZoneId, ZoneGrid_x = args.GridBlock.Location.Rowx, ZoneGrid_y = args.GridBlock.Location.Columny, ZoneName = _zones.Find(z => z.Id == args.GridBlock.ZoneId).Name }; await SendIoTHubMessage(zone, telemetryDataPoint).ConfigureAwait(false); if (_appSettings.Value.SimulateButtonPushes) { var rand = new Random(); int c = rand.Next(1, 10); if (c % 2 == 0) { telemetryDataPoint.Operation = "button_pushed"; _logger.LogInformation("Sending button push message to hub"); await SendIoTHubMessage(zone, telemetryDataPoint).ConfigureAwait(false); } } }
void E4ZoneEvent(Object device, ZoneEventArgs args)//THIS NEEDS TESTING AND PROBABLY UPDATING { var ex = device as SwampE4; string deviceString = Convert.ToString(ex.ExpanderType); uint expNum = ex.Number; uint callingZone = (args.Zone.Number + (ushort)(expanderFirstZone[expNum - 1]) - 1); switch (args.EventId) { case ZoneEventIds.SourceFeedbackEventId: myEISC.UShortInput[args.Zone.Number + 39 + (ushort)(expanderFirstZone[expNum - 1])].UShortValue = args.Zone.Source.UShortValue; UItoZone.zoneCurrentSourceNumber[callingZone] = args.Zone.Source.UShortValue;//UPDATE ZONE STATUS break; case ZoneEventIds.StartupVolumeFeedbackEventId: UItoZone.zoneCurrentStartupVols[callingZone] = args.Zone.StartupVolumeFeedback.UShortValue; break; default: break; } }
void E8ZoneEvent(Object device, ZoneEventArgs args) { var ex = device as SwampE8; string deviceString = Convert.ToString(ex.ExpanderType); uint expNum = ex.Number; uint callingZone = (args.Zone.Number + (ushort)(expanderFirstZone[expNum - 1]) - 1); switch (args.EventId) { case ZoneEventIds.SourceFeedbackEventId: myEISC.UShortInput[callingZone + 40].UShortValue = args.Zone.Source.UShortValue; UItoZone.zoneCurrentSourceNumber[callingZone] = args.Zone.Source.UShortValue;//UPDATE ZONE STATUS UItoZone.zoneCurrentSourceText[callingZone] = sourceNameArray[args.Zone.Source.UShortValue]; if (args.Zone.Source.UShortValue == 0) { UItoZone.zoneCurrentOnOffStatus[callingZone] = false; } else UItoZone.zoneCurrentOnOffStatus[callingZone] = true; updateUI(callingZone, "sources"); updateUI(callingZone, "onOffStatus"); break; case ZoneEventIds.VolumeFeedbackEventId: myEISC.UShortInput[callingZone + 100].UShortValue = args.Zone.VolumeFeedback.UShortValue; UItoZone.zoneCurrentVolumes[callingZone] = args.Zone.VolumeFeedback.UShortValue; updateUI(callingZone, "volumes"); break; case ZoneEventIds.MuteOnFeedbackEventId: UItoZone.zoneCurrentMuteStatus[callingZone] = args.Zone.MuteOnFeedback.BoolValue; updateUI(callingZone, "muteStatus"); break; case ZoneEventIds.StartupVolumeFeedbackEventId: UItoZone.zoneCurrentStartupVols[callingZone] = args.Zone.StartupVolumeFeedback.UShortValue; decimal vol = args.Zone.StartupVolumeFeedback.UShortValue; CrestronConsole.PrintLine("startupVolFB {0} {1:P} ", callingZone, vol / 65535); break; default: break; } }
void SwampZoneEvent(Object device, ZoneEventArgs args) { switch (args.EventId) { case ZoneEventIds.SourceFeedbackEventId: myEISC.UShortInput[args.Zone.Number + 40].UShortValue = args.Zone.Source.UShortValue;//UPDATE XSIG UItoZone.zoneCurrentSourceNumber[args.Zone.Number] = args.Zone.Source.UShortValue;//UPDATE ZONE STATUS UItoZone.zoneCurrentSourceText[args.Zone.Number] = sourceNameArray[args.Zone.SourceFeedback.UShortValue];//UPDATE SOURCE TEXT if (args.Zone.SourceFeedback.UShortValue == 0) { UItoZone.zoneCurrentOnOffStatus[args.Zone.Number] = false;//ZONE IS OFF } else { UItoZone.zoneCurrentOnOffStatus[args.Zone.Number] = true;//ZONE IS ON } updateUI(args.Zone.Number, "sources"); updateUI(args.Zone.Number, "onOffStatus"); break; case ZoneEventIds.VolumeFeedbackEventId: myEISC.UShortInput[args.Zone.Number + 100].UShortValue = args.Zone.VolumeFeedback.UShortValue; UItoZone.zoneCurrentVolumes[args.Zone.Number] = args.Zone.VolumeFeedback.UShortValue; updateUI(args.Zone.Number, "volumes"); break; case ZoneEventIds.MuteOnFeedbackEventId: UItoZone.zoneCurrentMuteStatus[args.Zone.Number] = args.Zone.MuteOnFeedback.BoolValue; updateUI(args.Zone.Number, "muteStatus"); break; case ZoneEventIds.StartupVolumeFeedbackEventId: UItoZone.zoneCurrentStartupVols[args.Zone.Number] = args.Zone.StartupVolumeFeedback.UShortValue; decimal vol = args.Zone.StartupVolumeFeedback.UShortValue; CrestronConsole.PrintLine("startupVolFB {0} {1:P} ", args.Zone.Number, vol / 65535); break; case ZoneEventIds.OverCurrentFeedbackEventId: myEISC.StringInput[810].StringValue = "Over Current Zone " + args.Zone.Number; break; case ZoneEventIds.OverOrUnderVoltageFeedbackEventId: myEISC.StringInput[810].StringValue = "Over / Under Voltage " + args.Zone.Number; break; default: break; } }
protected virtual void OnZoneExited(ZoneEventArgs e) { ZoneExited?.Invoke(this, e); }
public async Task <GridBlock> MoveInDirection(SimObject simObject, MoveDirection direction) { GridBlock currentGridBlock, newGridBlock = null; int x, y = 0; lock (_blockLock) { currentGridBlock = _gridBlocks.Find(g => g.OccupierId == simObject.Id); y = currentGridBlock.Location.Columny; x = currentGridBlock.Location.Rowx; if (currentGridBlock.IsZone) { _logger.LogInformation("Zone {0} exited by {1}", currentGridBlock.Id, simObject.Id); ZoneEventArgs args = new ZoneEventArgs(); args.GridBlock = currentGridBlock; args.SimObject = simObject; OnZoneExited(args); } switch (direction) { case MoveDirection.Up: y = y + 1; if (y > _col_high) { throw new OffTheGridException(string.Format("Moving {0} UP to estimated location {1} will exceed the grid coordinates", simObject.Id, y)); } break; case MoveDirection.Down: y = y - 1; if (y < _col_low) { throw new OffTheGridException(string.Format("Moving {0} DOWN to estimated location {1} will exceed the grid coordinates", simObject.Id, y)); } break; case MoveDirection.Left: x = x - 1; if (x < _row_low) { throw new OffTheGridException(string.Format("Moving {0} LEFT to estimated location {1} will exceed the grid coordinates", simObject.Id, x)); } break; case MoveDirection.Right: x = x + 1; if (x > _row_high) { throw new OffTheGridException(string.Format("Moving {0} RIGHT to estimated location {1} will exceed the grid coordinates", simObject.Id, x)); } break; default: break; } if (IsGridBlockOccupied(new Location { Columny = y, Rowx = x })) { throw new LocationOccupiedException(string.Format("Grid block already occupied at location x:{0}, y:{1} by {2}", x, y, currentGridBlock.OccupierId)); } //Get the new grid block newGridBlock = _gridBlocks.Find(g => g.Location.Columny == y && g.Location.Rowx == x); if (newGridBlock != null) { newGridBlock.OccupierId = simObject.Id; currentGridBlock.OccupierId = null; if (newGridBlock.IsZone) { _logger.LogInformation("Zone {0} entered by {1}", newGridBlock.ZoneId, simObject.Id); ZoneEventArgs args = new ZoneEventArgs(); args.GridBlock = newGridBlock; args.SimObject = simObject; OnZoneEntered(args); } } _logger.LogInformation("Moved sim {0} in direction: {1} to x: {2} and y {3}", simObject.Id, direction, x, y); } return(newGridBlock != null ? newGridBlock : null); }