Esempio n. 1
0
        public override void DirectVMNotify()
        {
            if (CraneInfo != null && PLC_Status != null)
            {
                CraneInfo.Name             = Name;
                CraneInfo.NumCommands      = PLC_Status.NumCommands;
                CraneInfo.Command_ID       = PLC_Status.Command_ID;
                CraneInfo.BufferCommand_ID = PLC_Status.BufferCommand_ID;
                CraneInfo.LPosition        = PLC_Status.LPosition;
                CraneInfo.FPosition        = PLC_Status.FPosition;
                CraneInfo.StateMachine     = PLC_Status.StateMachine;
                CraneInfo.Palette          = PLC_Status.Palette;
                CraneInfo.AlarmID          = PLC_Status.AlarmID;
                CraneInfo.Fault            = PLC_Status.Fault;
                CraneInfo.SetAlarms(PLC_Status.CurrentAlarms, Warehouse);
                CraneInfo.SetSensors(PLC_Status.Status);
                CraneInfo.Status      = PLC_Status.Status;
                CraneInfo.LastCommand = Command != null?Command.ToSmallString() : "";

                CraneInfo.LastBufferCommand = BufferCommand != null?BufferCommand.ToSmallString() : "";

                CraneInfo.Palette = Place != null ? new Palette {
                    Barcode = (uint)Place.Material
                } : null;
                CraneInfo.Online = Online();
                CallNotifyVM(CraneInfo);
            }
        }
Esempio n. 2
0
 public override void InitialNotify(Telegram t, uint material)
 {
     try
     {
         TelegramCraneTO tel = t as TelegramCraneTO;
         base.InitialNotify(t, material);
         if (tel.Buffer_ID != 0)
         {
             BufferCommand = Warehouse.DBService.FindSimpleCraneCommandByID(tel.Buffer_ID);
             if (BufferCommand == null)
             {
                 throw new CraneException(String.Format("Unknown BufferCommand ({0})", tel.Buffer_ID));
             }
             BufferCommand.Status = SimpleCommand.EnumStatus.InPlc;
             Warehouse.DBService.UpdateSimpleCommand(BufferCommand);
             Warehouse.AddEvent(Event.EnumSeverity.Event, Event.EnumType.Command, String.Format("{0} buffer command ({1}) in PLC", Name, BufferCommand != null ? BufferCommand.ToString() : "null"));
         }
         else if (BufferCommand != null)
         {
             BufferCommand.Reason = SimpleCommand.EnumReason.MFCS;
             BufferCommand.Status = SimpleCommand.EnumStatus.Canceled;
             Warehouse.DBService.UpdateSimpleCommand(BufferCommand);
             OnSimpleCommandFinish(BufferCommand);
             BufferCommand = null;
             Warehouse.AddEvent(Event.EnumSeverity.Event, Event.EnumType.Command, String.Format("{0} buffer command ({1}) not in PLC.", Name, BufferCommand != null ? BufferCommand.ToString() : "null"));
         }
         if (tel.MFCS_ID != 0)
         {
             Command = Warehouse.DBService.FindSimpleCraneCommandByID(tel.MFCS_ID);
             if (Command == null)
             {
                 throw new CraneException(String.Format("Unknown Command ({0})", tel.Buffer_ID));
             }
             Command.Status = SimpleCommand.EnumStatus.InPlc;
             Warehouse.DBService.UpdateSimpleCommand(Command);
             Warehouse.AddEvent(Event.EnumSeverity.Event, Event.EnumType.Command, String.Format("{0} Command ({1}) in PLC", Name, Command != null ? Command.ToString() : "null"));
         }
         else if (Command != null)
         {
             Command.Reason = SimpleCommand.EnumReason.MFCS;
             Command.Status = SimpleCommand.EnumStatus.Canceled;
             Warehouse.DBService.UpdateSimpleCommand(Command);
             OnSimpleCommandFinish(Command);
             Warehouse.AddEvent(Event.EnumSeverity.Event, Event.EnumType.Command, String.Format("{0} Command ({1}) not in PLC", Name, Command != null ? Command.ToString() : "null"));
             Command = null;
         }
     }
     catch (Exception ex)
     {
         Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, ex.Message);
         throw new CraneException(String.Format("{0} Crane.InitialNotify failed ({1},{2})", Name, t is TelegramCraneTO ? (t as TelegramCraneTO).MFCS_ID : 0, material));
     }
 }
Esempio n. 3
0
        public void OnTelegramCraneTO(Telegram t)
        {
            try
            {
                TelegramCraneTO tel = t as TelegramCraneTO;
                Command_Status = tel;

                // check if material exists
                if (tel.Order != TelegramCraneTO.ORDER_DELETEPALETTE)
                {
                    CreateOrUpdateMaterialID(tel.Palette);
                }

                // check if this is move command
                if (tel.Order < 50)
                {
                    if (tel.Confirmation == TelegramCraneTO.CONFIRMATION_INITIALNOTIFY)
                    {
                        InitialNotify(t, tel.Palette.Barcode);
                    }
                    else if (Command != null && Command.ID == tel.MFCS_ID)
                    {
                        WorkCommand(tel, Command, false);
                    }
                    else if (BufferCommand != null && BufferCommand.ID == tel.MFCS_ID)
                    {
                        // without confirmation of Command
                        Command       = BufferCommand;
                        BufferCommand = null;
                        Warehouse.AddEvent(Event.EnumSeverity.Event, Event.EnumType.Program, String.Format("{0} goes from buffer directly in execution", Command.ToString()));
                        WorkCommand(tel, Command, false);
                    }
                    else
                    {
                        Command = Warehouse.DBService.FindSimpleCraneCommandByID(tel.MFCS_ID);
                        if (Command == null)
                        {
                            throw new CraneException(String.Format("Crane.OnTelegramCraneTO {0}, tel.MFCS ({1}) does not match any move active command.", Name, tel.MFCS_ID));
                        }
                        Warehouse.AddEvent(Event.EnumSeverity.Event, Event.EnumType.Program, String.Format("{0} goes from database directly in execution", Command.ToString()));
                        WorkCommand(tel, Command, false);
                    }
                }
                else
                {
                    // fast command
                    if (Command_Status.MFCS_ID != 0 && (FastCommand == null || FastCommand.ID != Command_Status.MFCS_ID))
                    {
                        FastCommand = Warehouse.DBService.FindSimpleCraneCommandByID(tel.MFCS_ID);
                    }

                    if ((FastCommand != null) && (FastCommand.ID == tel.MFCS_ID))
                    {
                        WorkCommand(tel, FastCommand, true);
                    }
                    else
                    {
                        Warehouse.SteeringCommands.Run = false;
                        throw new CraneException(String.Format("Crane.OnTelegramCraneTO {0}, tel.MFCS ({1}) does not match any fast active command.", Name, tel.MFCS_ID));
                    }
                }
                OnStrategy?.Invoke();
                if (Command != null && CraneInfo != null)
                {
                    CraneInfo.LastCommand = Command.ToSmallString();
                }
                if (BufferCommand != null && CraneInfo != null)
                {
                    CraneInfo.LastBufferCommand = BufferCommand.ToString();
                }
                DirectVMNotify();
            }
            catch (Exception e)
            {
                Warehouse.SteeringCommands.Run = false;
                Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, e.Message);
                Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, String.Format("{0} OnTelegramCraneTO failed.", Name));
            }
        }