Exemplo n.º 1
0
 public SFCS_SIGMA(LogManager Logger)
     : base(Logger)
 {
     SqlConnected = false;
     Logger.PrintLog(this, "SFCS_SIGMA was initiated.", LogDetailLevel.LogRelevant);
     Logger.PrintLog(this, "The setting of GeneralLinkSqlLocalDebug is: " + CyBLE_MTK_Application.Properties.Settings.Default.GeneralLinkSqlLocalDebug.ToString(), LogDetailLevel.LogRelevant);
 }
Exemplo n.º 2
0
        private void AddPorts()
        {
            if (_ComPortInfoList == null || _ComPortInfoList.Count == 0)
            {
                _ComPortInfoList = COMPortInfo.GetCOMPortsInfo();
            }
            Graphics ComboGraphics = SerialPortCombo.CreateGraphics();
            Font     ComboFont     = SerialPortCombo.Font;
            int      MaxWidth      = 0;

            foreach (COMPortInfo ComPort in _ComPortInfoList)
            {
                string s = ComPort.Name + " - " + ComPort.Description;
                SerialPortCombo.Items.Add(s);
                int VertScrollBarWidth = (SerialPortCombo.Items.Count > SerialPortCombo.MaxDropDownItems) ? SystemInformation.VerticalScrollBarWidth : 0;
                int DropDownWidth      = (int)ComboGraphics.MeasureString(s, ComboFont).Width + VertScrollBarWidth;
                if (MaxWidth < DropDownWidth)
                {
                    SerialPortCombo.DropDownWidth = DropDownWidth;
                    MaxWidth = DropDownWidth;
                }
            }
            if (SerialPortCombo.Items.Count > 0)
            {
                SerialPortCombo.SelectedIndex = 0;
            }
            Log.PrintLog(this, _ComPortInfoList.Count.ToString() + " serial ports found.", LogDetailLevel.LogRelevant);
        }
Exemplo n.º 3
0
 public virtual MTKTestError RunTest()
 {
     Log.PrintLog(this, "Started", LogDetailLevel.LogRelevant);
     Thread.Sleep(1000);
     Log.PrintLog(this, "Finished", LogDetailLevel.LogRelevant);
     OnTestStatusUpdate(MTKTestMessageType.Complete, "DONE");
     return(MTKTestError.NoError);
 }
Exemplo n.º 4
0
 private void UpdateTestProgramWithNewTest(MTKTest NewTest)
 {
     if (TestProgramListBox.SelectedIndex >= 0)
     {
         TestProgram.Insert(TestProgramListBox.SelectedIndex, NewTest);
         TestProgramListBox.Items.Insert(TestProgramListBox.SelectedIndex, NewTest.GetDisplayText());
     }
     else
     {
         TestProgram.Add(NewTest);
         TestProgramListBox.Items.Add(NewTest.GetDisplayText());
     }
     Log.PrintLog(this, "Adding " + NewTest.ToString() + " to the test list.",
                  LogDetailLevel.LogEverything);
 }
Exemplo n.º 5
0
        public static void SwitchDutPower(int channel_no, PowerSupplyState PowerState)
        {
            try
            {
                if (!swConnected)
                {
                    ConnectSwitch();
                }

                if (PowerState == PowerSupplyState.PowerOn)
                {
                    //close single channel
                    sw.SetRelayWellA_byCH(channel_no, true);
                }
                else
                {
                    //open single channel
                    sw.SetRelayWellA_byCH(channel_no, false);
                }
            }
            catch (Exception)
            {
                Logger.PrintLog(MTKInstruments.sw, "", LogDetailLevel.LogRelevant);
            }
        }
Exemplo n.º 6
0
        public SFCS_LOCAL(LogManager Logger, string SavedFileName)
            : base(Logger)
        {
            if (SavedFileName != null && SavedFileName.Length > 0)
            {
                FileName = SavedFileName;
            }
            else
            {
                FileName = "SFCS.csv";
            }

            Logger.PrintLog(this, "SFCS_LOCAL was initiated.", LogDetailLevel.LogRelevant);
        }
        private void OKButton(object sender, EventArgs e)
        {
            string temp = "";

            if (CyBLE_MTK_Application.Properties.Settings.Default.Password == "null")
            {
                temp = "";
            }
            else
            {
                byte[] passtext = ProtectedData.Unprotect(Convert.FromBase64String(CyBLE_MTK_Application.Properties.Settings.Default.Password), null, DataProtectionScope.CurrentUser);
                temp = ChangePasswordDialog.GetString(passtext);
            }
            if (PasswordText.Text == temp)
            {
                if (NewPassword.Text == ReEnterNewPassword.Text)
                {
                    byte[] ciphertext = ProtectedData.Protect(GetBytes(ReEnterNewPassword.Text), null, DataProtectionScope.CurrentUser);
                    CyBLE_MTK_Application.Properties.Settings.Default.Password = Convert.ToBase64String(ciphertext);
                    CyBLE_MTK_Application.Properties.Settings.Default.Save();
                    Log.PrintLog(this, "Password successfully changed.", LogDetailLevel.LogRelevant);
                    MessageBox.Show("Password successfully changed!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    PasswordChanged = true;
                    this.Close();
                }
                else
                {
                    Log.PrintLog(this, "Password not changed! Re-entered password doesnot match.", LogDetailLevel.LogEverything);
                    MessageBox.Show("Password not changed! Re-entered password doesnot match.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                Log.PrintLog(this, "Password not changed! Wrong password.", LogDetailLevel.LogEverything);
                MessageBox.Show("Password not changed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 8
0
        protected void InsertRowToDB(SqlConnection connection)
        {
            int rowCnt = 0;

            sqlstring = "INSERT INTO " + tableName + " (" + column_list + ") " + "VALUES" + " (" + value_list + ")";
            //sqlstring = "INSERT INTO " + tableName +  " VALUES" + " (" + value_list + ")";

            if (connection.State == ConnectionState.Open)
            {
                SqlCommand command = new SqlCommand(sqlstring, connection);

                command.CommandText    = sqlstring;
                command.CommandTimeout = 3;
                command.CommandType    = CommandType.Text;

                try
                {
                    rowCnt = command.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception from ExecuteNonQuery: \n" + ex.ToString());
                    Logger.PrintLog(this, "Exception from ExecuteNonQuery: \n" + ex.ToString(), LogDetailLevel.LogRelevant);
                }
            }
            else
            {
                rowCnt = 0;
            }


            if (rowCnt > 0)
            {
                Console.WriteLine("Insert {0} row(s) to {1} successfully.", rowCnt, tableName);
            }
            return;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                sw.InitializeU2751A_WELLA(SWAlias_textBox.Text);
                sw.SetRelayWellA_ALLCLOSE();

                toolStripStatusLabel1.Text = "SW: " + SWAlias_textBox.Text + " is connected.";


                log.PrintLog(this, "U2751A is connected and all channels are closed.", LogDetailLevel.LogRelevant);
                button2.Focus();
            }
            catch
            {
                toolStripStatusLabel1.Text = "SW: " + SWAlias_textBox.Text + " is not connected.";
                button2.Focus();
            }
        }
        public void SaveParameters()
        {
            bool changed = false;

            if (textBox_dmm_alias.Text.ToLower() != CyBLE_MTK_Application.Properties.Settings.Default.DMM_Alias.ToLower())
            {
                CyBLE_MTK_Application.Properties.Settings.Default.DMM_Alias = textBox_dmm_alias.Text;
                CyBLE_MTK_Application.Properties.Settings.Default.Save();
                changed = true;
            }

            if (textBox_sw_alias.Text.ToLower() != CyBLE_MTK_Application.Properties.Settings.Default.Switch_Alias.ToLower())
            {
                CyBLE_MTK_Application.Properties.Settings.Default.Switch_Alias = textBox_sw_alias.Text;
                CyBLE_MTK_Application.Properties.Settings.Default.Save();
                changed = true;
            }

            if (comboBox_CurrUnit.Text.ToLower() != CyBLE_MTK_Application.Properties.Settings.Default.DUTCurrentMeasureUnit.ToLower())
            {
                CyBLE_MTK_Application.Properties.Settings.Default.DUTCurrentMeasureUnit = comboBox_CurrUnit.Text;
                CyBLE_MTK_Application.Properties.Settings.Default.Save();
                changed = true;
            }

            if (numericUpDown_RelayDelay.Value != CyBLE_MTK_Application.Properties.Settings.Default.RelayDelayInMS)
            {
                CyBLE_MTK_Application.Properties.Settings.Default.RelayDelayInMS = numericUpDown_RelayDelay.Value;
                CyBLE_MTK_Application.Properties.Settings.Default.Save();
                changed = true;
            }


            if (changed)
            {
                MTKInstruments.SyncParams();
                logger.PrintLog(this, "Parameters Sync done.", LogDetailLevel.LogRelevant);
            }
            else
            {
                //logger.PrintLog(this, "Parameters hasn't been changed.", LogDetailLevel.LogRelevant);
            }
        }
Exemplo n.º 11
0
            public bool Initialize(string RawDataFromRobot)
            {
                int ParsedSocketID = 0;

                SocketID = 0;
                RawData  = "";
                ErrCode  = ECCS.ERRORCODE_DUT_NOT_TEST;
                TestFlag = false;

                if (RawDataFromRobot == null)
                {
                    return(false);
                }

                RawData = RawDataFromRobot.Trim(new char[] { '\n', '\r', ' ', '\0', '#' });

                //Include TestID(1) + SocketID(1) + ModuleName(6) + id(1) + TestFlag(1) at least
                if (RawData.Length < 10)
                {
                    Log.PrintLog(this, "ReceviedRobotMessage is invalid due to lenght: " + RawData.Length.ToString(), LogDetailLevel.LogRelevant);
                    return(false);
                }

                //Test ID
                TesterID = RawData.Substring(0, 1); //Char[0]

                //Socket ID
                try
                {
                    ParsedSocketID = int.Parse(RawData.Substring(1, 1)); //Char[1]
                    if (ParsedSocketID <= 0 || ParsedSocketID > CyBLEMTKRobotServer.gNumDuts)
                    {
                        Log.PrintLog(this, "ReceviedRobotMessage is invalid due to the socket# out of range: " + ParsedSocketID.ToString(), LogDetailLevel.LogRelevant);
                        return(false);
                    }
                }
                catch
                {
                    Log.PrintLog(this, "ReceviedRobotMessage is invalid due to parsing socket# error : " + RawData, LogDetailLevel.LogRelevant);
                    return(false);
                }

                //Serial Number
                SerialNumber = RawData.Substring(2, RawData.Length - 3).Trim(new char[] { '\n', '\r', ' ', '\0', '@', '$', '%', '^', '&', '*', '+', '-' });

                //TestFlag
                if (RawData.EndsWith("1"))
                {
                    TestFlag = true;
                }
                else if (RawData.EndsWith("0"))
                {
                    TestFlag = false;
                }
                else
                {
                    Log.PrintLog(this, "ReceviedRobotMessage is invalid due to TestFlag : " + RawData.Last().ToString(), LogDetailLevel.LogRelevant);
                    return(false);
                }

                SocketID = ParsedSocketID;

                return(true);
            }
        public bool SaveTestProgram(bool SaveAs)
        {
            Log.PrintLog(this, "Saving test program.", LogDetailLevel.LogRelevant);

            SaveFileDialog TestProgSaveFileDialog = new SaveFileDialog();

            TestProgSaveFileDialog.Filter      = "xml Files (*.xml)|*.xml|All Files (*.*)|*.*";
            TestProgSaveFileDialog.FilterIndex = 1;
            TestProgSaveFileDialog.FileName    = TestFileName;// FullFileName;

            if ((File.Exists(FullFileName) == false) || (SaveAs == true) || (NoFileLoaded == true))
            {
                if (TestProgSaveFileDialog.ShowDialog() == DialogResult.Cancel)
                {
                    Log.PrintLog(this, "Save operation cancelled.", LogDetailLevel.LogRelevant);
                    return(false);
                }

                if (TestProgSaveFileDialog.FilterIndex == 1)
                {
                    TestFileName = Path.GetFileNameWithoutExtension(TestProgSaveFileDialog.FileName) + ".xml";
                }
                else
                {
                    TestFileName = Path.GetFileName(TestProgSaveFileDialog.FileName);
                }
                FullFileName = Path.GetDirectoryName(TestProgSaveFileDialog.FileName) + "\\" + TestFileName;
            }
            XmlWriter writer;

            try
            {
                writer = XmlWriter.Create(FullFileName);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "File operation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
            writer.WriteStartDocument(true);
            writer.WriteStartElement("CyBLEMTKTestProgram");
            {
                writer.WriteElementString("Name", TestFileName);
                writer.WriteElementString("NumberOfTests", TestProgram.Count.ToString());
                for (int i = 0; i < TestProgram.Count; i++)
                {
                    writer.WriteStartElement("Test");
                    {
                        writer.WriteElementString("TestIndex", i.ToString());
                        writer.WriteElementString("Name", TestProgram[i].ToString());
                        int temp = TestProgram[i].TestParameterCount;
                        writer.WriteElementString("NumberOfParamerters", temp.ToString());
                        for (int j = 0; j < TestProgram[i].TestParameterCount; j++)
                        {
                            writer.WriteElementString(TestProgram[i].GetTestParameterName(j), TestProgram[i].GetTestParameter(j));
                        }
                    }
                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();
            writer.Close();

            if (Path.GetFileNameWithoutExtension(TestFileName) == ("NewTestProgram" + NewFileCounter.ToString()))
            {
                NewFileCounter++;
            }
            NoFileLoaded = false;
            FileNotSaved = false;

            Log.PrintLog(this, "Test program successfully saved to " + FullFileName, LogDetailLevel.LogRelevant);
            return(true);
        }
Exemplo n.º 13
0
        private bool VerifyDeviceType()
        {
            if (SerialPortType == PortType.Host)
            {
                PrevHostConnStatus = CurHostConnStatus;
                SendCommand("WHO", 20);
                if (CommandResult != "HOST")
                {
                    CurHostConnStatus = "DISCONNECTED";
                    if (CurHostConnStatus != PrevHostConnStatus)
                    {
                        if (OnHostConnectionStatusChange != null)
                        {
                            OnHostConnectionStatusChange("DISCONNECTED");
                        }
                        if (CheckDUTPresence == true)
                        {
                            if (OnDUTConnectionStatusChange != null)
                            {
                                OnDUTConnectionStatusChange("DISCONNECTED");
                            }
                        }
                    }
                    return(false);
                }
                CurHostConnStatus = "CONNECTED";
                if (CurHostConnStatus != PrevHostConnStatus)
                {
                    if (OnHostConnectionStatusChange != null)
                    {
                        OnHostConnectionStatusChange("CONNECTED");
                    }
                }
                if (CheckDUTPresence == true)
                {
                    PrevDUTConnStatus = CommandResult;
                    SendCommand("PCS", 200);
                    if (PrevDUTConnStatus != CommandResult)
                    {
                        if (OnDUTConnectionStatusChange != null)
                        {
                            OnDUTConnectionStatusChange(CommandResult);
                        }
                    }
                }
            }
            else if ((SerialPortType == PortType.DUT) && (CheckDUTPresence))
            {
                PrevDUTConnStatus = CurDUTConnStatus;

                try
                {
                    _deviceSerialPort.WriteLine("AB");
                    Thread.Sleep(100);
                    string OuputACKNAC = _deviceSerialPort.ReadExisting();
                    if (!OuputACKNAC.Contains("AB"))
                    {
                        //SendCommand("WHO", 20);
                        _deviceSerialPort.WriteLine("\n");
                    }
                }
                catch
                {
                }

                SendCommand("WHO", 20);
                if (CommandResult != "DUT")
                {
                    CurDUTConnStatus = "DISCONNECTED";
                    if (CurDUTConnStatus != PrevDUTConnStatus)
                    {
                        if (OnDUTConnectionStatusChange != null)
                        {
                            OnDUTConnectionStatusChange("DISCONNECTED");
                        }
                    }
                    return(false);
                }
                CurDUTConnStatus = "CONNECTED";
                if (CurDUTConnStatus != PrevDUTConnStatus)
                {
                    if (OnDUTConnectionStatusChange != null)
                    {
                        OnDUTConnectionStatusChange("CONNECTED");
                    }
                }
            }
            else if (SerialPortType == PortType.Anritsu)
            {
                char[] DelimiterChars = { ',' };

                if (_connectionTime)
                {
                    _deviceSerialPort.WriteLine("*RST");
                    Thread.Sleep(3000);
                }

                _deviceSerialPort.WriteLine("*IDN?");
                Thread.Sleep(100);
                string   OuputACKNAC = _deviceSerialPort.ReadExisting();
                string[] Output      = OuputACKNAC.Split(DelimiterChars);

                if (Output.Count() >= 4)
                {
                    if ((Output[0] == "RANRITSU") && (Output[1] == "MT8852B"))
                    {
                        if (_connectionTime)
                        {
                            Log.PrintLog(this, "Device Found.", LogDetailLevel.LogRelevant);
                            Log.PrintLog(this, "Make: ANRITSU", LogDetailLevel.LogRelevant);
                            Log.PrintLog(this, "Model: " + Output[1], LogDetailLevel.LogRelevant);
                            Log.PrintLog(this, "Serial Number: " + Output[2], LogDetailLevel.LogRelevant);
                            Log.PrintLog(this, "Firmware Version: " + Output[3], LogDetailLevel.LogRelevant);
                        }
                    }
                    else
                    {
                        if (_connectionTime)
                        {
                            _deviceSerialPort.WriteLine("*RST");
                            Log.PrintLog(this, "Device unknown. Please reset the device and try again.", LogDetailLevel.LogRelevant);
                        }
                        return(false);
                    }
                }
                else
                {
                    if (_connectionTime)
                    {
                        _deviceSerialPort.WriteLine("*RST");
                        Log.PrintLog(this, "Device misbehaviour. Please reset the device and try again.", LogDetailLevel.LogRelevant);
                    }
                    return(false);
                }
            }

            return(true);
        }
 private void CloseButton_Click(object sender, EventArgs e)
 {
     Log.PrintLog(this, "Authentication cancelled.", LogDetailLevel.LogEverything);
     this.Close();
 }
Exemplo n.º 15
0
 public SFCS_FITTEC(LogManager Logger)
     : base(Logger)
 {
     Logger.PrintLog(this, "SFCS_FITTEC was initiated.", LogDetailLevel.LogRelevant);
 }
        public TryLogPrinting(LogManager log)
        {
            log.PrintLog(this, "TryTryTry....", LogDetailLevel.LogRelevant);

            speakout(log);
        }
 private void speakout(LogManager log)
 {
     log.PrintLog(this, "SpeakSpeakTryTryTry....", LogDetailLevel.LogRelevant);
 }
        protected override void OnLoad(EventArgs e)
        {
            Log.PrintLog(this, "Loading all settings.", LogDetailLevel.LogEverything);
            LoadAllSettings();
            base.OnLoad(e);

            PreferencesTreeView.ExpandAll();
            PreferencesTreeView.SelectedNode = PreferencesTreeView.Nodes["General"];
            PreferencesTreeView.Select();
            ApplyButton.Enabled = false;
            IsEdited            = false;
        }
 public MTKRobotHandler()
 {
     logger = new LogManager();
     logger.PrintLog(this, "ListenForClients() is running...", LogDetailLevel.LogRelevant);
     MessageSendWrongBack = "****SendWrongBack****";
 }