private void HealthySettingDialog_Load(object sender, EventArgs e)
        {
            List <MachineControl.Parameter> lists = ManageParameters.getAllParameters(PAR_CATEGORY.STATUS);

            MachineControl.Parameter par = lists.Find(x => (x.Order == Order));
            if (par != null)
            {
                txtHF.Mask = txtHT.Mask = txtU.Mask = txtS.Mask = par.Format;
            }
            else
            {
                MessageBox.Show(this, "Unknown parameter selected.", "Parameter not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.Cancel;
                Close();
            }
            lblDesc.Text = itemDescription;
            //MessageBox.Show(HF+Environment.NewLine+HT+Environment.NewLine+U+Environment.NewLine+S);
            txtHF.Text = HF.Trim();
            txtHT.Text = HT.Trim();
            txtS.Text  = S.Trim();
            txtU.Text  = U.Trim();
            if (UC > 0)
            {
                radUNH1.Checked = true;
            }
            if (UC < 0)
            {
                radUNH2.Checked = true;
            }
            if (UC == 0)
            {
                radUNH3.Checked = true;
            }
            if (SC > 0)
            {
                radS1.Checked = true;
            }
            if (SC < 0)
            {
                radS2.Checked = true;
            }
            if (SC == 0)
            {
                radS3.Checked = true;
            }
        }
Example #2
0
        private void MachineSettings_Load(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            List <Parameter> _params = ManageParameters.getAllParameters(PAR_CATEGORY.STATUS);

            foreach (Parameter param in _params)
            {
                if (param.CheckForHealthy)
                {
                    listBox1.Items.Add(param);
                }
            }
            machines = getMachineVariables();
            foreach (MachineVariables mv in machines)
            {
                comboBox1.Items.Add(mv.Type);
            }
            if (machines == null || machines.Count == 0)
            {
                MessageBox.Show(this, "Robo cant read machines parameters from mind.", "Mind error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            comboBox1.Focus();
        }
Example #3
0
        private void lstMachines_SelectedIndexChanged(object sender, EventArgs e)
        {
            lstMachines.Enabled = false;
            if (lstMachines.SelectedItems.Count > 0)
            {
                txtProblems.Text = "";
                lblStatus.Text   = "Searching problem ...";
                ListViewItem li      = lstMachines.SelectedItems[0];
                Machine      machine = new Machine(li.SubItems[1].Text.Trim(), Program.connString, ManageParameters.getAllParameters(PAR_CATEGORY.STATUS), ManageParameters.getAllParameters(PAR_CATEGORY.SETTINGS), UserSetting.StatusMessageFormat, UserSetting.SettingMessageFormat);
                if (machine.Error != MCError.NULL)
                {
                    if (machine.Error == MCError.INVALID_IDENTIFIER)
                    {
                        updateProblem("Machine ID invalid.");
                    }
                    else if (machine.Error == MCError.SQL_ERROR)
                    {
                        updateProblem("Mind error.");
                    }
                    else if (machine.Error == MCError.PARSE_FAILED)
                    {
                        updateProblem("Machine's entries invalid.");
                    }
                    else if (machine.Error == MCError.SETTING_ERROR)
                    {
                        if (machine.Settings.ErrorMessage == MCFormat_ERROR.NULL)
                        {
                            updateProblem("Machine setting is not updated yet or invalid settings parameters.");
                        }
                        else if (machine.Settings.ErrorMessage == MCFormat_ERROR.FORMAT_MISMATCH)
                        {
                            updateProblem("Machine setting message isn't matched with given format.");
                        }
                        else if (machine.Settings.ErrorMessage == MCFormat_ERROR.FORMAT_NOT_ACCEPTED)
                        {
                            updateProblem("Machine setting message has errors.");
                        }
                        else if (machine.Settings.ErrorMessage == MCFormat_ERROR.INVALID_FORMAT)
                        {
                            updateProblem("Machine setting message has invalid format.");
                        }
                        else if (machine.Settings.ErrorMessage == MCFormat_ERROR.PARAMETER_COUNT)
                        {
                            updateProblem("Machine setting message's received parameters count isn't matched with format.");
                        }
                        else if (machine.Settings.ErrorMessage == MCFormat_ERROR.SEPARATOR_NOT_FOUND)
                        {
                            updateProblem("Machine setting message hasn't any separator.");
                        }
                        else
                        {
                            updateProblem("Machine setting message has error.");
                        }
                    }
                    else if (machine.Error == MCError.STATUS_ERROR)
                    {
                        if (machine.Status.ErrorMessage == MCFormat_ERROR.NULL)
                        {
                            updateProblem("Machine status is not updated yet or invalid status parameters.");
                        }
                        else if (machine.Status.ErrorMessage == MCFormat_ERROR.FORMAT_NOT_ACCEPTED)
                        {
                            updateProblem("Machine status message's has errors.");
                        }
                        else if (machine.Status.ErrorMessage == MCFormat_ERROR.FORMAT_MISMATCH)
                        {
                            updateProblem("Machine status message's format isn't matched with given format.");
                        }
                        else if (machine.Status.ErrorMessage == MCFormat_ERROR.INVALID_FORMAT)
                        {
                            updateProblem("Machine status message has invalid format.");
                        }
                        else if (machine.Status.ErrorMessage == MCFormat_ERROR.PARAMETER_COUNT)
                        {
                            updateProblem("Machine status message's received parameters count not macthed with given format.");
                        }
                        else if (machine.Status.ErrorMessage == MCFormat_ERROR.SEPARATOR_NOT_FOUND)
                        {
                            updateProblem("Machine status message's separator not found.");
                        }
                        else
                        {
                            updateProblem("Machine status message's has error.");
                        }
                    }
                    else
                    {
                        updateProblem("Unknown problem id=1.");
                    }
                }

                if (true)
                {
                    if (machine.Status.Error)
                    {
                        updateProblem("Invalid received machine status parameters.");
                    }
                    else
                    {
                        List <MachineVariables> mparams = ParameterVariables.getMachineVariables();
                        if (mparams != null)
                        {
                            MachineVariables macParam  = Program.ParseHealthyCommand(machine.HealthySetting);
                            List <Parameter> chkValues = machine.Status.parameters;

                            foreach (Variables var in macParam.variables)
                            {
                                Parameter par = chkValues.Find(x => (x.Order == var.Order));
                                if (par != null)
                                {
                                    int result = checkParameter(par, var);
                                    //0 stoped, 1 unhealthy, 2 green, 3 unknown. -1 error
                                    if (result == 0)
                                    {
                                        updateProblem(par.Name + " indicates NOT_WORKING SIGNAL.");
                                    }
                                    else if (result == 1)
                                    {
                                        updateProblem(par.Name + " indicates UNHEALTHY SIGNAL.");
                                    }
                                    else if (result == 2)
                                    {
                                        updateProblem(par.Name + " indicates HEALTHY SIGNAL.");
                                    }
                                    else if (result == 3)
                                    {
                                        updateProblem(par.Name + " indicates NOT_MATCHED SIGNAL.");
                                    }
                                    else if (result == 1)
                                    {
                                        updateProblem(par.Name + " indicates ERROR SIGNAL.");
                                    }
                                }
                            }
                        }
                        else
                        {
                            updateProblem("Error in reading parameters from mind.");
                        }
                    }
                }
            }
            lblStatus.Text      = "Problem displayed.";
            lstMachines.Enabled = true;
        }
Example #4
0
        public static List <MachineVariables> getMachineVariables()
        {
            List <MachineVariables> _machines = new List <MachineVariables>();

            try
            {
                SqlConnection conn = new SqlConnection(Program.connString);
                conn.Open();
                SqlCommand    cmd = new SqlCommand("select * from machine_settings", conn);
                SqlDataReader dr  = cmd.ExecuteReader();
                while (dr.Read())
                {
                    String           type  = dr["type"].ToString();
                    String           param = dr["parameter"].ToString();
                    MachineVariables mv    = new MachineVariables(type, new List <Variables>());
                    mv.inputString = param;
                    _machines.Add(mv);
                }
                dr.Close();
                conn.Close();
            }
            catch (Exception ex)
            {
                return(null);
            }

            try
            {
                foreach (MachineVariables machine in _machines)
                {
                    String[] arrTemp = machine.inputString.Split(new String[] { "][" }, StringSplitOptions.None);
                    for (int i = 0; i < arrTemp.Length; i++)
                    {
                        arrTemp[i] = arrTemp[i].Replace("[", "").Replace("]", "");
                    }
                    List <Parameter> lstpars = ManageParameters.getAllParameters(PAR_CATEGORY.STATUS);
                    foreach (Parameter parm in lstpars)
                    {
                        if (parm.CheckForHealthy)
                        {
                            String hf = "", ht = "", uh = "", st = "";
                            foreach (String pfdb in arrTemp)
                            {
                                if (pfdb.ToLower().Contains(parm.Name.ToLower()))
                                {
                                    String[] arr = pfdb.Split(new String[] { "," }, StringSplitOptions.None);
                                    if (arr.Length == 5)
                                    {
                                        hf = arr[1];
                                        ht = arr[2];
                                        uh = arr[3];
                                        st = arr[4];
                                    }
                                    break;
                                }
                            }
                            machine.variables.Add(new Variables(parm.Name, hf, ht, uh, st));
                        }
                    }
                }
            }
            catch (Exception ex) { return(null); }

            return(_machines);
        }