Beispiel #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;
        }
Beispiel #2
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);
            }
        }
Beispiel #3
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);
            }
        }