Example #1
0
        public static void SaveMovements(TPlist list, int unit_id, string info = "check")
        {
            foreach (var item in list)
            {
                try
                {
                    int id = MoveOrderEntry.GetNextId() + 100;
                    while (BauerSql.Main.Database.ExecuteScalar <int>("SELECT COUNT(*) FROM UnitMoves WHERE ID=@0", id) > 0)
                    {
                        id = id + 100;
                    }

                    MoveOrderEntry move = new MoveOrderEntry()
                    {
                        ID          = id,
                        Source      = "",
                        TargetHook  = item.target,
                        Unit_ID     = unit_id,
                        WaitMove_ID = 0,
                        Status      = info,
                        Trolley     = 0,
                        Carrier     = 0
                    };

                    if (item.info == "GET")
                    {
                        move.Target     = "";
                        move.SourceHook = item.target;
                    }
                    if (item.info == "PUT")
                    {
                        // Haken leeren
                        item.target.ClearID();
                    }

                    move.Info = item.info;
                    move.Insert();
                }
                catch
                {
                }
            }
        }
Example #2
0
        public static TPlist Check(string actual_pos, string src, string dst, bool with_cylinder = false)
        {
            TPlist result = null;

            try
            {
                TransportOrder to = new TransportOrder()
                {
                    TransportSource = TransportOrder.Destinations.Storage,
                    TransportTarget = TransportOrder.Destinations.Storage,
                    State           = TransportOrder.OrderStates.PreparedForTrolley
                };

                if (src == "")
                {
                    to.SourceHook = actual_pos;
                }
                else
                {
                    to.SourceHook = src;
                }

                to.TargetHook = dst;
                Hook p = new Hook(actual_pos);
                Unit u = new Unit()
                {
                    PosAxis01 = p.Bridge, PosAxis02 = p.Trolley, PosAxis03 = p.Lift, PosAxis04 = p.Telescope
                };
                if (with_cylinder)
                {
                    u.Cylinder_ID = 4711;
                }
                result = MovementSequencer.SplitTransportOrder(to, u);

                System.Console.WriteLine(result.ToString());
                System.Diagnostics.Debug.WriteLine(result.ToString());
            }
            catch
            {
            }

            return(result);
        }
Example #3
0
        /// <summary>
        /// save TPList to UnitMoves - table
        /// </summary>
        /// <param name="list"></param>
        /// <param name="unit_id"></param>
        /// <param name="info"></param>
        /// <param name="first_move_wait_id"></param>
        /// <param name="transport_order_id"></param>
        /// <param name="before_insert"></param>
        public static void SaveMovements(TPlist list, int unit_id, string info = "check", int first_move_wait_id = 0, int transport_order_id = 0, Action <MoveOrderEntry> before_insert = null)
        {
            if (list == null)
            {
                return;
            }

            int last_carrier_id = 0;
            int last_id         = 0;

            foreach (var item in list)
            {
                try
                {
                    int id = MoveOrderEntry.GetNextId() + 100;
                    while (!MoveOrderEntry.IdIsFree(id))
                    {
                        id = id + 100;
                    }

                    MoveOrderEntry move = new MoveOrderEntry()
                    {
                        ID          = id,
                        Source      = "",
                        TargetHook  = item.target,
                        Unit_ID     = unit_id,
                        WaitMove_ID = first_move_wait_id,
                        Status      = info,
                        Trolley     = 0,
                        Carrier     = 0,
                        Order_ID    = transport_order_id,
                    };

                    if (item.info.ToLowerInvariant() == "carrier")
                    {
                        move.WaitMove_ID = last_id;
                        last_carrier_id  = id;
                    }
                    else if (last_carrier_id > 0)
                    {
                        move.WaitMove_ID = last_carrier_id;
                        last_carrier_id  = 0;
                    }
                    else
                    {
                        last_carrier_id = 0;
                    }

                    last_id = move.ID;

                    log.Info($"{Unit.UnitName(unit_id)} move {move.ID}: {item.target} {item.info}");

                    first_move_wait_id = 0;

                    if (item.info == "GET")
                    {
                        move.Target     = "";
                        move.SourceHook = item.target;
                    }

                    move.Info = item.info;

                    if (before_insert != null)
                    {
                        before_insert(move);
                    }

                    move.Insert();
                }
                catch (Exception ex)
                {
                    log.Error("exception in SaveMovements", ex);
                }
            }
        }
Example #4
0
        /// <summary>
        /// returns a list of movements according to Wohltmann TST: FA-Sequenz -1-
        /// </summary>
        /// <param name="SourceHook">position of roll pickup</param>
        /// <param name="TargetHook">position of roll placement</param>
        /// <param name="start_pos">actual trolley position</param>
        /// <param name="Cylinder_ID">roll on trolley</param>
        /// <returns></returns>
        public static TPlist SplitTransportOrder(Hook SourceHook, Hook TargetHook, Hook start_pos, int Cylinder_ID)
        {
            TPlist sequence = new TPlist();

            bool use_back_carrier = BauerLib.Registry.UseCarrier2;

            sequence.Append("START", start_pos);
            if (Cylinder_ID == 0 && SourceHook != null && SourceHook.IsValidTrolleyPosition())
            {
                if (SourceHook.Lift != 100)
                {
                    sequence.Append("GET", SourceHook);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("omit get");
                }
            }
            if (TargetHook.Lift == 100 && TargetHook.Telescope == 100)
            {
                sequence.Append("target", TargetHook);
            }
            else
            {
                sequence.Append("PUT", TargetHook);
            }

            TP TP_here = sequence[0];
            TP TP_next = sequence[1];

            while (TP_here != null && TP_next != null)     // 1a
            {
                Hook here = TP_here.target;
                Hook next = TP_next.target;

                if (here.Bridge != next.Bridge)                    // 1b
                {
                    if (here.Lift != 100 || here.Telescope != 100) // 1d
                    {
                        // top before next movement possible
                        sequence.InsertAfter("top", ref TP_here, ref here);
                        here.Lift = 100; here.Telescope = 100;                                            // now here
                    }
                    if (here.Trolley != 1)                                                                // 1e
                    {
                        if (ChangingStorageSides(here, next) || next.Trolley == 1 || !use_back_carrier || // 1f
                            BauerLib.Registry.Carrier2AllowedEndBridge < here.Bridge ||
                            BauerLib.Registry.Carrier2AllowedEndBridge < next.Bridge ||
                            BauerLib.Registry.Carrier2AllowedStartBridge > here.Bridge ||
                            BauerLib.Registry.Carrier2AllowedStartBridge > next.Bridge)
                        {
                            if (here.Trolley >= 10)
                            {
                                sequence.InsertAfter("before front row", ref TP_here, ref here);
                                here.Trolley = 2;   // now here
                            }
                            sequence.InsertAfter("front row", ref TP_here, ref here);
                            here.Trolley = 1;       // now here
                        }
                        else
                        {
                            if (here.Trolley != 10)  // 1k
                            {
                                sequence.InsertAfter("back row", ref TP_here, ref here);
                                here.Trolley = 10;
                            }
                        }
                    }
                    sequence.InsertAfter("carrier", ref TP_here, ref here);
                    here.Bridge = next.Bridge;      // right bridge reached    3)
                }

                if (here.Trolley != next.Trolley)                  // 1c
                {
                    if (here.Lift != 100 || here.Telescope != 100) // 1h
                    {
                        sequence.InsertAfter("top", ref TP_here, ref here);
                        here.Lift = 100;   here.Telescope = 100;
                    }

                    if (here.Trolley >= 10 && next.Trolley == 1)
                    {
                        sequence.InsertAfter("trolley", ref TP_here, ref here);
                        here.Trolley = 2;
                    }

                    if (here.Trolley == 1 && next.Trolley >= 10)
                    {
                        sequence.InsertAfter("trolley", ref TP_here, ref here);
                        if (next.Bridge >= 6)
                        {
                            here.Trolley = 8;
                        }
                        else
                        {
                            here.Trolley = 9;
                        }
                    }

                    sequence.InsertAfter("trolley", ref TP_here, ref here);
                    here.Trolley = next.Trolley;
                }

                // lift only moves still not possible !

                //if (here.Lift != next.Lift)   // 1m
                //{
                //    sequence.InsertAfter("lift", ref TP_here, ref here);
                //    here.Lift = next.Lift;
                //}

                //if (here.Telescope != next.Telescope && (new Hook(here.GetArray) {  Telescope = next.Telescope  } != next ))
                //{
                //    sequence.InsertAfter("telescope", ref TP_here, ref here);
                //    here.Lift = next.Lift;
                //    here.Telescope = next.Telescope;
                //}

                // next while
                int next_idx = sequence.IndexOf(TP_here) + 1;
                if (next_idx < sequence.Count - 1)
                {
                    TP_here = sequence[next_idx];
                    TP_next = sequence[next_idx + 1];
                }
                else
                {
                    here = sequence[next_idx].target;

                    // add last move at the end of the sequence
                    if (here.Lift != 100 || here.Telescope != 100)   // safe top at the very end
                    {
                        sequence.InsertAfter("STOP", ref TP_next, ref next);
                        next.Lift      = 100;
                        next.Telescope = 100;
                    }

                    TP_here = null;
                    TP_next = null;
                }
            }

            if (sequence != null && sequence.Count >= 2)
            {
                TP last   = sequence[sequence.Count - 1];
                TP before = sequence[sequence.Count - 2];
                if (last.info == "target" && before.target == last.target)
                {
                    sequence.Remove(last);
                }
            }

            return(sequence);
        }