示例#1
0
 private void HeightMeas()
 {
     ReadData = "";
     MLCP.Write(mlcp.Start());
     MLCP.Write(bytes, 0, 1);
     while (true)
     {
         Application.DoEvents();
         if (ReadData != "")
         {
             break;
         }
     }
 }
示例#2
0
        private void MLCP_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            double HeightVal = Convert.ToDouble(info[2]);
            double Height2;

            ReadData = MLCP.ReadLine();

            strar   = ReadData.Split(',');
            chararr = strar[2].ToCharArray();
            double value;
            string str2;

            str2 = chararr[0].ToString() + chararr[1].ToString() + chararr[2].ToString() +
                   chararr[3].ToString() + chararr[4].ToString();
            bool isDouble = double.TryParse(str2, out value);

            if (isDouble)
            {
                str2 = chararr[0].ToString() + chararr[1].ToString() + "." + chararr[2].ToString() +
                       chararr[3].ToString() + chararr[4].ToString();
                str2    = str2.Trim();
                Height2 = Convert.ToDouble(str2) + HeightVal;
            }
            else
            {
                str2 = chararr[0].ToString() + "." + chararr[1].ToString() + chararr[2].ToString() +
                       chararr[3].ToString();
                str2    = str2.Trim();
                Height2 = Convert.ToDouble(str2) + HeightVal;
            }

            if (Txt_Test.InvokeRequired)
            {
                Txt_Test.BeginInvoke(new Action(() =>
                {
                    Txt_Test.Text = Height2.ToString();
                }));
            }
            else
            {
                Txt_Test.Text = Height2.ToString();
            }
        }
示例#3
0
        public SelfForm()
        {
            InitializeComponent();
            masterinfo = new MasterInfo(5);
            masterinfo.LoadInfo();
            //logfile = new LogFile();
            DAQ1        = new DAQ();
            DAQ2        = new DAQ();
            DAQ3        = new DAQ();
            DAQ4        = new DAQ();
            DAQ5        = new DAQ();
            barcoderead = new BarcodeRead();
            mlcp        = new MLCP();
            bin         = new Binary();

            nmfdio = new NMFDIO();

            inifile = new IniFiles(@"C:\Users\abc\Data\Option.ini");
            Spec    = new List <string>();
            //Spec = logfile.LoadSpec(2, 92);
            IP       = new short[3];
            NMFstate = new int[3];

            ReadData = "";
            ID       = "";
            IsNICon  = false;
            IsNMFCon = false;
            bytes    = ConvertByteArray("0D");
            list     = new List <string>();
            info     = new List <string>();
            info2    = new List <bool>();
            //strar = new string[5];
            bin.Load(@"C:\Users\abc\Data\Spec\Spec1", ref info, ref info2);

            NIName = inifile.ReadString("NI", "DevName", "");
            if (NIName == "")
            {
                MessageBox.Show("Option 탭에서 NI DevName을 확인해주세요");
            }
            try
            {
                IP[0]  = Convert.ToInt16(inifile.ReadString("NMF", "DevName1", ""));
                IP[1]  = Convert.ToInt16(inifile.ReadString("NMF", "DevName2", ""));
                IP[2]  = Convert.ToInt16(inifile.ReadString("NMF", "DevName3", ""));
                DevNum = Convert.ToInt16(inifile.ReadString("NMF", "DevName4", ""));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Option 탭에서 NMF DevName을 확인해주세요");
            }

            //SSC_.Open();
            try
            {
                BarcodeScanner1.PortName = inifile.ReadString("Barcode1", "PortName", "");
                BarcodeScanner2.PortName = inifile.ReadString("Barcode2", "PortName", "");
                MLCP.PortName            = inifile.ReadString("Meter", "PortName", "");
                SSC_.PortName            = inifile.ReadString("SSC", "PortName", "");
                //Idread = new IDRead(inifile.ReadString("SSC", "PortName", ""), 19200);

                BarcodeScanner1.Open();
                BarcodeScanner2.Open();
                MLCP.Open();
                SSC_.Open();
                //Idread.Connect();
            }
            catch
            {
                MessageBox.Show("장비 연결을 확인해주세요");
            }

            //IsNMFCon = nmfdio.Connect(DevNum, IP[0], IP[1], IP[2], 200);

            DAQ1.Analog_Connect(NIName, "ai0");
            DAQ2.Analog_Connect(NIName, "ai1");
            DAQ3.Analog_Connect(NIName, "ai2");
            DAQ4.Analog_Connect(NIName, "ai3");
            DAQ5.Analog_Connect(NIName, "ai4");
            DAQ1.Digital_Connect(NIName);
            DAQ2.Digital_Connect(NIName);
            DAQ3.Digital_Connect(NIName);
            DAQ4.Digital_Connect(NIName);
        }