예제 #1
0
        /// <summary>
        /// c#版本开关矩阵数据解析
        /// </summary>
        /// <param name="switchArrays">开关序号数组</param>
        /// <returns>I2C通信传输的byte[]数组</returns>
        public static byte[] GetMcuFormatBytes(byte[] switchArrays)
        {
            CmdFrame cmdFrame = new CmdFrame();

            cmdFrame.param = switchArrays;
            return(cmdFrame.convertToByteArray());
        }
예제 #2
0
        private static byte[] cmdUART0 = { 0xEE, 0xA, 0x1, 0x0, 0xFF, 0xFC, 0xFF, 0xFF };//开关完整帧的数据格式
        /// <summary>
        /// labview版本的开关矩阵数据解析
        /// </summary>
        /// <param name="switchArrays">开关矩阵二维数组</param>
        /// <param name="switchIndex">行索引</param>
        /// <returns>I2C通信传输的byte[]数组</returns>
        public static byte[] GetMcuFormatBytes(bool[,] switchArrays, int switchIndex)
        {
            bool[]      currentArrays      = IndexArray(switchArrays, switchIndex, IndexType.Row);
            int         length             = currentArrays.Length;
            List <byte> switchEnableIndexs = new List <byte>();

            for (int i = 0; i < length; i++)
            {
                if (currentArrays[i])
                {
                    switchEnableIndexs.Add((byte)(i + 1));
                }
            }
            CmdFrame cmdFrame = new CmdFrame();

            cmdFrame.param = switchEnableIndexs.ToArray();
            return(cmdFrame.convertToByteArray());
        }