Example #1
0
        public bool WriteMeasureDetail(int rowStart, MeasureDetail measureDetail, emMeasureType MeasureType)
        {
            if (_package == null || _excelWorksheet == null)
            {
                return(false);
            }

            try
            {
                _excelWorksheet.Cells[NO + rowStart].Value    = measureDetail.No;
                _excelWorksheet.Cells[TIME + rowStart].Value  = measureDetail.Time?.ToString(cstrDateTimeFomatShow);
                _excelWorksheet.Cells[VALUE + rowStart].Value = measureDetail.Value;

                var range = string.Format("{0}{2}:{1}{2}", NO, RESULT, rowStart.ToString());

                if (MeasureType == emMeasureType.AlarmTest)
                {
                    _excelWorksheet.Cells[RESULT + rowStart].Value = measureDetail.Result;
                }
                else
                {
                    range = string.Format("{0}{2}:{1}{2}", NO, VALUE, rowStart.ToString());
                }

                _excelWorksheet.Cells[range].Style.Border.Top.Style    = ExcelBorderStyle.Thin;
                _excelWorksheet.Cells[range].Style.Border.Left.Style   = ExcelBorderStyle.Thin;
                _excelWorksheet.Cells[range].Style.Border.Right.Style  = ExcelBorderStyle.Thin;
                _excelWorksheet.Cells[range].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Example #2
0
        private void MeasureStart(int intDev, emMeasureType type = emMeasureType.AlarmTest)
        {
            MeasureType = type;

            // Get info custom input
            if (!GetInputDevice(intDev))
            {
                return;
            }

            var GraphTitle = lblAlarmTest.Text.Trim();

            telnetDSF      = new TelnetInterfaceDsf();
            _measureResult = (int)emMeasureResult.Normal;

            if (MeasureType == emMeasureType.WalkingTest)
            {
                _measureResult = (int)emMeasureResult.Pass;
                GraphTitle     = lblWalkingTest.Text.Trim();
            }

            try
            {
                if (telnetDSF.ConnectToServer(_deviceCurrent.ipAddress, _deviceCurrent.port))
                {
                    telnetDSF.OnDataReceived += new ClientHandlePacketData(client_OnDataReceived);
                    telnetDSF.ProcessErrors  += new ClientHandleWhenHasErrors(client_ProcessErrors);

                    ResetMeasure();
                    ModeMeasure(_deviceCurrent.deviceType);

                    GraphInit(GraphTitle + " " + DateTime.Now.ToString(cstrDateTimeFomatShow),
                              MeasureType == emMeasureType.WalkingTest ? _deviceCurrent.failLevel : _deviceCurrent.AlarmValue);

                    _iSetting.MeasureType   = MeasureType;
                    _iSetting.DeviceCurrent = _deviceCurrent;
                    _iSetting.MeasureStart();

                    _flagInsertDetail = true;
                    _threadInsert     = new Thread(new ThreadStart(CallProcessData));
                    _threadInsert.Start();
                    telnetDSF.Start();

                    if (MeasureType == emMeasureType.WalkingTest)
                    {
                        timerWalkingTest.Interval = Math.Abs(_deviceCurrent.period * 1000);
                        timerWalkingTest.Start();
                    }

                    _blnStartMeasure = true;
                }
                else
                {
                    telnetDSF = null;
                    ShowMsg(MessageBoxIcon.Error, MSG_ERR_CONNECT);
                }
            }
            catch
            {
                ShowMsg(MessageBoxIcon.Error, MSG_ERR_CONNECT);
            }
        }