Exemplo n.º 1
0
 public void SetOutputPoint(IO_OUT_Type Io, IOValue Value)
 {
     if (m_ControlerBoard != null)
     {
         m_ControlerBoard.SendCommandToSetControlBoardOutput(Io, Value);
     }
 }
Exemplo n.º 2
0
        public void SendCommandToSetControlBoardOutput(IO_OUT_Type Io, IOValue Value)
        {
            int BoardIndex = 0;
            int IoOutIndex = 0;

            GetIoOutBoardAndAxisIndexByIO_OUT_Type(Io, ref BoardIndex, ref IoOutIndex);

            if (!IsControlerConnected((Board)BoardIndex))
            {
                return;
            }

            uint outputBuffer = 0;  //输出口数据
            uint outputEnable = 0;  //输出口使能

            if (Value == IOValue.High)
            {
                outputBuffer |= ((uint)1 << IoOutIndex);
            }

            outputEnable |= ((uint)1 << IoOutIndex);

            byte[] temp = new byte[CommunicationProtocol.MessageLength];
            CommunicationProtocol.MakeSendArrayByCode((byte)ControlerCommandCode.SetOutput, ref temp);

            const int DataIndex = CommunicationProtocol.MessageCommandIndex + 1;

            temp[DataIndex + 0] = (byte)(outputEnable & 0xffU);
            temp[DataIndex + 1] = (byte)((outputEnable >> 8) & 0xffU);
            temp[DataIndex + 2] = (byte)((outputEnable >> 16) & 0xffU);
            temp[DataIndex + 3] = (byte)((outputEnable >> 24) & 0xffU);
            temp[DataIndex + 4] = (byte)(outputBuffer & 0xffU);
            temp[DataIndex + 5] = (byte)((outputBuffer >> 8) & 0xffU);
            temp[DataIndex + 6] = (byte)((outputBuffer >> 16) & 0xffU);
            temp[DataIndex + 7] = (byte)((outputBuffer >> 24) & 0xffU);

            temp[CommunicationProtocol.MessageSumCheck] = 0x00;
            temp[CommunicationProtocol.MessageSumCheck] = MyMath.CalculateSum(temp, CommunicationProtocol.MessageLength);

            AddCommandMessageToQueue((Board)BoardIndex, ControlerCommandCode.SetOutput, ref temp);
        }
Exemplo n.º 3
0
        public void SendCommandToSetControlBoardOutputByInput(IO_IN_Type Io_In, int Value, IO_OUT_Type Io_Out1, int Out1_Value, IO_OUT_Type Io_Out2, int Out2_Value)
        {
            int BoardIndex = 0;
            int IoInIndex  = 0;

            GetIoInBoardAndAxisIndexByIO_IN_Type(Io_In, ref BoardIndex, ref IoInIndex);

            int indexBoardOut1 = 0;
            int IoOut1Index    = 0;

            GetIoOutBoardAndAxisIndexByIO_OUT_Type(Io_Out1, ref indexBoardOut1, ref IoOut1Index);

            int indexBoardOut2 = 0;
            int IoOut2Index    = 0;

            GetIoOutBoardAndAxisIndexByIO_OUT_Type(Io_Out2, ref indexBoardOut2, ref IoOut2Index);

            if (!IsControlerConnected((Board)BoardIndex))
            {
                return;
            }

            byte[] temp = new byte[CommunicationProtocol.MessageLength];
            CommunicationProtocol.MakeSendArrayByCode((byte)ControlerCommandCode.SetOutputByInput, ref temp);

            const int DataIndex = CommunicationProtocol.MessageCommandIndex + 1;

            temp[DataIndex + 0] = (byte)IoInIndex;
            temp[DataIndex + 1] = (byte)Value;
            temp[DataIndex + 2] = (byte)IoOut1Index;
            temp[DataIndex + 3] = (byte)Out1_Value;
            temp[DataIndex + 4] = (byte)IoOut2Index;
            temp[DataIndex + 5] = (byte)Out2_Value;

            temp[CommunicationProtocol.MessageSumCheck] = 0x00;
            temp[CommunicationProtocol.MessageSumCheck] = MyMath.CalculateSum(temp, CommunicationProtocol.MessageLength);

            AddCommandMessageToQueue((Board)BoardIndex, ControlerCommandCode.SetOutputByInput, ref temp);
        }
Exemplo n.º 4
0
        public void GetIoOutBoardAndAxisIndexByIO_OUT_Type(IO_OUT_Type IoOutType, ref int BoadrIndex, ref int IoOutIndex)
        {
            switch (IoOutType)
            {
            case IO_OUT_Type.IO_OUT_LedRed:
            {
                BoadrIndex = Profile.m_Config.IO_OUT_LedRed.BoardIndex;
                IoOutIndex = Profile.m_Config.IO_OUT_LedRed.IoOutIndex;
            }
            break;

            case IO_OUT_Type.IO_OUT_LedOriange:
            {
                BoadrIndex = Profile.m_Config.IO_OUT_LedOriange.BoardIndex;
                IoOutIndex = Profile.m_Config.IO_OUT_LedOriange.IoOutIndex;
            }
            break;

            case IO_OUT_Type.IO_OUT_LedGreen:
            {
                BoadrIndex = Profile.m_Config.IO_OUT_LedGreen.BoardIndex;
                IoOutIndex = Profile.m_Config.IO_OUT_LedGreen.IoOutIndex;
            }
            break;

            case IO_OUT_Type.IO_OUT_LedKeyRun:
            {
                BoadrIndex = Profile.m_Config.IO_OUT_LedKeyRun.BoardIndex;
                IoOutIndex = Profile.m_Config.IO_OUT_LedKeyRun.IoOutIndex;
            }
            break;

            case IO_OUT_Type.IO_OUT_LedKeyPause:
            {
                BoadrIndex = Profile.m_Config.IO_OUT_LedKeyPause.BoardIndex;
                IoOutIndex = Profile.m_Config.IO_OUT_LedKeyPause.IoOutIndex;
            }
            break;

            case IO_OUT_Type.IO_OUT_LedKeyStop:
            {
                BoadrIndex = Profile.m_Config.IO_OUT_LedKeyStop.BoardIndex;
                IoOutIndex = Profile.m_Config.IO_OUT_LedKeyStop.IoOutIndex;
            }
            break;

            case IO_OUT_Type.IO_OUT_Beep:
            {
                BoadrIndex = Profile.m_Config.IO_OUT_Beep.BoardIndex;
                IoOutIndex = Profile.m_Config.IO_OUT_Beep.IoOutIndex;
            }
            break;


            default:
                break;
            }

            IoOutIndex = IoOutIndex - 1;

            if (IoOutIndex < 0)
            {
                IoOutIndex = 0;
            }
            else if (IoOutIndex >= IO_POINT_TOTAL)
            {
                IoOutIndex = IO_POINT_TOTAL - 1;
            }
        }