Example #1
0
        private string getCheckDigit(string cmdCombined)
        {
            bool[] bits = BitConverterEx.GetBits((byte)cmdCombined[0]);
            for (int j = 1; j < cmdCombined.Length; j++)
            {
                for (byte i = 0; i < 8; i++)
                {
                    bits[i] ^= BitConverterEx.TestB(cmdCombined[j], i);
                }
            }
            int upperBit = 0;
            int lowerBit = 0;

            for (byte i = 0; i < 4; i++)
            {
                BitConverterEx.SetBit(ref lowerBit, i, bits[i]);
                BitConverterEx.SetBit(ref upperBit, i, bits[i + 4]);
            }
            return(string.Format("{0:x}{1:x}", upperBit, lowerBit));
        }
Example #2
0
 /// <summary>
 /// 設定Output數值
 /// </summary>
 /// <param name="portNo">Port Number</param>
 /// <param name="bitNo">Bit Number</param>
 /// <param name="status">寫入成功回傳true,反之false(DI點一定false)</param>
 /// <returns></returns>
 public bool SetOutput2(PortNo portNo, BitNo bitNo, bool status)
 {
     if (dIOPara.IsActive)
     {
         I16 retOfIO = CCMNet.CS_mnet_io_input(RingNoOfMNet, dIOPara.SlaveIP, (U8)portNo);
         BitConverterEx.SetBit(ref retOfIO, (byte)bitNo, status);
         I16 retOfSetOutput = CCMNet.CS_mnet_io_output(RingNoOfMNet, dIOPara.SlaveIP, (U8)portNo, (byte)retOfIO);
         if (retOfSetOutput >= 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Example #3
0
 /// <summary>
 /// 設定Output數值
 /// </summary>
 /// <param name="portNo">Port Number</param>
 /// <param name="bitNo">Bit Number</param>
 /// <param name="status">寫入成功回傳true,反之false(DI點一定false)</param>
 /// <returns></returns>
 public bool SetOutput2(PortNo portNo, BitNo bitNo, bool status)
 {
     if (dIOPara.IsActive)
     {
         U8 val = 0;
         CMNET_L132.CS_mnet_io_input((U16)dIOPara.CardSwitchNo, (U16)dIOPara.RingNoOfCard, dIOPara.SlaveIP, (U8)portNo, ref val);
         BitConverterEx.SetBit(ref val, (byte)bitNo, status);
         I16 retOfSetOutput = CMNET_L132.CS_mnet_io_output((U16)dIOPara.CardSwitchNo, (U16)dIOPara.RingNoOfCard, dIOPara.SlaveIP, (U8)portNo, val);
         if (retOfSetOutput >= 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }