예제 #1
0
        private void FireSwitchEvent(Types.Commutation.CommutationMode SwitchState, Types.Commutation.HWModuleCommutationType CommutationType, Types.Commutation.HWModulePosition Position)
        {
            SystemHost.Journal.AppendLog(m_ID, LogMessageType.Info,
                                         string.Format("Switch state {0} on {1}:{2}", SwitchState, CommutationType, Position));

            m_Communication.PostCommutationSwitchEvent(SwitchState);
        }
예제 #2
0
        internal DeviceState Switch(Types.Commutation.CommutationMode Mode,
                                    Types.Commutation.HWModuleCommutationType CommutationType =
                                    Types.Commutation.HWModuleCommutationType.Undefined,
                                    Types.Commutation.HWModulePosition Position =
                                    Types.Commutation.HWModulePosition.Position1)
        {
            if (m_IsCommutationEmulation)
            {
                return(DeviceState.Success);
            }

            if (CommutationType == Types.Commutation.HWModuleCommutationType.Undefined)
            {
                CommutationType = m_Type6 ? Types.Commutation.HWModuleCommutationType.MT3 : Types.Commutation.HWModuleCommutationType.Direct;
            }

            try
            {
                var warning = (Types.Commutation.HWWarningReason)
                              ReadRegister(REG_WARNING);

                if (warning != Types.Commutation.HWWarningReason.None)
                {
                    FireNotificationEvent(warning, Types.Commutation.HWFaultReason.None);
                    ClearWarning();
                }

                var devState = (Types.Commutation.HWDeviceState)GetDeviceState();

                if (devState == Types.Commutation.HWDeviceState.Fault)
                {
                    FireNotificationEvent(Types.Commutation.HWWarningReason.None,
                                          (Types.Commutation.HWFaultReason)ReadRegister(REG_FAULT_REASON));
                    return(DeviceState.Fault);
                }

                WriteRegister(REG_MODULE_TYPE, (ushort)CommutationType);
                WriteRegister(REG_MODULE_POSITION, (ushort)Position);

                switch (Mode)
                {
                case Types.Commutation.CommutationMode.None:
                    CallAction(m_Type6 ? ACT_COMM6_NONE : ACT_COMM2_NONE);
                    break;

                case Types.Commutation.CommutationMode.Gate:
                    CallAction(m_Type6 ? ACT_COMM6_GATE : ACT_COMM2_GATE);
                    break;

                case Types.Commutation.CommutationMode.VTM:
                    CallAction(m_Type6 ? ACT_COMM6_SL : ACT_COMM2_SL);
                    break;

                case Types.Commutation.CommutationMode.BVTD:
                    CallAction(m_Type6 ? ACT_COMM6_BVT_D : ACT_COMM2_BVT_D);
                    break;

                case Types.Commutation.CommutationMode.BVTR:
                    CallAction(m_Type6 ? ACT_COMM6_BVT_R : ACT_COMM2_BVT_R);
                    break;

                case Types.Commutation.CommutationMode.DVDT:
                    //для dvdt может быть только коммутация ACT_COMM2_DVDT
                    CallAction(ACT_COMM2_DVDT);
                    break;

                case Types.Commutation.CommutationMode.ATU:
                    //для ATU может быть только коммутация ACT_COMM2_ATU
                    CallAction(ACT_COMM2_ATU);
                    break;

                case Types.Commutation.CommutationMode.RAC:
                    //для RAC (сделан на блоке BVT) может быть только коммутация ACT_COMM2_BVT_D
                    CallAction(ACT_COMM2_BVT_D);
                    break;

                case Types.Commutation.CommutationMode.TOU:
                    //для TOU может быть только коммутация ACT_COMM2_TOU
                    CallAction(ACT_COMM2_TOU);
                    break;
                }

                FireSwitchEvent(Mode, CommutationType, Position);

                return(DeviceState.Success);
            }
            catch (Exception ex)
            {
                FireExceptionEvent(ex.Message);
                return(DeviceState.Fault);
            }
        }