示例#1
0
        /// <summary>
        /// Constructor Overload
        /// </summary>
        /// <param name="receiveBuffer">Receive buffer</param>
        /// <param name="startIndex">Start position</param>
        /// <param name="profileInfo">Profile information</param>
        public ProfileData(int[] receiveBuffer, int startIndex, LJV7IF_PROFILE_INFO profileInfo)
        {
            int bufIntSize = CalculateDataSize(profileInfo);
            int[] bufIntArray = new int[bufIntSize];
            _profileInfo = profileInfo;

            Array.Copy(receiveBuffer, startIndex, bufIntArray, 0, bufIntSize);
            SetData(bufIntArray, profileInfo);
        }
示例#2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="receiveBuffer">Receive buffer</param>
        /// <param name="startIndex">Start position</param>
        /// <param name="profileInfo">Profile information</param>
        public ProfileData(byte[] receiveBuffer, int startIndex, LJV7IF_PROFILE_INFO profileInfo)
        {
            int bufIntSize = CalculateDataSize(profileInfo);
            int[] bufIntArray = new int[bufIntSize];
            _profileInfo = profileInfo;

            // Conversion from byte[] to int[]
            for (int i = 0; i < bufIntSize; i++)
            {
                bufIntArray[i] = BitConverter.ToInt32(receiveBuffer, (startIndex + i *  Marshal.SizeOf(typeof(int))));
            }
            SetData(bufIntArray, profileInfo);
        }
示例#3
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ProfileData(int[] receiveBuffer, LJV7IF_PROFILE_INFO profileInfo)
 {
     SetData(receiveBuffer, profileInfo);
 }
示例#4
0
        /// <summary>
        /// Set the members to the arguments.
        /// </summary>
        /// <param name="receiveBuffer">Receive buffer</param>
        /// <param name="profileInfo">Profile information</param>
        private void SetData(int[] receiveBuffer, LJV7IF_PROFILE_INFO profileInfo)
        {
            _profileInfo = profileInfo;

            // Extract the header.
            int headerSize = Utility.GetByteSize(Utility.TypeOfStruct.PROFILE_HEADER) /  Marshal.SizeOf(typeof(int));
            int[] headerData = new int[headerSize];
            Array.Copy(receiveBuffer, 0, headerData, 0, headerSize);
            _triggerCnt = headerData[1];
            _encoderCnt = headerData[2];

            // Extract the footer.
            int footerSize = Utility.GetByteSize(Utility.TypeOfStruct.PROFILE_FOOTER) /  Marshal.SizeOf(typeof(int));
            int[] footerData = new int[footerSize];
            Array.Copy(receiveBuffer, receiveBuffer.Length - footerSize, footerData, 0, footerSize);

            // Extract the profile data.
            int profSize = receiveBuffer.Length - headerSize - footerSize;
            _profData = new int[profSize];
            Array.Copy(receiveBuffer, headerSize, _profData, 0, profSize);
        }
示例#5
0
        /// <summary>
        /// Create the X-position string from the profile information.
        /// </summary>
        /// <param name="profileInfo">Profile information</param>
        /// <returns>X-position string</returns>
        public static string GetXPosString(LJV7IF_PROFILE_INFO profileInfo)
        {
            StringBuilder sb = new StringBuilder();
            // Data position calculation
            double posX = profileInfo.lXStart;
            double deltaX = profileInfo.lXPitch;

            int singleProfileCount = profileInfo.wProfDataCnt;
            int dataCount = (int)profileInfo.byProfileCnt * (profileInfo.byEnvelope + 1);

            for (int i = 0; i < dataCount; i++)
            {
                for (int j = 0; j < singleProfileCount; j++)
                {
                    sb.AppendFormat("{0}\t", (posX + deltaX * j));
                }
            }
            return sb.ToString();
        }
示例#6
0
        /// <summary>
        /// Data size calculation
        /// </summary>
        /// <param name="profileInfo">Profile information</param>
        /// <returns>Profile data size</returns>
        public static int CalculateDataSize(LJV7IF_PROFILE_INFO profileInfo)
        {
            LJV7IF_PROFILE_HEADER header = new LJV7IF_PROFILE_HEADER();
            LJV7IF_PROFILE_FOOTER footer = new LJV7IF_PROFILE_FOOTER();

            return profileInfo.wProfDataCnt * profileInfo.byProfileCnt * (profileInfo.byEnvelope + 1) +
                (Marshal.SizeOf(header) + Marshal.SizeOf(footer)) /  Marshal.SizeOf(typeof(int));
        }
示例#7
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ProfileData(int[] receiveBuffer, LJV7IF_PROFILE_INFO profileInfo)
 {
     SetData(receiveBuffer, profileInfo);
 }