Exemple #1
0
        private void BtnStart_OnClick(object sender, RoutedEventArgs e)
        {
            if (IsRunning)
            {
                return;
            }

            //если пресс был зажат вручную - не стоит пробовать зажимать его ещё раз
            ClampParameters.SkipClamping = Cache.Clamp.ManualClamping;

            var commPar = new Types.Commutation.TestParameters()
            {
                BlockIndex      = (!Cache.Clamp.UseTmax) ? Types.Commutation.HWBlockIndex.Block1 : Types.Commutation.HWBlockIndex.Block2,
                CommutationType = ConverterUtil.MapCommutationType(CommType),
                Position        = ConverterUtil.MapModulePosition(ModPosition)
            };

            var parameters = new List <BaseTestParametersAndNormatives>(1);

            parameters.Add(Parameters);

            if (!Cache.Net.Start(commPar, ClampParameters, parameters))
            {
                return;
            }
            IsRunning = true;
        }
Exemple #2
0
        internal DeviceState Start(TestParameters Parameters, Types.Commutation.TestParameters commParameters)
        {
            _Parameters = Parameters;

            if (_State == DeviceState.InProcess)
            {
                throw new Exception("TOU test is already started");
            }

            _Result = new TestResults()
            {
                TestTypeId = _Parameters.TestTypeId,
            };

            if (!_IsTOUEmulation)
            {
                //Считываем регистр состояния
                var devState = (HWDeviceState)ReadRegister(REG_DEV_STATE);
                //Проверяем на наличие ошибки либо отключения
                CheckDevStateThrow(devState);
                if (devState != HWDeviceState.Ready)
                {
                    string error = "Launch test, TOU State not Ready, function Start";
                    SystemHost.Journal.AppendLog(ComplexParts.TOU, LogMessageType.Note, error);
                    throw new Exception(error);
                }
            }

            MeasurementLogicRoutine(commParameters);

            return(_State);
        }
Exemple #3
0
        internal DeviceState Start(TestParameters Parameters, Types.Commutation.TestParameters commParameters)
        {
            m_Parameters = Parameters;

            if (m_State == DeviceState.InProcess)
            {
                throw new Exception("IH test is already started.");
            }

            m_Result            = new TestResults();
            m_Result.TestTypeId = m_Parameters.TestTypeId;

            m_Stop = false;

            if (!m_IsEmulation)
            {
                //смотрим состояние Gate
                m_IOGate.ClearWarning();
                ushort State = m_IOGate.ReadDeviceState();

                switch (State)
                {
                case (ushort)Types.Gate.HWDeviceState.Fault:
                    ushort faultReason = m_IOGate.ReadFaultReason();
                    FireNotificationEvent(ComplexParts.Gate, (ushort)HWProblemReason.None, (ushort)HWWarningReason.None, faultReason, (ushort)HWDisableReason.None);

                    break;

                case (ushort)Types.Gate.HWDeviceState.Disabled:
                    ushort disableReason = m_IOGate.ReadDisableReason();
                    FireNotificationEvent(ComplexParts.Gate, (ushort)HWProblemReason.None, (ushort)HWWarningReason.None, (ushort)HWFaultReason.None, disableReason);

                    break;
                }

                //смотрим состояние StLs
                m_IOStLs.ClearWarning();
                State = m_IOStLs.ReadDeviceState();

                switch (State)
                {
                case (ushort)Types.VTM.HWDeviceState.Fault:
                    ushort faultReason = m_IOStLs.ReadFaultReason();
                    FireNotificationEvent(ComplexParts.SL, (ushort)HWProblemReason.None, (ushort)HWWarningReason.None, faultReason, (ushort)HWDisableReason.None);

                    break;

                case (ushort)Types.VTM.HWDeviceState.Disabled:
                    ushort disableReason = m_IOStLs.ReadDisableReason();
                    FireNotificationEvent(ComplexParts.SL, (ushort)HWProblemReason.None, (ushort)HWWarningReason.None, (ushort)HWFaultReason.None, disableReason);

                    break;
                }
            }

            MeasurementLogicRoutine(commParameters);

            return(m_State);
        }
Exemple #4
0
        internal DeviceState Start(Types.BVT.TestParameters parameters, Types.Commutation.TestParameters commParameters)
        {
            m_Parameters = parameters;

            if (m_State == DeviceState.InProcess)
            {
                throw new Exception("BVT test is already started");
            }

            m_Result = new Types.BVT.TestResults {
                TestTypeId = parameters.TestTypeId
            };
            m_Stop = false;

            ClearWarning();

            if (!m_IsBVTEmulation)
            {
                var devState = (Types.BVT.HWDeviceState)ReadRegister(REG_DEVICE_STATE);
                if (devState == Types.BVT.HWDeviceState.Fault)
                {
                    var faultReason = (Types.BVT.HWFaultReason)ReadRegister(REG_FAULT_REASON);
                    FireNotificationEvent(Types.BVT.HWProblemReason.None, Types.BVT.HWWarningReason.None, faultReason,
                                          Types.BVT.HWDisableReason.None);

                    throw new Exception(string.Format("BVT is in fault state, reason: {0}", faultReason));
                }

                if (devState == Types.BVT.HWDeviceState.Disabled)
                {
                    var disableReason = (Types.BVT.HWDisableReason)ReadRegister(REG_DISABLE_REASON);
                    FireNotificationEvent(Types.BVT.HWProblemReason.None, Types.BVT.HWWarningReason.None,
                                          Types.BVT.HWFaultReason.None, disableReason);

                    throw new Exception(string.Format("BVT is in disabled state, reason: {0}", disableReason));
                }
            }

            m_State = DeviceState.InProcess;
            FireBvtAllEvent(m_State);

            MeasurementLogicRoutine(commParameters);

            if (m_State != DeviceState.Success)
            {
                FireBvtAllEvent(m_State);
            }

            return(m_State);
        }
Exemple #5
0
        private void BtnStart_OnClick(object sender, RoutedEventArgs e)
        {
            if (VM.IsRunning)
            {
                return;
            }

            VM.IsRunning = true;

            var paramGate = new Types.Gate.TestParameters {
                IsEnabled = false
            };
            var paramVtm = new Types.VTM.TestParameters {
                IsEnabled = false
            };
            var paramBvt = new Types.BVT.TestParameters {
                IsEnabled = false
            };
            var paramATU = new Types.ATU.TestParameters {
                IsEnabled = false
            };
            var paramQrrTq = new Types.QrrTq.TestParameters {
                IsEnabled = false
            };
            var paramIH = new Types.IH.TestParameters {
                IsEnabled = false
            };
            var paramRCC = new Types.RCC.TestParameters {
                IsEnabled = false
            };

            //если пресс был зажат вручную - не стоит пробовать зажимать его ещё раз
            VM.Clamping.SkipClamping = Cache.Clamp.ManualClamping;

            Types.Commutation.TestParameters commutation = new Types.Commutation.TestParameters()
            {
                BlockIndex      = (!Cache.Clamp.UseTmax) ? Types.Commutation.HWBlockIndex.Block1 : Types.Commutation.HWBlockIndex.Block2,
                CommutationType = ConverterUtil.MapCommutationType(VM.CommutationType),
                Position        = ConverterUtil.MapModulePosition(VM.Position)
            };



            if (!Cache.Net.Start(paramGate, paramVtm, paramBvt, paramATU, paramQrrTq, paramIH, paramRCC, commutation, VM.Clamping, VM.TOU))
            {
                return;
            }

            ClearStatus();
        }
Exemple #6
0
        internal DeviceState Start(TestParameters Parameters, Types.Commutation.TestParameters commParameters, out RCCResult resultRCC)
        {
            m_Parameters = Parameters;

            if (m_State == DeviceState.InProcess)
            {
                throw new Exception("RCC test is already started.");
            }

            m_Result            = new TestResults();
            m_Result.TestTypeId = m_Parameters.TestTypeId;

            m_Stop = false;

            if (!m_IsEmulation)
            {
                //результат прозвонки цепи катод-катод не определён
                resultRCC = RCCResult.OPRESULT_NONE;

                //смотрим состояние Gate
                m_IOGate.ClearWarning();
                ushort State = m_IOGate.ReadDeviceState();

                switch (State)
                {
                case (ushort)Types.Gate.HWDeviceState.Fault:
                    ushort faultReason = m_IOGate.ReadFaultReason();
                    FireNotificationEvent(ComplexParts.Gate, (ushort)HWProblemReason.None, (ushort)HWWarningReason.None, faultReason, (ushort)HWDisableReason.None);

                    return((DeviceState)State);

                case (ushort)Types.Gate.HWDeviceState.Disabled:
                    ushort disableReason = m_IOGate.ReadDisableReason();
                    FireNotificationEvent(ComplexParts.Gate, (ushort)HWProblemReason.None, (ushort)HWWarningReason.None, (ushort)HWFaultReason.None, disableReason);

                    return((DeviceState)State);
                }
            }

            MeasurementLogicRoutine(commParameters);

            resultRCC = m_Result.RCC;

            return(m_State);
        }
Exemple #7
0
        private void MeasurementLogicRoutine(Types.Commutation.TestParameters Commutation)
        {
            try
            {
                m_State = DeviceState.InProcess;
                FireAllEvent(m_State);

                if (m_IOCommutation.Switch(Types.Commutation.CommutationMode.Gate, Commutation.CommutationType, Commutation.Position) ==
                    DeviceState.Fault)
                {
                    m_State = DeviceState.Fault;
                    FireAllEvent(m_State);
                    return;
                }

                if (Kelvin())
                {
                    Resistance();
                    IgtVgt();
                    Ih();
                    Il();
                }

                if (m_IOCommutation.Switch(Types.Commutation.CommutationMode.None) == DeviceState.Fault)
                {
                    m_State = DeviceState.Fault;
                    FireAllEvent(m_State);
                    return;
                }

                m_State = m_Stop ? DeviceState.Stopped : DeviceState.Success;

                FireAllEvent(m_State);
            }
            catch (Exception ex)
            {
                m_IOCommutation.Switch(Types.Commutation.CommutationMode.None);

                m_State = DeviceState.Fault;
                FireAllEvent(m_State);
                FireExceptionEvent(ex.Message);

                throw;
            }
        }
Exemple #8
0
        internal DeviceState Start(TestParameters Parameters, Types.Commutation.TestParameters commParameters)
        {
            m_Parameters = Parameters;

            if (m_State == DeviceState.InProcess)
            {
                throw new Exception("dVdt test is already started");
            }

            m_Result = new TestResults()
            {
                TestTypeId  = m_Parameters.TestTypeId,
                Mode        = m_Parameters.Mode,
                VoltageRate = (ushort)Parameters.VoltageRate
            };
            m_Stop = false;

            ClearWarning();

            if (!m_IsdVdtEmulation)
            {
                var devState = (HWDeviceState)ReadRegister(REG_DEVICE_STATE);
                if (devState == HWDeviceState.Fault)
                {
                    var faultReason = (HWFaultReason)ReadRegister(REG_FAULT_REASON);
                    FireNotificationEvent(HWWarningReason.None, faultReason,
                                          HWDisableReason.None);

                    throw new Exception(string.Format("dVdt is in fault state, reason: {0}", faultReason));
                }

                if (devState == HWDeviceState.Disabled)
                {
                    var disableReason = (HWDisableReason)ReadRegister(REG_DISABLE_REASON);
                    FireNotificationEvent(HWWarningReason.None,
                                          HWFaultReason.None, disableReason);

                    throw new Exception(string.Format("dVdt is in disabled state, reason: {0}", disableReason));
                }
            }

            MeasurementLogicRoutine(commParameters);

            return(m_State);
        }
Exemple #9
0
        private void MeasurementLogicRoutine(Types.Commutation.TestParameters Commutation)
        {
            try
            {
                m_State = DeviceState.InProcess;

                //уведомляем UI о том, что мы находимся в состоянии m_State с результатами измерений m_Result
                FireEvent(m_State, m_Result);

                if (m_IsEmulation)
                {
                    //эмулируем успешный результат измерений
                    m_State      = DeviceState.Success;
                    m_Result.RCC = RCCResult.OPRESULT_OK;
                }
                else
                {
                    //включаем требуемую коммутацию
                    m_IOCommutation.WriteRegister(IOCommutation.REG_MODULE_TYPE, (ushort)Commutation.CommutationType);
                    m_IOCommutation.CallAction(IOCommutation.ACT_COMM2_RCC);

                    //запускаем прозвонку цепи катод-катод
                    m_IOGate.CallAction(IOGate.ACT_START_RCC);

                    WaitForEndOfGateTest();

                    //прозвонка цепи катод-катод успешно исполнена
                    m_State = DeviceState.Success;

                    //считываем значение регистра результата
                    m_Result.RCC = (RCCResult)m_IOGate.ReadRegister(IOGate.REG_TEST_FINISHED);
                }

                FireEvent(m_State, m_Result);
            }
            catch (Exception e)
            {
                m_State = DeviceState.Fault;
                FireEvent(m_State, m_Result);
                FireExceptionEvent(e.Message);

                throw;
            }
        }
Exemple #10
0
        internal DeviceState Start(TestParameters Parameters, Types.Commutation.TestParameters commParameters)
        {
            m_Parameters = Parameters;

            if (m_State == DeviceState.InProcess)
            {
                throw new Exception("QrrTq test is already started.");
            }

            //запоминаем в каком режиме будут выполняться измерения
            m_Result = new TestResults {
                Mode = m_Parameters.Mode, OffStateVoltage = m_Parameters.OffStateVoltage, OsvRate = (ushort)m_Parameters.OsvRate
            };
            m_Result.TestTypeId = m_Parameters.TestTypeId;

            m_Stop = false;

            if (!m_IsEmulation)
            {
                ushort State = ReadRegister(REG_DEV_STATE);

                switch (State)
                {
                case (ushort)HWDeviceState.DS_Fault:
                    ushort faultReason = ReadRegister(REG_FAULT_REASON);
                    FireNotificationEvent((ushort)HWProblemReason.None, (ushort)HWWarningReason.None, faultReason, (ushort)HWDisableReason.None);

                    break;

                case (ushort)HWDeviceState.DS_Disabled:
                    ushort disableReason = ReadRegister(REG_DISABLE_REASON);
                    FireNotificationEvent((ushort)HWProblemReason.None, (ushort)HWWarningReason.None, (ushort)HWFaultReason.None, disableReason);

                    break;
                }
            }

            MeasurementLogicRoutine(commParameters);

            return(m_State);
        }
Exemple #11
0
        internal DeviceState Start(TestParameters Parameters, Types.Commutation.TestParameters commParameters)
        {
            m_Parameters = Parameters;

            if (m_State == DeviceState.InProcess)
            {
                throw new Exception("ATU test is already started.");
            }

            m_Result            = new TestResults();
            m_Result.TestTypeId = m_Parameters.TestTypeId;

            m_Stop = false;

            if (!m_IsATUEmulation)
            {
                ushort State = ReadRegister(REG_DEV_STATE);

                switch (State)
                {
                case (ushort)HWDeviceState.DS_Fault:
                    ushort faultReason = ReadRegister(REG_FAULT_REASON);

                    FireNotificationEvent((ushort)HWWarningReason.None, faultReason, (ushort)HWDisableReason.None);

                    throw new Exception(string.Format("ATU is in 'DS_Fault' state, reason: {0}", faultReason));

                case (ushort)HWDeviceState.DS_Disabled:
                    ushort disableReason = ReadRegister(REG_DISABLE_REASON);

                    FireNotificationEvent((ushort)HWWarningReason.None, (ushort)HWFaultReason.None, disableReason);

                    throw new Exception(string.Format("ATU is in 'DS_Disabled' state, reason: {0}", disableReason));
                }
            }

            MeasurementLogicRoutine(commParameters);

            return(m_State);
        }
Exemple #12
0
        private void BtnStart_OnClick(object sender, RoutedEventArgs e)
        {
            UserSettings.Default.ShuntResistance = TextBoxResistance.Text;
            UserSettings.Default.Save();
            StartButtonEnabled(false);

            ClearStatus();
            CommType = Settings.Default.SinglePositionModuleMode ? Types.Commutation.ModuleCommutationType.Direct : Types.Commutation.ModuleCommutationType.MT3;
            var commPar = new Types.Commutation.TestParameters()
            {
                BlockIndex      = (!Cache.Clamp.UseTmax) ? Types.Commutation.HWBlockIndex.Block1 : Types.Commutation.HWBlockIndex.Block2,
                CommutationType = ConverterUtil.MapCommutationType(CommType),
                Position        = ConverterUtil.MapModulePosition(ModPosition)
            };

            //если пресс был зажат вручную - не стоит пробовать зажимать его ещё раз
            ClampParameters.SkipClamping = Cache.Clamp.ManualClamping;

            var parameters = new List <BaseTestParametersAndNormatives>(1);

            parameters.Add(Parameters);

            Cache.Net.Start(commPar, ClampParameters, parameters);
        }
Exemple #13
0
 bool IExternalControl.Start(Types.Gate.TestParameters ParametersGate, Types.VTM.TestParameters ParametersSL,
                             Types.BVT.TestParameters ParametersBvt, Types.ATU.TestParameters ParametersAtu, Types.QrrTq.TestParameters ParametersQrrTq, Types.IH.TestParameters ParametersIH, Types.RCC.TestParameters ParametersRCC,
                             Types.Commutation.TestParameters ParametersComm, Types.Clamping.TestParameters ParametersClamp, Types.TOU.TestParameters ParametersTOU)
 {
     return(_IoMain.Start(ParametersGate, ParametersSL, ParametersBvt, ParametersAtu, ParametersQrrTq, ParametersIH, ParametersRCC, ParametersComm, ParametersClamp, ParametersTOU));
 }
Exemple #14
0
        private void MeasurementLogicRoutine(Types.Commutation.TestParameters Commutation)
        {
            try
            {
                m_State = DeviceState.InProcess;
                FireVTMEvent(m_State, m_Result, 0);

                var timeStamp = Environment.TickCount + m_Timeout;

                if (!m_IsSLEmulation)
                {
                    while (Environment.TickCount < timeStamp)
                    {
                        var devState = (Types.VTM.HWDeviceState)ReadRegister(REG_DEVICE_STATE, true);
                        if (devState == Types.VTM.HWDeviceState.PowerReady)
                        {
                            break;
                        }

                        Thread.Sleep(50);
                    }
                }

                if (Environment.TickCount > timeStamp)
                {
                    m_State = DeviceState.Fault;
                    return;
                }

                if (!m_Parameter.IsSelfTest)
                {
                    if (m_IOCommutation.Switch(Types.Commutation.CommutationMode.VTM, Commutation.CommutationType, Commutation.Position) == DeviceState.Fault)
                    {
                        m_State = DeviceState.Fault;
                        FireVTMEvent(m_State, m_Result, 0);
                        return;
                    }
                }

                var current = 0;

                if (!m_IsSLEmulation)
                {
                    if (m_Parameter.IsSelfTest)
                    {
                        m_Result.CapacitorsArray = new List <float>
                        {
                            ReadRegister(REG_V11, true) / 10.0f,
                            ReadRegister(REG_V12, true) / 10.0f,
                            ReadRegister(REG_V21, true) / 10.0f,
                            ReadRegister(REG_V22, true) / 10.0f,
                            ReadRegister(REG_V31, true) / 10.0f,
                            ReadRegister(REG_V32, true) / 10.0f,
                            ReadRegister(REG_V41, true) / 10.0f,
                            ReadRegister(REG_V42, true) / 10.0f,
                            ReadRegister(REG_V51, true) / 10.0f,
                            ReadRegister(REG_V52, true) / 10.0f
                        };

                        CallAction(ACT_RUN_SELF_TEST);

                        for (var i = 0; i < m_Result.CapacitorsArray.Count; i++)
                        {
                            if (m_Result.CapacitorsArray[i] > 100)
                            {
                                m_Result.CapacitorsArray[i] = 100;
                            }
                        }
                    }
                    else
                    {
                        switch (m_Parameter.TestType)
                        {
                        case Types.VTM.VTMTestType.Ramp:
                        {
                            WriteRegister(REG_MEASUREMENT_TYPE, MEASURE_RAMP);
                            WriteRegister(REG_RAMP_DESIRED_CURRENT, m_Parameter.RampCurrent);
                            WriteRegister(REG_RAMP_DESIRED_TIME, m_Parameter.RampTime);
                            WriteRegister(REG_HEATING_ENABLE, (ushort)(m_Parameter.IsRampOpeningEnabled ? 1 : 0));

                            if (m_Parameter.IsRampOpeningEnabled)
                            {
                                WriteRegister(REG_HEATING_CURRENT, m_Parameter.RampOpeningCurrent);
                                WriteRegister(REG_HEATING_TIME, m_Parameter.RampOpeningTime);
                            }

                            current = m_Parameter.RampCurrent;
                        }
                        break;

                        case Types.VTM.VTMTestType.Sinus:
                        {
                            WriteRegister(REG_MEASUREMENT_TYPE, MEASURE_SIN);
                            WriteRegister(REG_SIN_DESIRED_CURRENT, m_Parameter.SinusCurrent);
                            WriteRegister(REG_SIN_DESIRED_TIME, m_Parameter.SinusTime);

                            current = m_Parameter.SinusCurrent;
                        }
                        break;

                        case Types.VTM.VTMTestType.Curve:
                        {
                            WriteRegister(REG_MEASUREMENT_TYPE, MEASURE_S_CURVE);
                            WriteRegister(REG_SCURVE_DESIRED_CURRENT, m_Parameter.CurveCurrent);
                            WriteRegister(REG_SCURVE_DESIRED_TIME, m_Parameter.CurveTime);
                            WriteRegister(REG_SCURVE_ADD_TIME, m_Parameter.CurveAddTime);
                            WriteRegister(REG_SCURVE_FACTOR, m_Parameter.CurveFactor);

                            current = m_Parameter.CurveCurrent;
                        }
                        break;
                        }

                        WriteRegister(REG_USE_FULL_SCALE, (ushort)(m_Parameter.UseFullScale ? 1 : 0));
                        WriteRegister(REG_DISABLE_VTM_PP, (ushort)(m_Parameter.UseLsqMethod ? 0 : 1));

                        WriteRegister(REG_REPETITION_COUNT, m_Parameter.Count);
                        CallAction(ACT_START_TEST);
                    }

                    m_State = WaitForEndOfTest();
                }
                else
                {
                    m_State = DeviceState.Success;
                }

                if (!m_Parameter.IsSelfTest)
                {
                    if (m_IOCommutation.Switch(Types.Commutation.CommutationMode.None) == DeviceState.Fault)
                    {
                        m_State = DeviceState.Fault;
                        FireVTMEvent(m_State, m_Result, 0);
                        return;
                    }
                }

                m_Result.IsSelftest = m_Parameter.IsSelfTest;

                if (m_IsSLEmulation)
                {
                    m_Result.Voltage = EMU_DEFAULT_VTM;
                    m_Result.Current = EMU_DEFAULT_ITM;
                }
                else
                {
                    m_Result.Voltage = ReadRegister(REG_TEST_RESULT);
                    m_Result.Current = ReadRegister(REG_TEST_CURRENT_RESULT);

                    if (m_ReadGraph)
                    {
                        m_Result.DesiredArray = ReadArrayFastS(ARR_SCOPE_DESIRED);
                        m_Result.ITMArray     = ReadArrayFastS(ARR_SCOPE_ITM);
                        m_Result.VTMArray     = ReadArrayFastS(ARR_SCOPE_VTM);
                    }

                    if (m_Parameter.IsSelfTest)
                    {
                        m_Result.SelfTestArray = ReadArrayFastS(ARR_SELF_TEST);
                    }
                }

                FireVTMEvent(m_State, m_Result, current);
            }
            catch (Exception ex)
            {
                if (!m_Parameter.IsSelfTest)
                {
                    m_IOCommutation.Switch(Types.Commutation.CommutationMode.None);
                }

                m_State = DeviceState.Fault;
                FireVTMEvent(DeviceState.Fault, m_Result, 0);
                FireExceptionEvent(ex.Message);

                throw;
            }
        }
Exemple #15
0
        private void MeasurementLogicRoutine(Types.Commutation.TestParameters Commutation)
        {
            try
            {
                m_State = DeviceState.InProcess;

                //сбрасываем возможные предупреждения
                CallAction(ACT_CLR_WARNING);

                //уведомляем UI о том, что мы находимся в состоянии m_State с результатами измерений m_Result
                FireQrrTqEvent(m_State, m_Result);

                //пишем тип измерения
                WriteRegister(REG_MODE, (ushort)m_Parameters.Mode);

                //пишем амплитуду прямого тока (в А)
                WriteRegister(REG_DIRECT_CURRENT, m_Parameters.DirectCurrent);

                //пишем длительность импульса прямого тока (в мкс)
                WriteRegister(REG_DC_PULSE_WIDTH, m_Parameters.DCPulseWidth);

                //пишем скорость нарастания прямого тока (в А/мкс)
                WriteRegister(REG_DC_RISE_RATE, (ushort)(m_Parameters.DCRiseRate * 10));

                //пишем скорость спада тока (в А/мкс)
                ushort DCFallRate = (ushort)m_Parameters.DCFallRate;
                WriteRegister(REG_DC_FALL_RATE, (ushort)(DCFallRate * 10));

                //пишем прямое повторное напряжение (в В)
                WriteRegister(REG_OFF_STATE_VOLTAGE, m_Parameters.OffStateVoltage);

                //пишем скорость нарастания прямого повторного напряжения (в В/мкс)
                if (m_Parameters.Mode == TMode.QrrTq)
                {
                    ushort OsvRate = (ushort)m_Parameters.OsvRate;
                    WriteRegister(REG_OSV_RATE, OsvRate);
                }

                //пишем метод измерения Trr "Измерение trr по методу 90%-50%"
                int TrrMeasureBy9050Method = m_Parameters.TrrMeasureBy9050Method == false ? 0 : 1;
                WriteRegister(REG_TRR_MEASURE_BY_9050_METHOD, (ushort)TrrMeasureBy9050Method);

                if (m_IsEmulation)
                {
                    //эмулируем успешный результат измерений
                    m_State = DeviceState.Success;

                    Random rnd = new Random();
                    FireKindOfFreezingEvent((ushort)rnd.Next(1, 1000));

                    m_Result.Idc            = 1;
                    m_Result.Qrr            = 2 / 10f;
                    m_Result.Irr            = 3;
                    m_Result.Trr            = 4 / 10f;
                    m_Result.DCFactFallRate = 6 / 10f;
                    m_Result.Tq             = 5 / 10f;

                    if (m_NeedReadGraf)
                    {
                        for (int i = 1; i <= 2000; i++)
                        {
                            //эмуляция графика тока
                            m_Result.CurrentData.Add(1500);

                            //эмуляция графика напряжения
                            m_Result.VoltageData.Add(600);
                        }
                    }

                    //проверяем отображение Problem, Warning, Fault
                    FireNotificationEvent(7, (ushort)HWWarningReason.None, (ushort)HWFaultReason.None, (ushort)HWDisableReason.None);
                    FireNotificationEvent((ushort)HWProblemReason.None, 2, (ushort)HWFaultReason.None, (ushort)HWDisableReason.None);
                    FireNotificationEvent((ushort)HWProblemReason.None, (ushort)HWWarningReason.None, 1, (ushort)HWDisableReason.None);
                }
                else
                {
                    //запускаем процесс измерения
                    CallAction(ACT_START_TEST);

                    //ждём окончания процесса измерения
                    m_State = WaitForEndOfTest();

                    //если тест успешно завершён - считываем результаты измерения из блока QrrTq
                    if (m_State == DeviceState.Success)
                    {
                        //если значение регистра REG_FINISHED содержит значение 1 (OPRESULT_OK), то можно считать оцифрованные значения тока из EP_SlaveData и результаты измерений из соответствующих регистров
                        ushort finishedResult = ReadRegister(REG_FINISHED);

                        if ((HWFinishedResult)finishedResult == HWFinishedResult.Ok)
                        {
                            m_Result.Idc = ReadRegisterS(REG_RES_IDC);

                            //значения Qrr, Irr, Trr надо читать только в режиме измерения 'Qrr'
                            if (m_Parameters.Mode == TMode.Qrr)
                            {
                                //в регистре хранится умноженное на 10 значение
                                m_Result.Qrr = ReadRegisterS(REG_RES_QRR) / 10f;

                                m_Result.Irr = ReadRegisterS(REG_RES_IRR);

                                //в регистре хранится умноженное на 10 значение
                                m_Result.Trr = ReadRegisterS(REG_RES_TRR) / 10f;
                            }

                            //в регистре хранится умноженное на 10 значение
                            m_Result.DCFactFallRate = ReadRegisterS(REG_RES_DC_FACT_FALL_RATE) / 10f;

                            //читаем из регистра измеренное значение Tq только в режиме измерения Tq
                            m_Result.Tq = m_Parameters.Mode == TMode.QrrTq ? ReadRegisterS(REG_RES_TQ) / 10f : 0;

                            //если нужно читать данные для построения графиков - читаем их
                            if (m_NeedReadGraf)
                            {
                                ReadArrays(m_Result);
                            }
                        }
                    }
                }

                FireQrrTqEvent(m_State, m_Result);
            }

            catch (Exception e)
            {
                m_State = DeviceState.Fault;
                FireQrrTqEvent(m_State, m_Result);
                FireExceptionEvent(e.Message);

                throw;
            }
        }
Exemple #16
0
        private void MeasurementLogicRoutine(Types.Commutation.TestParameters commutation)
        {
            var internalState = DeviceState.InProcess;

            var data = new List <BvtInputParameters>()
            {
                new BvtInputParameters
                {
                    TestType         = m_Parameters.TestType,
                    CurrentLimit     = m_Parameters.CurrentLimit,
                    PlateTime        = m_Parameters.PlateTime,
                    RampUpVoltage    = m_Parameters.RampUpVoltage,
                    StartVoltage     = m_Parameters.StartVoltage,
                    VoltageFrequency = m_Parameters.VoltageFrequency,
                    FrequencyDivisor = m_Parameters.FrequencyDivisor,
                    VoltageLimitD    = m_Parameters.VoltageLimitD,
                    VoltageLimitR    = m_Parameters.VoltageLimitR,
                    MeasurementMode  = m_Parameters.MeasurementMode,
                    IsUdsmUrsm       = false
                }
            };

            if (m_Parameters.UseUdsmUrsm)
            {
                data.Add(new BvtInputParameters()
                {
                    TestType         = m_Parameters.UdsmUrsmTestType,
                    CurrentLimit     = m_Parameters.UdsmUrsmCurrentLimit,
                    PlateTime        = m_Parameters.UdsmUrsmPlateTime,
                    RampUpVoltage    = m_Parameters.UdsmUrsmRampUpVoltage,
                    StartVoltage     = m_Parameters.UdsmUrsmStartVoltage,
                    VoltageFrequency = m_Parameters.UdsmUrsmVoltageFrequency,
                    FrequencyDivisor = m_Parameters.UdsmUrsmFrequencyDivisor,
                    VoltageLimitD    = m_Parameters.UdsmUrsmVoltageLimitD,
                    VoltageLimitR    = m_Parameters.UdsmUrsmVoltageLimitR,
                    MeasurementMode  = BVTMeasurementMode.ModeI,
                    IsUdsmUrsm       = true
                });
            }


            foreach (var bvtInputParameter in data)
            {
                try
                {
                    WriteRegister(REG_LIMIT_CURRENT, (ushort)(bvtInputParameter.CurrentLimit * 10));
                    WriteRegister(REG_PLATE_TIME, bvtInputParameter.PlateTime);
                    WriteRegister(REG_RAMPUP_RATE, (ushort)(bvtInputParameter.RampUpVoltage * 10));
                    WriteRegister(REG_START_VOLTAGE, bvtInputParameter.StartVoltage);
                    WriteRegister(REG_VOLTAGE_FREQUENCY, bvtInputParameter.VoltageFrequency);
                    WriteRegister(REG_FREQUENCY_DIVISOR, bvtInputParameter.FrequencyDivisor);
                    WriteRegister(REG_MEASUREMENT_MODE,
                                  bvtInputParameter.MeasurementMode == Types.BVT.BVTMeasurementMode.ModeI
                            ? MEASURE_MODE_I
                            : MEASURE_MODE_V);

                    if (bvtInputParameter.TestType == Types.BVT.BVTTestType.Both ||
                        bvtInputParameter.TestType == Types.BVT.BVTTestType.Direct)
                    {
                        internalState = DeviceState.InProcess;
                        FireBvtEvent(internalState, m_Result, BVTTestType.Direct, bvtInputParameter.IsUdsmUrsm);

                        if (m_IOCommutation.Switch(commutation.CommutationType == HWModuleCommutationType.Reverse ?
                                                   CommutationMode.BVTR : CommutationMode.BVTD
                                                   , commutation.CommutationType, commutation.Position) ==
                            DeviceState.Fault)
                        {
                            m_State = DeviceState.Fault;
                            FireBvtAllEvent(m_State);
                            return;
                        }

                        WriteRegister(REG_LIMIT_VOLTAGE, bvtInputParameter.VoltageLimitD);
                        WriteRegister(REG_MEASUREMENT_TYPE, MEASURE_TYPE_AC_D);

                        CallAction(ACT_START_TEST);

                        if (!m_IsBVTEmulation)
                        {
                            internalState = WaitForEndOfTest();

                            if (bvtInputParameter.IsUdsmUrsm)
                            {
                                m_Result.VDSM = (ushort)Math.Abs(ReadRegisterS(REG_RESULT_V));
                                m_Result.IDSM = Math.Abs(ReadRegisterS(REG_RESULT_I) / 10.0f);
                            }
                            else
                            {
                                m_Result.VDRM = (ushort)Math.Abs(ReadRegisterS(REG_RESULT_V));
                                m_Result.IDRM = Math.Abs(ReadRegisterS(REG_RESULT_I) / 10.0f);
                            }

                            if (m_ReadGraph)
                            {
                                ReadArrays(m_Result, true);
                            }
                        }
                        else
                        {
                            internalState = DeviceState.Success;

                            if (bvtInputParameter.IsUdsmUrsm)
                            {
                                m_Result.VDSM = Convert.ToUInt16(EMU_DEFAULT_VDRM * new Random((int)DateTime.Now.Ticks).NextDouble());
                                m_Result.IDSM = Convert.ToUInt16(EMU_DEFAULT_IDRM * 300 * new Random((int)DateTime.Now.Ticks).NextDouble());
                            }
                            else
                            {
                                m_Result.VDRM = Convert.ToUInt16(EMU_DEFAULT_VDRM * new Random((int)DateTime.Now.Ticks).NextDouble());
                                m_Result.IDRM = Convert.ToUInt16(EMU_DEFAULT_IDRM * 300 * new Random((int)DateTime.Now.Ticks).NextDouble());
                            }
                        }

                        FireBvtEvent(internalState, m_Result, BVTTestType.Direct, bvtInputParameter.IsUdsmUrsm);


                        if (m_IOCommutation.Switch(Types.Commutation.CommutationMode.None) == DeviceState.Fault)
                        {
                            m_State = DeviceState.Fault;
                            FireBvtAllEvent(m_State);
                            return;
                        }
                    }
                    else
                    {
                        internalState = DeviceState.Success;
                    }

                    if ((internalState == DeviceState.Success) &&
                        (bvtInputParameter.TestType == Types.BVT.BVTTestType.Both ||
                         bvtInputParameter.TestType == Types.BVT.BVTTestType.Reverse))
                    {
                        internalState = DeviceState.InProcess;
                        FireBvtEvent(internalState, m_Result, BVTTestType.Reverse, bvtInputParameter.IsUdsmUrsm);

                        if (m_IOCommutation.Switch(commutation.CommutationType == HWModuleCommutationType.Reverse ?
                                                   CommutationMode.BVTD: CommutationMode.BVTR, commutation.CommutationType, commutation.Position) ==
                            DeviceState.Fault)
                        {
                            m_State = DeviceState.Fault;
                            FireBvtAllEvent(m_State);
                            return;
                        }

                        WriteRegister(REG_LIMIT_VOLTAGE, bvtInputParameter.VoltageLimitR);
                        WriteRegister(REG_MEASUREMENT_TYPE, MEASURE_TYPE_AC_R);
                        CallAction(ACT_START_TEST);

                        if (!m_IsBVTEmulation)
                        {
                            internalState = WaitForEndOfTest();

                            if (bvtInputParameter.IsUdsmUrsm)
                            {
                                m_Result.VRSM = (ushort)Math.Abs(ReadRegisterS(REG_RESULT_V));
                                m_Result.IRSM = Math.Abs(ReadRegisterS(REG_RESULT_I) / 10.0f);
                            }
                            else
                            {
                                m_Result.VRRM = (ushort)Math.Abs(ReadRegisterS(REG_RESULT_V));
                                m_Result.IRRM = Math.Abs(ReadRegisterS(REG_RESULT_I) / 10.0f);
                            }

                            if (m_ReadGraph)
                            {
                                ReadArrays(m_Result, false);
                            }
                        }
                        else
                        {
                            internalState = DeviceState.Success;

                            if (bvtInputParameter.IsUdsmUrsm)
                            {
                                m_Result.VRSM = Convert.ToUInt16(EMU_DEFAULT_VRRM * new Random((int)DateTime.Now.Ticks).NextDouble());
                                m_Result.IRSM = Convert.ToUInt16(EMU_DEFAULT_IRRM * 300 * new Random((int)DateTime.Now.Ticks).NextDouble());
                            }
                            else
                            {
                                m_Result.VRRM = Convert.ToUInt16(EMU_DEFAULT_VRRM * new Random((int)DateTime.Now.Ticks).NextDouble());
                                m_Result.IRRM = Convert.ToUInt16(EMU_DEFAULT_IRRM * 300 * new Random((int)DateTime.Now.Ticks).NextDouble());
                            }
                        }

                        FireBvtEvent(internalState, m_Result, BVTTestType.Reverse, bvtInputParameter.IsUdsmUrsm);
                    }

                    if (m_IOCommutation.Switch(Types.Commutation.CommutationMode.None) == DeviceState.Fault)
                    {
                        m_State = DeviceState.Fault;
                        FireBvtAllEvent(m_State);
                        return;
                    }

                    m_State = internalState;
                }
                catch (Exception ex)
                {
                    m_IOCommutation.Switch(Types.Commutation.CommutationMode.None);
                    m_State = DeviceState.Fault;
                    FireBvtAllEvent(m_State);

                    FireExceptionEvent(ex.Message);
                    throw;
                }
            }
        }
Exemple #17
0
        private void MeasurementLogicRoutine(Types.Commutation.TestParameters Commutation)
        {
            try
            {
                m_State = DeviceState.InProcess;

                //уведомляем UI о том, что мы находимся в состоянии m_State с результатами измерений m_Result
                FireEvent(m_State, m_Result);

                m_IOCommutation.CallAction(IOCommutation.ACT_COMM_IH);

                try
                {
                    m_IOGate.WriteRegister(130, 1);

                    try
                    {
                        m_IOGate.CallAction(IOGate.ACT_START_IH);//102

                        m_IOStLs.WriteRegister(128, 1);
                        m_IOStLs.WriteRegister(140, m_Parameters.Itm);
                        m_IOStLs.WriteRegister(141, 10000);
                        m_IOStLs.WriteRegister(160, 1);
                        m_IOStLs.CallAction(100);

                        if (m_IsEmulation)
                        {
                            //эмулируем успешный результат измерений
                            m_State     = DeviceState.Success;
                            m_Result.Ih = 10;

                            //проверяем отображение Problem, Warning, Fault
                            FireNotificationEvent(ComplexParts.IH, 7, (ushort)HWWarningReason.None, (ushort)HWFaultReason.None, (ushort)HWDisableReason.None);
                            FireNotificationEvent(ComplexParts.IH, (ushort)HWProblemReason.None, 2, (ushort)HWFaultReason.None, (ushort)HWDisableReason.None);
                            FireNotificationEvent(ComplexParts.IH, (ushort)HWProblemReason.None, (ushort)HWWarningReason.None, 1, (ushort)HWDisableReason.None);
                        }
                        else
                        {
                            if (WaitForEndOfSLTest() == DeviceState.Success)
                            {
                                WaitForEndOfGateTest();

                                //тесты в обоих блоках завершились успешно, поэтому читаем регистры результатов
                                m_State     = DeviceState.Success;
                                m_Result.Ih = m_IOGate.ReadRegister(201);
                            }
                        }
                    }

                    finally
                    {
                        //регистр 130 не зависимо от результата измерения надо выставить в ноль
                        m_IOGate.WriteRegister(130, 0);
                    }
                }

                finally
                {
                    //выполняем команду 110 на блоке коммутации
                    m_IOCommutation.CallAction(110);
                }

                FireEvent(m_State, m_Result);
            }

            catch (Exception e)
            {
                m_State = DeviceState.Fault;
                FireEvent(m_State, m_Result);
                FireExceptionEvent(e.Message);

                throw;
            }
        }
Exemple #18
0
        private void MeasurementLogicRoutine(Types.Commutation.TestParameters Commutation)
        {
            try
            {
                m_State = DeviceState.InProcess;
                FiredVdtEvent(m_State, m_Result);

                WriteRegister(REG_DESIRED_VOLTAGE, m_Parameters.Voltage);

                //перед измерением dVdt исполняем команду включения коммутации см. требование http://elma.pe.local/Tasks/Task/Execute/108699
                if (m_IOCommutation.Switch(Types.Commutation.CommutationMode.DVDT, Commutation.CommutationType, Commutation.Position) == DeviceState.Fault)
                {
                    m_State         = DeviceState.Fault;
                    m_Result.Passed = false;
                    FiredVdtEvent(m_State, m_Result);
                    return;
                }

                if (m_IsdVdtEmulation)
                {
                    //в режиме эмуляции эмулируем успешный результат проверки
                    m_State         = DeviceState.Success;
                    m_Result.Passed = true;

                    //значение VoltageRate имеет смысл только для режима "Определение"
                    if (m_Parameters.Mode == DvdtMode.Detection)
                    {
                        m_Result.VoltageRate = 2200;
                    }
                    else
                    {
                        m_Result.VoltageRate = 0;
                    }
                }
                else
                {
                    if (m_Parameters.Mode == DvdtMode.Confirmation)
                    {
                        //режим "Подтверждение" (Confirmation)
                        bool   opened    = false;
                        ushort testCount = 0;

                        //повторяем тест подтверждения столько раз, сколько задано в параметре "Число повторений теста подтверждения", тест имеет смысл пока прибор не открылся. если прибор открылся - он считается браком, повторять тест подтверждения для бракованного прибора нет смысла
                        while ((!opened) && (testCount < m_Parameters.ConfirmationCount))
                        {
                            switch (m_Parameters.VoltageRate)
                            {
                            case VoltageRate.V500:
                                CallAction(ACT_START_TEST_500);
                                break;

                            case VoltageRate.V1000:
                                CallAction(ACT_START_TEST_1000);
                                break;

                            case VoltageRate.V1600:
                                CallAction(ACT_START_TEST_1600);
                                break;

                            case VoltageRate.V2000:
                                CallAction(ACT_START_TEST_2000);
                                break;

                            case VoltageRate.V2500:
                                CallAction(ACT_START_TEST_2500);
                                break;
                            }

                            m_State         = WaitForEndOfTest();
                            opened          = (ReadRegisterS(REG_TEST_RESULT) == 0);
                            m_Result.Passed = !opened;

                            //увеличиваем счётчик выполненных тестов "Подтверждение"
                            testCount++;
                        }
                    }
                    else
                    {
                        if (m_Parameters.Mode == DvdtMode.Detection)
                        {
                            //режим "Определение" (Detection)
                            //формируем стек шагов по которым будем шагать
                            var Steps = new List <ushort>();
                            PrepareSteps(Steps);

                            ushort TestVoltageRate = 0;
                            ushort i        = 0;
                            bool   opened   = false;
                            bool   moveDown = false;

                            while (true)
                            {
                                //считываем скорость роста напряжения на которой мы собрались тестировать прибор
                                TestVoltageRate = Steps[i];

                                //запускаем проверку прибора на скорости роста напряжения TestVoltageRate
                                WriteRegister(REG_VOLTAGE_RATE, TestVoltageRate);
                                CallAction(ACT_START_TEST_CUSTOM);

                                m_State = WaitForEndOfTest();
                                opened  = (ReadRegisterS(REG_TEST_RESULT) == 0);

                                //если мы проверили прибор на максимальной скорости роста напряжения и он не открылся - он годен, тест завершён
                                if ((i == Steps.Count - 1) && (!opened))
                                {
                                    m_Result.Passed      = true;
                                    m_Result.VoltageRate = TestVoltageRate;

                                    break;
                                }

                                //если мы спустились на самую первую ступеньку после того, как было зафиксировано открытие прибора и на этой последней ступеньке было зафиксировано открытие прибора - прибор брак, тест завершён
                                if ((i == 0) && opened)
                                {
                                    m_Result.Passed      = false;
                                    m_Result.VoltageRate = 0;

                                    break;
                                }

                                //если мы двигаемся вниз и прибор не открылся - прибор годен для TestVoltageRate, тест завершён
                                if (moveDown && (!opened))
                                {
                                    m_Result.Passed      = true;
                                    m_Result.VoltageRate = TestVoltageRate;

                                    break;
                                }

                                //если почему-то индекс i стал больше, чем число шагов минус 1
                                if (i > Steps.Count - 1)
                                {
                                    throw new Exception("scme.service.io.iodvdt.cs MeasurementLogicRoutine. (i>Steps.Count-1.");
                                }

                                //если почему-то индекс i стал отрицательным
                                if (i < 0)
                                {
                                    throw new Exception("scme.service.io.iodvdt.cs MeasurementLogicRoutine. i<0.");
                                }

                                //если мы пошли вниз - дорога вверх уже закрыта
                                if (opened || moveDown)
                                {
                                    moveDown = true;
                                    i--;
                                }
                                else
                                {
                                    i++;
                                }
                            }
                        }
                    }
                }

                FiredVdtEvent(m_State, m_Result);
            }

            catch (Exception ex)
            {
                m_State = DeviceState.Fault;
                FiredVdtEvent(m_State, m_Result);
                FireExceptionEvent(ex.Message);

                throw;
            }
        }
Exemple #19
0
        private void MeasurementLogicRoutine(Types.Commutation.TestParameters Commutation)
        {
            try
            {
                m_State = DeviceState.InProcess;

                //перед измерением очищаем только Warning. сброс состояния Fault не делаем, т.к. он переводит ATU в состояние None
                ClearWarning();

                //уведомляем UI о том, что мы находимся в состоянии m_State с результатами измерений m_Result
                FireATUEvent(m_State, m_Result);

                //пишем значение амплитуды предварительного импульса тока в блок ATU
                WriteRegister(REG_PRE_PULSE_VALUE, m_Parameters.PrePulseValue);

                //пишем значение требуемой мощности в блок ATU
                WriteRegister(REG_POWER_VALUE, m_Parameters.PowerValue);

                if (m_IsATUEmulation)
                {
                    //эмулируем успешный результат измерений
                    m_State        = DeviceState.Success;
                    m_Result.UBR   = 3000;                          //В
                    m_Result.UPRSM = 1800;                          //В
                    m_Result.IPRSM = RoundTwoDigits(10257 / 1000d); //А   уровень отображения реализует вывод до 2 десятых
                    m_Result.PRSM  = RoundTwoDigits(316 / 100d);    //в регистре сидит значение Bт/10. переводим его в кВт уровень отображения реализует вывод до 2 десятых

                    //проверяем обработку не удачного окончания измерения
                    FireNotificationEvent((ushort)HWWarningReason.Short, (ushort)HWFaultReason.None, (ushort)HWDisableReason.None);
                    FireNotificationEvent((ushort)HWWarningReason.None, (ushort)HWFaultReason.ChargeError, (ushort)HWDisableReason.None);
                }
                else
                {
                    //перед каждым измерением выполняем включение специальной коммутации для блока ATU для подключения требуемого измерительного блока к испытуемому прибору
                    if (m_IOCommutation.Switch(Types.Commutation.CommutationMode.ATU, Commutation.CommutationType, Commutation.Position) == DeviceState.Fault)
                    {
                        m_State = DeviceState.Fault;
                        //раз коммутация не удалась - выставляем значения всех измеряемых параметров в ноль
                        m_Result.UBR   = 0;
                        m_Result.UPRSM = 0;
                        m_Result.IPRSM = 0;
                        m_Result.PRSM  = 0;

                        FireATUEvent(m_State, m_Result);

                        return;
                    }

                    //запускаем процесс измерения
                    CallAction(ACT_START_TEST);

                    //ждём окончания процесса измерения
                    m_State = WaitForEndOfTest();

                    //считываем результаты измерения из блока ATU
                    m_Result.UBR   = ReadRegisterS(REG_CASCADING_VOLTAGE_VALUE_MEASURE);
                    m_Result.UPRSM = ReadRegisterS(REG_VOLTAGE_VALUE_MEASURE);
                    m_Result.IPRSM = RoundTwoDigits(ReadRegisterS(REG_CURRENT_VALUE_MEASURE) / 1000d); //А уровень отображения реализует вывод до 2 десятых
                    m_Result.PRSM  = RoundTwoDigits(ReadRegisterS(REG_POWER_VALUE_MEASURE) / 100d);    //в регистре сидит значение Bт/10. переводим его в кВт уровень отображения реализует вывод до 2 десятых

                    //по окончании процесса измерения - отключаем коммутацию
                    if (m_IOCommutation.Switch(Types.Commutation.CommutationMode.None) == DeviceState.Fault)
                    {
                        m_State = DeviceState.Fault;

                        //коммутация не удалась, оставляем содержимое m_Result без изменения
                        FireATUEvent(m_State, m_Result);

                        return;
                    }
                }

                FireATUEvent(m_State, m_Result);
            }
            catch (Exception e)
            {
                m_IOCommutation.Switch(Types.Commutation.CommutationMode.None);
                m_State = DeviceState.Fault;
                FireATUEvent(m_State, m_Result);
                FireExceptionEvent(e.Message);

                throw;
            }
        }
Exemple #20
0
        private void MeasurementLogicRoutine(Types.Commutation.TestParameters Commutation)
        {
            try
            {
                _State = DeviceState.InProcess;
                CallAction(ACT_CLEAR_WARNING);
                FireTOUEvent(_State, _Result);

                if (_IsTOUEmulation)
                {
                    Random rand = new Random(DateTime.Now.Millisecond);

                    var randValue = rand.Next(0, 2);

                    //if (randValue == 0)
                    //{
                    //    _State = DeviceState.Problem;
                    //    Thread.Sleep(500);
                    //    //проверяем отображение Problem, Warning, Fault
                    //    FireNotificationEvent(HWProblemReason.None, HWWarningReason.AnperageOutOfRange, HWFaultReason.NoPotensialSignal, HWDisableReason.None);
                    //    Thread.Sleep(500);
                    //    FireTOUEvent(_State, _Result);
                    //}
                    //else
                    //{
                    //Как в RAC проверка ошибок
                    Thread.Sleep(500);
                    FireNotificationEvent(HWProblemReason.None, HWWarningReason.CurrentOutOfRange, HWFaultReason.None, HWDisableReason.None);
                    Thread.Sleep(500);
                    FireNotificationEvent(HWProblemReason.None, HWWarningReason.None, HWFaultReason.Overflow90, HWDisableReason.None);
                    Thread.Sleep(500);
                    _Result.ITM = (float)rand.NextDouble() * 1000;
                    _Result.TGD = (float)rand.NextDouble() * 1000;
                    _Result.TGT = (float)rand.NextDouble() * 1000;
                    _State      = DeviceState.Success;
                    FireTOUEvent(_State, _Result);
                    //}
                }
                else
                {
                    if (ActiveCommutation.Switch(Types.Commutation.CommutationMode.TOU, Commutation.CommutationType, Commutation.Position) == DeviceState.Fault)
                    {
                        _State = DeviceState.Fault;
                        FireTOUEvent(_State, _Result);
                        return;
                    }

                    WriteRegister(REG_CURRENT_VALUE, _Parameters.CurrentAmplitude);
                    CallAction(ACT_START_TEST);
                    WaitState(HWDeviceState.Ready);

                    ushort finish = ReadRegister(REG_TEST_FINISHED);
                    _Result.ITM = ReadRegister(REG_MEAS_CURRENT_VALUE);
                    _Result.TGD = ReadRegister(REG_MEAS_TIME_DELAY);
                    _Result.TGT = ReadRegister(REG_MEAS_TIME_ON);

                    _State = DeviceState.Success;
                    FireTOUEvent(_State, _Result);
                    if (finish != OPRESULT_OK)
                    {
                        HWFaultReason   faultReason   = (HWFaultReason)ReadRegister(REG_PROBLEM);
                        HWWarningReason warningReason = (HWWarningReason)ReadRegister(REG_WARNING);
                        FireNotificationEvent(HWProblemReason.None, warningReason, faultReason, HWDisableReason.None);
                    }

                    //по окончании процесса измерения - отключаем коммутацию
                    if (ActiveCommutation.Switch(Types.Commutation.CommutationMode.None) == DeviceState.Fault)
                    {
                        _State = DeviceState.Fault;
                        FireTOUEvent(_State, _Result);
                        return;
                    }
                }
            }

            catch (Exception ex)
            {
                ActiveCommutation.Switch(Types.Commutation.CommutationMode.None);
                _State = DeviceState.Fault;
                FireTOUEvent(_State, _Result);
                FireExceptionEvent(ex.Message);

                throw;
            }
        }