private void WriteReadInfoFromDp()
        {
            int DpPtr = 0;

            for (byte i = 0; i < classCalibrationSettings.JigConfiguration; i++)
            {
                if (classCalibrationSettings.ConnectedChanels[i] == true)
                {
                    for (int j = 0; j < MAX_ALLOW_SEND_GET_INFO_CMD; j++)
                    {
                        classMultiplexingInstanse.ConnectDpDevice(i);
                        Thread.Sleep(250);

                        //read current pressure from plc...
                        ReadPressureFromPlc();

                        //classDpCommunicationInstanse.DpWritePressurePointToDevice(classCalibrationSettings.TempUnderTestList[CurrentCalibTempIndex], CurrentCalibTempIndex, classCalibrationSettings.PressureUnderTestList[CurrentCalibPressureIndex], CurrentCalibPressureIndex);
                        classDpCommunicationInstanse.DpWritePressurePointToDevice(classCalibrationSettings.TempUnderTestList[CurrentCalibTempIndex], CurrentCalibTempIndex, PlcAdc2Bar(CurrentPressure), CurrentCalibPressureIndex);
                        Thread.Sleep(2000);

                        if (classDpCommunicationInstanse.NewDpInfoEvent) // check if recieve data from DP
                        {
                            //save the data on the current device and current calibpoint..
                            classDevices[DpPtr].CalibrationData[CurrentCalibTempIndex, CurrentCalibPressureIndex].PressureValue1 = classDpCommunicationInstanse.dpInfo.S1Pressure;
                            classDevices[DpPtr].CalibrationData[CurrentCalibTempIndex, CurrentCalibPressureIndex].PressureValue2 = classDpCommunicationInstanse.dpInfo.S2Pressure;
                            classDevices[DpPtr].CalibrationData[CurrentCalibTempIndex, CurrentCalibPressureIndex].tempOnDevice   = classDpCommunicationInstanse.dpInfo.CurrentTemp;
                            classDevices[DpPtr].CalibrationData[CurrentCalibTempIndex, CurrentCalibPressureIndex].LeftA2DValue   = classDpCommunicationInstanse.dpInfo.LeftA2D;
                            classDevices[DpPtr].CalibrationData[CurrentCalibTempIndex, CurrentCalibPressureIndex].RightA2DValue  = classDpCommunicationInstanse.dpInfo.RightA2D;
                            classDevices[DpPtr].DeviceMacAddress = classDpCommunicationInstanse.dpInfo.DeviseMacAddress;

                            classDevices[DpPtr].CalibrationData[CurrentCalibTempIndex, CurrentCalibPressureIndex].extA2dPressureValue = PlcAdc2Bar(CurrentPressure);

                            classDpCommunicationInstanse.NewDpInfoEvent = false;
                            //classDpCommunicationInstanse.DPgetDpInfo();

                            if (CurrentCalibPressureIndex == (classCalibrationSettings.PressureUnderTestList.Count - 1) && (CurrentCalibTempIndex == classCalibrationSettings.TempUnderTestList.Count - 1))
                            {
                                //send end calibration CMD
                                classDpCommunicationInstanse.SendEndCalibration();
                                if (classDevices[DpPtr].deviceStatus == DeviceStatus.Wait)
                                {
                                    classDevices[DpPtr].deviceStatus = DeviceStatus.Pass;
                                }
                            }
                            j = MAX_ALLOW_SEND_GET_INFO_CMD; // break the for loop...
                        }
                        else
                        {
                            if (j == MAX_ALLOW_SEND_GET_INFO_CMD)
                            {
                                classDevices[DpPtr].deviceStatus = DeviceStatus.Fail;
                            }
                        }
                    }
                    DpPtr++;
                }
            }
        }
Example #2
0
        private void bt_startProgram_Click(object sender, EventArgs e)
        {
            EnableProgram = true;
            for (byte i = 0; i < classCalibrationInfo.DpCountAxist && EnableProgram == true; i++)
            {
                MultiplexingProtocolInstanse.ConnectDpDevice(i);
                // need implamnt wait to insure that the device are connected


                //string RealTimeData = string.Format("Start Program DP Number {0}. Serial number:{1}.",i.ToString(), classCalibrationInfo.classDevices[i].DeviceSerialNumber.ToString());
                string RealTimeData = string.Format(Properties.Settings.Default.FlashProgrammerToolPath);
                lbl_info.Text = RealTimeData;

                bool res = FlashDpDevice(Properties.Settings.Default.HexFilePath);

                DGVSetCellColor(dgv_dpTableInfo, 1, i, res ? Color.Green: Color.Red);
            }
            EnableProgram = false;
        }