Exemplo n.º 1
0
        /// <summary>
        /// Old Codes
        /// </summary>
        /// <param name="Input"></param>
        /// <returns></returns>
        /// /*
        /*
        private byte getByteFromeValue(byte Input)
        {
            if (ValueFormat == "0x" || ValueFormat == "")
                return (byte)Value;
            else if (ValueFormat == "0b")
            {
                string strInput = Convert.ToString(Input, 2);
                while (strInput.Length < 8)
                    strInput = "0" + strInput;

                char[] charInput = strInput.ToCharArray();
                string strValue = Convert.ToString(Value, 2);
                while (strValue.Length < BitLength)
                    strValue = "0" + strValue;
                strValue.CopyTo(0, charInput, 7 - StartBit, BitLength);
                return (byte)Convert.ToInt32(new string(charInput), 2);
            }
            else return Input;
        }
        */


        public bool isDataAvailable(ref CCFBinary CCFBin)
        {
            if (CCFBin.isInilized)
            {
                IEnumerable<byte[]> theByteList = from byte[] t in CCFBin.Data
                                                  where t[0] == MDF >> 8
                                                  select t;
                foreach (byte[] t in theByteList)
                    return true;
                return false;
            }
            else return false;
        }
Exemplo n.º 2
0
        public bool setValueFromCCFBinary(ref CCFBinary CCFBin)
        {

            if (CCFBin.isInilized)
            {
                IEnumerable<byte[]> theByteList = from byte[] t in CCFBin.Data
                                                  where t[0] == (MDF >> 8)
                                                  select t;
                foreach (byte[] t in theByteList)
                {
                    byte theByte = t[StartByte - 1];
                    if (BitLength == 8)
                        Value = (int)theByte;
                    else
                    {
                        string strValue = Convert.ToString(theByte, 2);
                        while (strValue.Length < 8)
                            strValue = "0" + strValue;
                        strValue = strValue.Substring(7 - StartBit, BitLength);
                        Value = Convert.ToInt32(strValue, 2);
                    }
                    return true;
                }

                return false;
            }
            else return false;
        }
Exemplo n.º 3
0
        public bool writeByteIntoCCFBinary(ref CCFBinary CCFBin)
        {

            return CCFBin.SetValue(this.EUCDBlockID, this.StartByte, this.StartBit, this.BitLength, this.Value);
            /* OldCode
            if (CCFBin.isInilized)
            {
                IEnumerable<byte[]> theByteList = from byte[] t in CCFBin.Data
                                                  where t[0] == (MDF >> 8)
                                                  select t;
                foreach (byte[] t in theByteList)
                {
                    t[StartByte - 1] = getByteFromeValue(t[StartByte - 1]);
                }

                return false;
            }
            else return false;
            */
        }
Exemplo n.º 4
0
        public bool ReadValue(ref CCFBinary CCFBin)
        {
            int DebugCount = 0;
            try
            {
                foreach (CCFParameter t in CCFParameters)
                {
                    t.setValueFromCCFBinary(ref CCFBin);
                    DebugCount++;
                }

                return true;
            }
            catch
            {
                return false;
            }
        }