public void AutomaticOff() { Communicator.AddSendTelegram( new Telegrams.TelegramCraneStatus { MFCS_ID = 0, Sender = PLC_ID, Order = TelegramCraneStatus.ORDER_AUTOMATICOFF }); }
private void Startup() { Communicator.AddSendTelegram( new Telegrams.TelegramCraneStatus { Sender = PLC_ID, MFCS_ID = 0, Order = TelegramCraneStatus.ORDER_SYSTEMQUERY }); }
public override void LongTermBlockOff(Int32 id) { Communicator.AddSendTelegram(new TelegramTransportStatus { MFCS_ID = id, SegmentID = (short)PLC_ID, Sender = Communicator.MFCS_ID, Receiver = Communicator.PLC_ID, Order = TelegramTransportStatus.ORDER_LONGTERMBLOCKOFF }); Warehouse.AddEvent(Database.Event.EnumSeverity.Event, Database.Event.EnumType.Program, String.Format("Segment {0} LongTermBlockOff called.", Name)); }
public override void Info(Int32 id) { Communicator.AddSendTelegram(new TelegramCraneStatus { MFCS_ID = id, ID = (short)PLC_ID, Sender = Communicator.MFCS_ID, Receiver = Communicator.PLC_ID, Order = TelegramTransportStatus.ORDER_INFO }); Warehouse.AddEvent(Database.Event.EnumSeverity.Event, Database.Event.EnumType.Program, String.Format("Segment {0} refresh called.", Name)); }
public override void AutomaticOn(Int32 id) { Communicator.AddSendTelegram(new TelegramTransportStatus { MFCS_ID = id, SegmentID = (short)PLC_ID, Sender = Communicator.MFCS_ID, Receiver = Communicator.PLC_ID, Order = TelegramTransportStatus.ORDER_AUTOON }); Warehouse.AddEvent(Database.Event.EnumSeverity.Event, Database.Event.EnumType.Program, String.Format("Segment {0} AutomaticOn called.", Name)); }
public void CancelCommand() { if (Command != null) { Communicator.AddSendTelegram( new TelegramCraneTO { MFCS_ID = 0, Sender = PLC_ID, Order = TelegramCraneTO.ORDER_CANCEL }); } }
public override void SetClock(Int32 id) { Communicator.AddSendTelegram(new TelegramTransportSetTime { MFCS_ID = id, Sender = Communicator.MFCS_ID, Receiver = Communicator.PLC_ID, PLCSetTime = new PLCSetTime { Year = (short)DateTime.Now.Year, Day = (short)DateTime.Now.Day, Hour = (short)DateTime.Now.Hour, Month = (short)DateTime.Now.Month, Minute = (short)DateTime.Now.Minute, Seconds = (short)DateTime.Now.Second }, Order = TelegramTransportSetTime.ORDER_SETDATETIME }); Warehouse.AddEvent(Database.Event.EnumSeverity.Event, Database.Event.EnumType.Program, String.Format("Segment {0} SetTime called.", Name)); }
public void CancelAllCranes(int id) { foreach (Crane c in SegmentCranes) { Communicator.AddSendTelegram(new TelegramCraneTO { MFCS_ID = id++, ID = (short)PLC_ID, Sender = Communicator.MFCS_ID, Receiver = Communicator.PLC_ID, Order = TelegramCraneTO.ORDER_CANCEL, }); Warehouse.AddEvent(Database.Event.EnumSeverity.Event, Database.Event.EnumType.Program, $"Blind command cancel for {c.Name}"); } }
public override void LongTermBlockOff(Int32 id) { Communicator.AddSendTelegram(new TelegramCraneStatus { MFCS_ID = id, ID = (short)PLC_ID, Sender = Communicator.MFCS_ID, Receiver = Communicator.PLC_ID, Order = TelegramTransportStatus.ORDER_LONGTERMBLOCKOFF }); SegmentInfo.ActiveAlarms.ForEach(aa => Warehouse.DBService.UpdateAlarm(Name, aa.ToString(), Alarm.EnumAlarmStatus.Ack)); foreach (var c in SegmentCranes) { c.CraneInfo.ActiveAlarms.ForEach(aa => Warehouse.DBService.UpdateAlarm(c.Name, aa.ToString(), Alarm.EnumAlarmStatus.Ack)); } Warehouse.AddEvent(Database.Event.EnumSeverity.Event, Database.Event.EnumType.Program, String.Format("Segment {0} LongTermBlockOff called.", Name)); }
public override void Reset(Int32 id) { Communicator.AddSendTelegram(new TelegramTransportStatus { MFCS_ID = id, SegmentID = (short)PLC_ID, Sender = Communicator.MFCS_ID, Receiver = Communicator.PLC_ID, Order = TelegramTransportStatus.ORDER_RESET }); SegmentInfo.ActiveAlarms.ForEach(aa => Warehouse.DBService.UpdateAlarm(Name, aa.ToString(), Alarm.EnumAlarmStatus.Ack)); foreach (var c in SegmentConveyors) { c.ConveyorInfo.ActiveAlarms.ForEach(aa => Warehouse.DBService.UpdateAlarm(c.Name, aa.ToString(), Alarm.EnumAlarmStatus.Ack)); } Warehouse.AddEvent(Database.Event.EnumSeverity.Event, Database.Event.EnumType.Program, String.Format("Segment {0} reset called.", Name)); }
public override void SetClock(Int32 id) { Communicator.AddSendTelegram( new TelegramCraneStatus { MFCS_ID = id, ID = (short)PLC_ID, Sender = Communicator.MFCS_ID, Receiver = Communicator.PLC_ID, Order = TelegramCraneStatus.ORDER_SETDATETIME, LPosition = new Position { R = (short)DateTime.Now.Year, X = (short)DateTime.Now.Month, Y = (short)DateTime.Now.Day }, FPosition = new Position { R = (short)DateTime.Now.Hour, X = (short)DateTime.Now.Minute, Y = (short)DateTime.Now.Second } }); Warehouse.AddEvent(Database.Event.EnumSeverity.Event, Database.Event.EnumType.Program, String.Format("Segment {0} SetClock called.", Name)); }
private void AddCommandToPLC(SimpleCraneCommand cmd) { LPosition pos = LPosition.FromString(cmd.Source); if (!pos.IsWarehouse()) { if (cmd.Task == EnumSimpleCraneCommandTask.Pick) { pos = FindInTransport(cmd.Source).CraneAdress; } else if (cmd.Task == EnumSimpleCraneCommandTask.Drop) { pos = FindOutTransport(cmd.Source).CraneAdress; } else if (cmd.Task == EnumSimpleCraneCommandTask.Goto) { pos = FindInOutTransport(cmd.Source).CraneAdress; } } Communicator.AddSendTelegram( new Telegrams.TelegramCraneTO { Sender = PLC_ID, MFCS_ID = cmd.ID, Order = (short)cmd.Task, Position = new Telegrams.Position { R = (short)pos.Shelve, X = (short)pos.Travel, Y = (short)pos.Height, Z = (short)pos.Depth }, Palette = new Telegrams.Palette { Barcode = Convert.ToUInt32(cmd.Material) } }); using (var dc = new MFCSEntities()) { dc.SimpleCraneCommands.Attach(cmd); cmd.Status = EnumSimpleCraneCommandStatus.Written; dc.SaveChanges(); } }
public override void CreateAndSendTOTelegram(SimpleCommand cmd) { try { if (!(cmd is SimpleConveyorCommand)) { throw new ConveyorException(String.Format("{0} is not SimpleCoveyorCommand", cmd.ToString())); } SimpleConveyorCommand Cmd = cmd as SimpleConveyorCommand; MaterialID matID = Warehouse.DBService.FindMaterialID((int)cmd.Material, true); short task; switch (Cmd.Task) { case SimpleCommand.EnumTask.Move: task = TelegramTransportTO.ORDER_MOVE; break; case SimpleCommand.EnumTask.Delete: task = TelegramTransportTO.ORDER_PALETTEDELETE; break; case SimpleCommand.EnumTask.Create: task = TelegramTransportTO.ORDER_PALETTECREATE; break; case SimpleCommand.EnumTask.Cancel: throw new NotImplementedException(); default: throw new ConveyorException(String.Format("{0} has unknown Order", Cmd.ToString())); } if (Warehouse.Conveyor.ContainsKey(Cmd.Source)) { Communicator.AddSendTelegram(new TelegramTransportTO { MFCS_ID = Cmd.ID, Sender = Communicator.MFCS_ID, Receiver = Communicator.PLC_ID, Order = task, Palette = new Palette { Barcode = (UInt32)Cmd.Material, Type = (short)matID.Size, Weight = (ushort)matID.Weight }, SenderTransport = Warehouse.FindConveyorBasic(Cmd.Source).ConveyorAddress, Source = Warehouse.FindConveyorBasic(Cmd.Source).ConveyorAddress, Target = Warehouse.FindConveyorBasic(Cmd.Target).ConveyorAddress }); cmd.Status = SimpleCommand.EnumStatus.Written; Warehouse.DBService.UpdateSimpleCommand(cmd); Warehouse.AddEvent(Event.EnumSeverity.Event, Event.EnumType.Command, cmd.ToString()); if (cmd.Command_ID.HasValue) { Command command = Warehouse.DBService.FindCommandByID(cmd.Command_ID.Value); if (command == null) { throw new ConveyorException($"Command {command.ToString()} null."); } if (command.Status < Database.Command.EnumCommandStatus.Active) { command.Status = Database.Command.EnumCommandStatus.Active; Warehouse.DBService.UpdateCommand(command); Warehouse.OnCommandFinish?.Invoke(command); } } } } catch (Exception e) { Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, e.Message); throw new ConveyorException(String.Format("{0} Conveyor.CreateAndSendTOTelegram failed ({1}).", Name, cmd != null ? cmd.ToString() : "null")); } }
public override void CreateAndSendTOTelegram(SimpleCommand cmd) { try { if (!(cmd is SimpleCraneCommand)) { throw new CraneException(String.Format("{0} is not SimpleCraneCommand.", cmd.ToString())); } SimpleCraneCommand Cmd = cmd as SimpleCraneCommand; MaterialID matID = null; if (Cmd.Material.HasValue) { matID = Warehouse.DBService.FindMaterialID((int)Cmd.Material, true); } LPosition pos = LPosition.FromString(Cmd.Source); if (!pos.IsWarehouse()) { if (cmd.Task == SimpleCommand.EnumTask.Pick) { pos = FindInConveyor(cmd.Source).CraneAddress; } else if (cmd.Task == SimpleCommand.EnumTask.Drop) { pos = FindOutConveyor(cmd.Source).CraneAddress; } else if (cmd.Task == SimpleCommand.EnumTask.Move) { pos = FindInOutConveyor(cmd.Source).CraneAddress; } else if (cmd.Task == SimpleCommand.EnumTask.Cancel) { pos = CraneAddress; if (!cmd.CancelID.HasValue) { throw new CraneException(String.Format("{0} Parameter null", cmd != null ? cmd.ToString() : "null")); } } else if (cmd.Task >= SimpleCommand.EnumTask.Delete) { pos = CraneAddress; } } if (matID == null && cmd.Task != SimpleCommand.EnumTask.Move && cmd.Task != SimpleCommand.EnumTask.Cancel) { throw new CraneException(String.Format("Command validity fault ({0})", cmd.ToString())); } Communicator.AddSendTelegram( new Telegrams.TelegramCraneTO { Sender = Communicator.MFCS_ID, Receiver = Communicator.PLC_ID, MFCS_ID = cmd.ID, Order = (short)cmd.Task, Buffer_ID = (cmd.Task != SimpleCommand.EnumTask.Cancel) ? (matID != null ? matID.ID : 0) : cmd.CancelID.Value, Position = new Telegrams.Position { R = (short)pos.Shelve, X = (short)pos.Travel, Y = (short)pos.Height, Z = (short)pos.Depth }, Palette = new Telegrams.Palette { Barcode = Convert.ToUInt32(matID != null ? matID.ID : 0), Type = (Int16)(matID != null ? matID.Size : 0), Weight = (UInt16)(matID != null ? matID.Weight : 0) }, ID = PLC_ID }); cmd.Status = SimpleCommand.EnumStatus.Written; Warehouse.DBService.UpdateSimpleCommand(cmd); Warehouse.AddEvent(Event.EnumSeverity.Event, Event.EnumType.Command, cmd.ToString()); // check for blocked locations LPosition p = LPosition.FromString(cmd.Source); string frontLoc; if (p.Shelve > 0 && p.Depth == 2) { LPosition pOther = new LPosition { Shelve = p.Shelve, Travel = p.Travel, Height = p.Height, Depth = 1 }; frontLoc = pOther.ToString(); } else { frontLoc = cmd.Source; } if (Warehouse.DBService.FindPlaceID(cmd.Source) != null && (Warehouse.DBService.FindPlaceID(cmd.Source).Blocked || Warehouse.DBService.FindPlaceID(frontLoc).Blocked)) { Warehouse.Segment[Segment].AlarmRequest(0); Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Command, string.Format("Location blocked. Command: {0}", cmd.ToString())); } if (cmd.Command_ID.HasValue) { Command command = Warehouse.DBService.FindCommandByID(cmd.Command_ID.Value); if (command == null) { throw new ConveyorException($"Command {command.ToString()} null."); } if (command.Status < Database.Command.EnumCommandStatus.Active) { command.Status = Database.Command.EnumCommandStatus.Active; Warehouse.DBService.UpdateCommand(command); Warehouse.OnCommandFinish?.Invoke(command); } } } catch (Exception ex) { Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, ex.Message); throw new CraneException(String.Format("{0} Crane.CreateAndSendTOTelegram failed. ({1})", Name, cmd != null ? cmd.ToString() : "null")); } }