Ejemplo n.º 1
0
        private void frmErrorDetails_Load(object sender, EventArgs e)
        {
            Translate.DoTranslate(this);

            DB_Error.ErrorMessage msg = DB_Error.GetErrorMessage(unit.Ident, Registry.Culture, number);

            lblError.Text    = msg.Message;
            lblReason.Text   = msg.Reason;
            lblSolution.Text = msg.Solution;
        }
Ejemplo n.º 2
0
        public frmErrorDetails(int Number, string UnitID)
        {
            InitializeComponent();

            if (Program.MainIsRunning)
            {
                number       = Number;
                unit         = Unit.GetUnit(UnitID);
                txtUnit.Text = unit.Name;

                error = new DB_Error();
            }
        }
    public UnitErrorsAndMovesController()
    {
        Get["/uniterrors"] = _ => View["uniterrors"];

        // GET api/values
        Get["/api/uniterrors"] = parameters =>
        {
            var lst = DB_Error.AllAlarms(BauerLib.Registry.Culture);
            return(Response.AsJson(new DataObject {
                data = lst
            }));
        };
    }
Ejemplo n.º 4
0
        private void btnQuickCheck_Click(object sender, EventArgs e)
        {
            try
            {
                txtLog.Text = "";
            }
            catch
            {
            }

            try
            {
                log.Info("quick check start");

                foreach (var ls in new List <Unit> {
                    Unit.LS01, Unit.LS02
                })
                {
                    log.Info($"{ls.FriendlyName} : step number {ls.StepNo}");
                    log.Info(ls.FriendlyName + " " + (ls.Ready ? "is ready" : "is not ready") + " and " + (ls.Active ? "active" : "not active"));
                    log.Info(ls.FriendlyName + " " + (ls.LoadingStation_WithPallet ? "with pallet" : "without pallet"));
                    log.Info(ls.FriendlyName + " " + (ls.LoadingStation_WithRoll ? "with roll" : "without roll"));
                }
            }
            catch (Exception ex)
            {
                log.Error("exception in btnQuickCheck_Click 1", ex);
            }
            try
            {
                foreach (var tr in new List <Unit> {
                    Unit.Trolley1, Unit.Trolley2
                })
                {
                    log.Info($"{tr.FriendlyName} : step number {tr.StepNo}");
                    log.Info(tr.FriendlyName + " " + (tr.Ready ? "is ready" : "is not ready") + " and " + (tr.Active ? "active" : "not active"));
                    log.Info(tr.FriendlyName + " " + (tr.Trolley_WithRoll ? "with roll" : "without roll"));
                    log.Info($"{tr.FriendlyName} position : { tr.PlcPosition() }");
                }
            }
            catch (Exception ex)
            {
                log.Error("exception in btnQuickCheck_Click 2", ex);
            }

            try
            {
                foreach (var cr in new List <Unit> {
                    Unit.Carrier1, Unit.Carrier2
                })
                {
                    log.Info($"{cr.FriendlyName} : step number {cr.StepNo}");
                    log.Info(cr.FriendlyName + " " + (cr.Ready ? "is ready" : "is not ready") + " and " + (cr.Active ? "active" : "not active"));
                    log.Info($"{cr.FriendlyName} position : { cr.PlcPosition() }");
                }
            }
            catch (Exception ex)
            {
                log.Error("exception in btnQuickCheck_Click 3", ex);
            }

            try
            {
                log.Info("actually pending errors");
                foreach (var un in new List <Unit> {
                    Unit.LS01, Unit.LS02, Unit.LS03, Unit.Trolley1, Unit.Trolley2, Unit.Trolley3, Unit.Carrier1, Unit.Carrier2
                })
                {
                    int[] errValues = null;
                    int   no        = (int)un.Number;

                    errValues = un.ErrorValues;

                    if (errValues != null)
                    {
                        for (int i = 0; i < errValues.Length; i++)
                        {
                            int x = errValues[i];
                            for (int j = 0; j < 16; j++)
                            {
                                if ((x & (int)(Math.Pow(2, j))) != 0)
                                {
                                    DB_Error.ErrorMessage msg = DB_Error.GetErrorMessage(un.Ident, Registry.Culture, (i * 16) + j + 1);
                                    switch (msg.Sensitivity)
                                    {
                                    case 300: log.Warn($"{un.FriendlyName} : { msg.Message } ({ msg.Number })"); break;

                                    case 100: log.Info($"{un.FriendlyName} : { msg.Message } ({ msg.Number })"); break;

                                    default: log.Error($"{un.FriendlyName} : { msg.Message } ({ msg.Number })"); break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("exception in btnQuickCheck_Click 4", ex);
            }

            try
            {
                log.Info("actually orders in database");
                foreach (var ta in Main.Database.Fetch <TransportOrder>("SELECT * FROM StorageOrders WITH(NOLOCK)"))
                {
                    log.Info(ta.SimpleStringWithState);
                }
            }
            catch (Exception ex)
            {
                log.Error("exception in btnQuickCheck_Click 5", ex);
            }

            try
            {
                log.Info("actually moves in database");
                foreach (var mv in Main.Database.Fetch <MoveOrderEntry>("SELECT * FROM UnitMoves WITH(NOLOCK)"))
                {
                    log.Info(mv.ToString());
                }
            }
            catch (Exception ex)
            {
                log.Error("exception in btnQuickCheck_Click 6", ex);
            }

            try
            {
                foreach (var btn in simpleActionsControl.Buttons(true))
                {
                    log.Info($"left side { btn.CenteredText } { (btn.Visible ? " is visible" : " is not visible") } ");
                }
                foreach (var btn in simpleActionsControl.Buttons(false))
                {
                    log.Info($"right side { btn.CenteredText } { (btn.Visible ? " is visible" : " is not visible") } ");
                }
            }
            catch (Exception ex)
            {
                log.Error("exception in btnQuickCheck_Click 7", ex);
            }

            try
            {
                log.Info("quick check end");
                btnTabLog.InnerFillColor = Color.White;

                TabButton_Clicked(btnTabActions, null);
                this.Refresh();
                Application.DoEvents();

                if (!Directory.Exists("screenshots"))
                {
                    Directory.CreateDirectory("screenshots");
                }

                ScreenCapture.CaptureWindowToFile(Handle, $".\\screenshots\\shot_actions_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.jpg");

                TabButton_Clicked(btnTabFetch, null);
                this.Refresh();
                Application.DoEvents();

                ScreenCapture.CaptureWindowToFile(Handle, $".\\screenshots\\shot_fetch_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.jpg");

                TabButton_Clicked(btnTabLog, null);
            }
            catch (Exception ex)
            {
                log.Error("exception in btnQuickCheck_Click 8", ex);
            }
        }
Ejemplo n.º 5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (!Program.MainIsRunning)
            {
                return;
            }

            try
            {
                string[] units =
                {
                    "+ST01.BU",
                    "+ST01.LS01",
                    "+ST01.LS02",
                    "+ST01.LS03",
                    "+ST01.SC01",
                    "+ST01.SC02",
                    "+ST01.SC03",
                    "+ST01.CAR01",
                    "+ST01.CAR02"
                };


                ListBox list_err  = new ListBox();
                ListBox list_warn = new ListBox();
                ListBox list_msg  = new ListBox();

                foreach (string SelectedUnit in units)
                {
                    un = Unit.GetUnit(SelectedUnit);
                    if (un == null)
                    {
                        continue;
                    }

                    if (un.SystemError != null && un.SystemError.Length > 0)
                    {
                        OnNewSystemMessage?.Invoke(un.Unit_ID, un.SystemError);

                        log.Error(un.FriendlyName + " : System failure: " + un.SystemError);
                        un.SystemError = "";
                        un.Update();
                    }

                    int[] errValues = null;
                    int   no        = (int)un.Number;

                    errValues = un.ErrorValues;

                    if (errValues != null)
                    {
                        for (int i = 0; i < errValues.Length; i++)
                        {
                            int x = errValues[i];
                            for (int j = 0; j < 16; j++)
                            {
                                if ((x & (int)(Math.Pow(2, j))) != 0)
                                {
                                    DB_Error.ErrorMessage msg = DB_Error.GetErrorMessage(SelectedUnit, Registry.Culture, (i * 16) + j + 1);
                                    ListBox l = null;
                                    switch (msg.Sensitivity)
                                    {
                                    case 500: l = list_err; break;

                                    case 300: l = list_warn; break;

                                    case 100: l = list_msg; break;

                                    default: l = list_err; break;
                                    }
                                    if (l != null)
                                    {
                                        l.Items.Add(msg.Number + " " + un.Name + " : "
                                                    //+ msg.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " "
                                                    + msg.Message);
                                    }
                                }
                            }
                        }
                    }
                    if (list_err.Items.Count > 0)
                    {
                        isError = true;
                    }
                    else
                    {
                        isError = false;
                    }
                    if (list_msg.Items.Count > 0)
                    {
                        isMessage = true;
                    }
                    else
                    {
                        isMessage = false;
                    }
                    if (list_warn.Items.Count > 0)
                    {
                        isWarning = true;
                    }
                    else
                    {
                        isWarning = false;
                    }
                }

                #region arrange listbox
                for (int i = 0; i < listError.Items.Count; i++)
                {
                    if (!list_err.Items.Contains(listError.Items[i]))
                    {
                        listError.Items.Remove(listError.Items[i]);
                    }
                }

                for (int j = 0; j < list_err.Items.Count; j++)
                {
                    if (!listError.Items.Contains(list_err.Items[j]))
                    {
                        listError.Items.Add(list_err.Items[j]);
                    }
                }
                #endregion

                #region arrange listbox
                for (int i = 0; i < listWarn.Items.Count; i++)
                {
                    if (!list_warn.Items.Contains(listWarn.Items[i]))
                    {
                        listWarn.Items.Remove(listWarn.Items[i]);
                    }
                }

                for (int j = 0; j < list_warn.Items.Count; j++)
                {
                    if (!listWarn.Items.Contains(list_warn.Items[j]))
                    {
                        listWarn.Items.Add(list_warn.Items[j]);
                    }
                }
                #endregion

                #region arrange listbox
                for (int i = 0; i < listMessages.Items.Count; i++)
                {
                    if (!list_msg.Items.Contains(listMessages.Items[i]))
                    {
                        listMessages.Items.Remove(listMessages.Items[i]);
                    }
                }

                for (int j = 0; j < list_msg.Items.Count; j++)
                {
                    if (!listMessages.Items.Contains(list_msg.Items[j]))
                    {
                        listMessages.Items.Add(list_msg.Items[j]);
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                log.Error("error reading errors", ex);
            }
        }
Ejemplo n.º 6
0
    public dynamic GetUnitsTable()
    {
        List <TableItem> lst = new List <TableItem>();

        try
        {
            Unit[] units = new Unit[] { Unit.MainRack, Unit.LS01, Unit.LS02, Unit.LS03, Unit.Trolley1, Unit.Trolley2, Unit.Trolley3, Unit.Carrier1, Unit.Carrier2 };

            var alarms = DB_Error.AllAlarms(BauerLib.Registry.Culture);

            foreach (Unit u in units)
            {
                if (!BauerLib.Registry.UseVehicle(u.Unit_ID))
                {
                    continue;
                }

                TableItem item = new TableItem(u.FriendlyName);

                item.id      = u.Unit_ID;
                item.ready   = u.Ready ? color(KnownColor.LightGreen) : color(KnownColor.LightGray);
                item.active  = u.Active ? color(KnownColor.LightGreen) : color(KnownColor.LightGray);
                item.online  = u.Online ? color(KnownColor.LightGreen) : color(KnownColor.Red);
                item.error   = u.HasError ? color(KnownColor.Red) : color(KnownColor.LightGray);
                item.inorout = "";

                item.reserved = "";

                if (u.IsCarrier() && u.Reserved >= 20 && u.Reserved <= 23)
                {
                    item.reserved = $"TR {u.Reserved - 20}";
                }

                item.step = u.StepNo;

                //lst.Add(new StatusEntry(div_id, "StepNo", ls.StepNo.ToString()));
                //lst.Add(new StatusEntry(div_id, "MoveID", ls.MoveID.ToString()));

                if (u.Cylinder_ID != 0)
                {
                    item.roll = u.Cylinder.Number;
                }

                Hook p = u.PlcPosition();
                item.position = p.ToString().Replace(",100,100", "").Replace("0,0,0,0", "");

                //if (u.IsCarrier() && u.Reserved != 0)
                //    item.AddInfo($"reserved for : {Unit.GetUnit(u.Reserved).FriendlyName}");

                if (u.IsLoadingStation() && u.BlockForManualOrderUntil > DateTime.UtcNow)
                {
                    item.AddInfo($"blocked for automatics");
                }

                var mv = GetLatestPLCMoveForUnit(u.Unit_ID);
                if (mv != null)
                {
                    item.AddInfo("Move " + mv.ToString().Substring(3));
                    if (mv.MoveTarget.Bridge != 0 && mv.MoveTarget.Trolley != 0)
                    {
                        item.target = mv.MoveTarget.ToString().Replace(",100,100", "");
                    }
                }
                string info = GetLatestOrderForUnit(u.Reserved);
                item.AddInfo(info);

                if (info.Contains("incoming"))
                {
                    item.inorout = "in";
                }
                if (info.Contains("outgoing"))
                {
                    item.inorout = "out";
                }

                //lst.Add(new StatusEntry(div_id, "Cylinder (in)", Hook.LoadingStation(ls.Number, true).CylinderNumber));
                //lst.Add(new StatusEntry(div_id, "Cylinder (out)", Hook.LoadingStation(ls.Number, false).CylinderNumber));


                foreach (var a in alarms)
                {
                    if (a.UnitName == item.name)
                    {
                        item.AddInfo($"{a.Level} {a.Number} : {a.Message}");
                    }
                }

                lst.Add(item);
            }
        }
        catch
        {
        }
        return(Response.AsJson(lst));
    }