Exemple #1
0
 // make all nceseary changes after drop command
 public void Drop(UInt32 material, string target)
 {
     try
     {
         LPosition pos = LPosition.FromString(target);
         if (pos.IsWarehouse())
         {
             Warehouse.DBService.MaterialMove((int)material, Name, target);
             Warehouse.OnMaterialMove?.Invoke(new Place {
                 Material = (int)material, Place1 = target
             }, EnumMovementTask.Move);
             Place = null;
         }
         else
         {
             ConveyorBasic cIO = FindOutConveyor(target) as ConveyorBasic;
             Move(material, this, cIO); // this will be done automatically
         }
     }
     catch (Exception ex)
     {
         Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, ex.Message);
         throw new CraneException(String.Format("{0} Crane.Drop failed ({1},{2})", Name, material, target));
     }
 }
Exemple #2
0
        public void ProcesMaterialNotify(TelegramTransportTO tel)
        {
            try
            {
                // update materialID
                if (tel.Confirmation != TelegramTransportTO.CONFIRMATION_PALETTETAKEN && tel.Confirmation != TelegramTransportTO.CONFIRMATION_PALETTEDELETED)
                {
                    // TAI specific: change hc to 2 if we can store to higher rack
                    if (tel.SenderTransport == 100 && Warehouse.DBService.IsRackSlotHC2Empty())
                    {
                        tel.Palette.Weight = (ushort)(20000 + tel.Palette.Weight % 10000);
                    }
                    CreateOrUpdateMaterialID(tel.Palette);
                }

                if (tel.Confirmation == TelegramTransportTO.CONFIRMATION_NOTIFY ||
                    tel.Confirmation == TelegramTransportTO.CONFIRMATION_DIMENSIONCHECKERROR)
                {
//                    Move(tel.Palette.Barcode, Warehouse.FindDeviceByPLC_ID(tel.Previous), this);
                    ConveyorBasic src = Warehouse.FindDeviceByPLC_ID(tel.Previous);
                    Move(tel.Palette.Barcode, src, this);
                }
                else if (tel.Confirmation == TelegramTransportTO.CONFIRMATION_INITIALNOTIFY)
                {
                    InitialNotify(tel, tel.Palette.Barcode);
                }
                else if (tel.Confirmation == TelegramTransportTO.CONFIRMATION_NEWPALETTE || tel.Confirmation == TelegramTransportTO.CONFIRMATION_PALETTECREATED)
                {
                    try
                    {
                        Place p = Warehouse.DBService.FindMaterial((int)tel.Palette.Barcode);
                        if (p != null)
                        {
                            Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Material,
                                               string.Format("Place {0}: pallet {1} exists in the system", p.Place1, tel.Palette.Barcode));
                        }
                        MaterialCreate(tel.Palette.Barcode);
                        FinishCommand(tel.MFCS_ID, Command, SimpleCommand.EnumStatus.Finished);
                    }
                    catch
                    {
                        Command.Reason = SimpleCommand.EnumReason.MFCS;
                        FinishCommand(tel.MFCS_ID, Command, SimpleCommand.EnumStatus.Canceled);
                        throw;
                    }
                    finally
                    {
                        Command = null;
                    }
                }
                else if (tel.Confirmation == TelegramTransportTO.CONFIRMATION_PALETTETAKEN || tel.Confirmation == TelegramTransportTO.CONFIRMATION_PALETTEDELETED)
                {
                    try
                    {
                        MaterialDelete(tel.Palette.Barcode);
                        FinishCommand(tel.MFCS_ID, Command, SimpleCommand.EnumStatus.Finished);
                    }
                    catch
                    {
                        Command.Reason = SimpleCommand.EnumReason.MFCS;
                        FinishCommand(tel.MFCS_ID, Command, SimpleCommand.EnumStatus.Canceled);
                        throw;
                    }
                    finally
                    {
                        Command = null;
                    }
                }
                else if (tel.Confirmation == TelegramTransportTO.CONFIRMATION_COMMANDFINISHED)
                {
                    try
                    {
                        Move(tel.Palette.Barcode, Warehouse.FindDeviceByPLC_ID(tel.Previous), this);
                        // for output we need additional confirmation PALETTETAKEN
                        if (tel.MFCS_ID != 0 && (!(this is IConveyorOutput)))
                        {
                            FinishCommand(tel.MFCS_ID, Command, SimpleCommand.EnumStatus.Finished);
                        }
                    }
                    finally
                    {
                        if (tel.MFCS_ID != 0 && (!(this is IConveyorOutput)))
                        {
                            Command = null;
                        }
                    }
                }
                else if (tel.Confirmation == TelegramTransportTO.CONFIRMATION_FAULT)
                {
                    try
                    {
                        Command.Reason = (Database.SimpleCommand.EnumReason)tel.Confirmation;
                        FinishCommand(tel.MFCS_ID, Command, SimpleCommand.EnumStatus.Canceled);
                    }
                    finally
                    {
                        Command = null;
                    }
                }
                else if (tel.Confirmation == TelegramTransportTO.CONFIRMATION_NONE)
                {
                    try
                    {
                        Command.Reason = (Database.SimpleCommand.EnumReason)tel.Fault;
                        FinishCommand(tel.MFCS_ID, Command, SimpleCommand.EnumStatus.Canceled);
                    }
                    finally
                    {
                        Command = null;
                    }
                }
            }
            catch (Exception ex)
            {
                Command.Reason = SimpleCommand.EnumReason.MFCS;
                FinishCommand(tel.MFCS_ID, Command, SimpleCommand.EnumStatus.Canceled);
                Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, ex.Message);
                throw new ConveyorException(String.Format("{0} ProcesMaterialNotify failed", Name));
            }
        }
Exemple #3
0
        public void Move(UInt32 material, ConveyorBasic source, ConveyorBasic target)
        {
            // for input points
            try
            {
                if (source == target)
                {
                    return;
                }

                if (source == null)
                {
                    throw new ConveyorBasicException(String.Format("ConveyorBasic.Move source is null ({0}).", source.Name));
                }

                if (target == null)
                {
                    throw new ConveyorBasicException(String.Format("ConveyorBasic.Move target is null ({0}).", source.Name));
                }

                if (source.Place == null)
                {
                    throw new ConveyorBasicException(String.Format("ConveyorBasic.Move source({0}) is empty.", source.Name));
                }

                if (target.Place != null)
                {
                    throw new ConveyorBasicException(String.Format("ConveyorBasic.Move target ({0}) is not empty.", target.Name));
                }

                if (source.Place.Material != material)
                {
                    throw new ConveyorBasicException(String.Format("ConveyorBasic.Move wrong pallet ({0}!={1}) at source ({2}).", material, source.Place.Material, source.Name));
                }

                if (target is Conveyor && source is Conveyor)
                {
                    (target as Conveyor).Command = (source as Conveyor).Command;
                    (source as Conveyor).Command = null;
                }
                target.Place        = source.Place;
                target.Place.Place1 = Name;
                source.Place        = null;

                if (source is ConveyorJunction)
                {
                    (source as ConveyorJunction).ActiveRoute    = null;
                    (source as ConveyorJunction).ActiveMaterial = null;
                }
                if (target is ConveyorJunction)
                {
                    (target as ConveyorJunction).ActiveRoute    = null;
                    (target as ConveyorJunction).ActiveMaterial = null;
                }

                //                Warehouse.DBService.MaterialMove((int) material, source.Name, target.Name);
                Place ps = Warehouse.DBService.FindPlace(source.Name);
                Place pt = Warehouse.DBService.FindPlace(target.Name);
                if (target.WriteToDB == WriteToDB.Never)
                {
                    if (source.WriteToDB == WriteToDB.Always || (source.WriteToDB == WriteToDB.Try && ps != null))
                    {
                        Warehouse.DBService.MaterialDelete(source.Name, (int)material);
                    }
                }
                else if (target.WriteToDB == WriteToDB.Always || (target.WriteToDB == WriteToDB.Try && pt == null))
                {
                    if (source.WriteToDB == WriteToDB.Always || (source.WriteToDB == WriteToDB.Try && ps != null))
                    {
                        Warehouse.DBService.MaterialMove((int)material, source.Name, target.Name);
                    }
                    else
                    {
                        Warehouse.DBService.MaterialCreate(target.Name, (int)material, true);
                    }
                }

                Warehouse.OnMaterialMove?.Invoke(new Place {
                    Place1 = target.Name, Material = (int)material
                }, EnumMovementTask.Move);

                // add force UI notify
                source.DirectVMNotify();
                target.DirectVMNotify();
            }
            catch (Exception ex)
            {
                Warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, ex.Message);
                throw new ConveyorBasicException(String.Format("{0} ConveyorBasic.Move fault ({1},{2},{3}).", Name, material, source != null ? source.Name : "null", target != null ? target.Name : "null"));
            }
        }