Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        private XmlElement GetHighSpeedProfileValues()
        {
            LJV7IF_GET_PROFILE_REQ req = new LJV7IF_GET_PROFILE_REQ();
            req.byTargetBank = (byte)ProfileBank.Active;
            req.byPosMode = (byte)ProfilePos.Current;
            req.dwGetProfNo = 0;
            req.byGetProfCnt = 10;
            req.byErase = 0;

            LJV7IF_GET_PROFILE_RSP rsp = new LJV7IF_GET_PROFILE_RSP();
            LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();

            int profileDataSize = Define.MAX_PROFILE_COUNT +
                (Marshal.SizeOf(typeof(LJV7IF_PROFILE_HEADER)) + Marshal.SizeOf(typeof(LJV7IF_PROFILE_FOOTER))) / Marshal.SizeOf(typeof(int));
            int[] receiveBuffer = new int[profileDataSize * req.byGetProfCnt];

                using (PinnedObject pin = new PinnedObject(receiveBuffer))
                {
                    Rc rc = (Rc)NativeMethods.LJV7IF_GetProfile(Define.DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer,
                        (uint)(receiveBuffer.Length * Marshal.SizeOf(typeof(int))));
                    if (rc!=Rc.Ok) throw new Exception("Cannot Read High Speed Profile Data");
                }

                // Output the data of each profile
                List<ProfileData> profileDatas = new List<ProfileData>();
                int unitSize = ProfileData.CalculateDataSize(profileInfo);
                for (int i = 0; i < rsp.byGetProfCnt; i++)
                {
                    profileDatas.Add(new ProfileData(receiveBuffer, unitSize * i, profileInfo));
                }
                return GetHighSpeedProfileValueXML(profileDatas);
        }
Ejemplo n.º 4
0
        private XmlElement GetBatchProfileAdvanceValues()
        {
            LJV7IF_GET_BATCH_PROFILE_ADVANCE_REQ req = new LJV7IF_GET_BATCH_PROFILE_ADVANCE_REQ();
            req.byPosMode = (byte)BatchPos.Commited;
            req.dwGetBatchNo = 0;
            req.dwGetProfNo = 0;
            req.byGetProfCnt = byte.MaxValue;

            LJV7IF_GET_BATCH_PROFILE_ADVANCE_RSP rsp = new LJV7IF_GET_BATCH_PROFILE_ADVANCE_RSP();
            LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();
            LJV7IF_MEASURE_DATA[] batchMeasureData = new LJV7IF_MEASURE_DATA[NativeMethods.MeasurementDataCount];
            LJV7IF_MEASURE_DATA[] measureData = new LJV7IF_MEASURE_DATA[NativeMethods.MeasurementDataCount];

            int profileDataSize = Define.MAX_PROFILE_COUNT +
                (Marshal.SizeOf(typeof(LJV7IF_PROFILE_HEADER)) + Marshal.SizeOf(typeof(LJV7IF_PROFILE_FOOTER))) / Marshal.SizeOf(typeof(int));
            int measureDataSize = Marshal.SizeOf(typeof(LJV7IF_MEASURE_DATA)) * NativeMethods.MeasurementDataCount / Marshal.SizeOf(typeof(int));
            int[] receiveBuffer = new int[(profileDataSize + measureDataSize) * req.byGetProfCnt];

            List<ProfileData> profileDatas = new List<ProfileData>();
            // Get profiles.
            using (PinnedObject pin = new PinnedObject(receiveBuffer))
            {
                Rc rc = (Rc)NativeMethods.LJV7IF_GetBatchProfileAdvance(Define.DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer,
                    (uint)(receiveBuffer.Length * Marshal.SizeOf(typeof(int))), batchMeasureData, measureData);
                if (rc != Rc.Ok) throw new Exception("Cannot Read Batch Profile Advance Data");

                // Output the data of each profile
                int unitSize = ProfileData.CalculateDataSize(profileInfo) + measureDataSize;
                for (int i = 0; i < rsp.byGetProfCnt; i++)
                {
                    profileDatas.Add(new ProfileData(receiveBuffer, unitSize * i, profileInfo));
                }

                // Get all profiles within the batch.
                req.byPosMode = (byte)BatchPos.Spec;
                req.dwGetBatchNo = rsp.dwGetBatchNo;
                do
                {
                    // Update the get profile position
                    req.dwGetProfNo = rsp.dwGetBatchTopProfNo + rsp.byGetProfCnt;
                    req.byGetProfCnt = (byte)Math.Min((uint)(byte.MaxValue), (rsp.dwGetBatchProfCnt - req.dwGetProfNo));

                    rc = (Rc)NativeMethods.LJV7IF_GetBatchProfileAdvance(Define.DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer,
                        (uint)(receiveBuffer.Length * Marshal.SizeOf(typeof(int))), batchMeasureData, measureData);
                    if (rc != Rc.Ok) throw new Exception("Cannot Read Batch Profile Advance Data");
                    for (int i = 0; i < rsp.byGetProfCnt; i++)
                    {
                        profileDatas.Add(new ProfileData(receiveBuffer, unitSize * i, profileInfo));
                    }
                } while (rsp.dwGetBatchProfCnt != (rsp.dwGetBatchTopProfNo + rsp.byGetProfCnt));
            }
            return GetBatchProfileAdvanceValueXML(new MeasureData(batchMeasureData),new MeasureData(measureData),profileDatas);
        }
Ejemplo n.º 5
0
        private XmlElement GetBatchHighSpeedProfileValues()
        {
            // Specify the target batch to get.
            LJV7IF_GET_BATCH_PROFILE_REQ req = new LJV7IF_GET_BATCH_PROFILE_REQ();
            req.byTargetBank = (byte)ProfileBank.Active;
            req.byPosMode = (byte)BatchPos.Commited;
            req.dwGetBatchNo = 0;
            req.dwGetProfNo = 0;
            req.byGetProfCnt = byte.MaxValue;
            req.byErase = 0;

            LJV7IF_GET_BATCH_PROFILE_RSP rsp = new LJV7IF_GET_BATCH_PROFILE_RSP();
            LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();

            int profileDataSize = Define.MAX_PROFILE_COUNT +
                (Marshal.SizeOf(typeof(LJV7IF_PROFILE_HEADER)) + Marshal.SizeOf(typeof(LJV7IF_PROFILE_FOOTER))) / Marshal.SizeOf(typeof(int));
            int[] receiveBuffer = new int[profileDataSize * req.byGetProfCnt];
            List<ProfileData> profileDatas = new List<ProfileData>();
            // Get profiles
            using (PinnedObject pin = new PinnedObject(receiveBuffer))
            {
                Rc rc = (Rc)NativeMethods.LJV7IF_GetBatchProfile(Define.DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer,
                    (uint)(receiveBuffer.Length * Marshal.SizeOf(typeof(int))));
                if (rc != Rc.Ok) throw new Exception("Cannot Read Batch High Speed Profile");

                // Output the data of each profile
                int unitSize = ProfileData.CalculateDataSize(profileInfo);
                for (int i = 0; i < rsp.byGetProfCnt; i++)
                {
                    profileDatas.Add(new ProfileData(receiveBuffer, unitSize * i, profileInfo));
                }

                // Get all profiles within the batch.
                req.byPosMode = (byte)BatchPos.Spec;
                req.dwGetBatchNo = rsp.dwGetBatchNo;
                do
                {
                    // Update the get profile position
                    req.dwGetProfNo = rsp.dwGetBatchTopProfNo + rsp.byGetProfCnt;
                    req.byGetProfCnt = (byte)Math.Min((uint)(byte.MaxValue), (rsp.dwCurrentBatchProfCnt - req.dwGetProfNo));

                    rc = (Rc)NativeMethods.LJV7IF_GetBatchProfile(Define.DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer,
                        (uint)(receiveBuffer.Length * Marshal.SizeOf(typeof(int))));
                    if (rc != Rc.Ok) throw new Exception("Cannot Read Batch High Speed Profile");
                    for (int i = 0; i < rsp.byGetProfCnt; i++)
                    {
                        profileDatas.Add(new ProfileData(receiveBuffer, unitSize * i, profileInfo));
                    }
                } while (rsp.dwGetBatchProfCnt != (rsp.dwGetBatchTopProfNo + rsp.byGetProfCnt));
            }
            return GetHighSpeedProfileValueXML(profileDatas);
        }
Ejemplo n.º 6
0
        internal static extern int LJV7IF_PreStartHighSpeedDataCommunication(
		int lDeviceId, ref LJV7IF_HIGH_SPEED_PRE_START_REQ pReq,
		ref LJV7IF_PROFILE_INFO pProfileInfo);
Ejemplo n.º 7
0
        internal static extern int LJV7IF_GetStorageProfile(int lDeviceId, ref LJV7IF_GET_STORAGE_REQ pReq,
		ref LJV7IF_STORAGE_INFO pStorageInfo, ref LJV7IF_GET_STORAGE_RSP pRes,
		ref LJV7IF_PROFILE_INFO pProfileInfo, IntPtr pdwData, uint dwDataSize);
Ejemplo n.º 8
0
        internal static extern int LJV7IF_GetStorageBatchProfile(int lDeviceId,
		ref LJV7IF_GET_BATCH_PROFILE_STORAGE_REQ pReq, ref LJV7IF_STORAGE_INFO pStorageInfo,
		ref LJV7IF_GET_BATCH_PROFILE_STORAGE_RSP pRes, ref LJV7IF_PROFILE_INFO pProfileInfo,
		IntPtr pdwData, uint dwDataSize, ref uint pTimeOffset, [Out]LJV7IF_MEASURE_DATA[] pMeasureData);
Ejemplo n.º 9
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();
        }
Ejemplo n.º 10
0
        internal static extern int LJV7IF_GetProfile(int lDeviceId, ref LJV7IF_GET_PROFILE_REQ pReq,
		ref LJV7IF_GET_PROFILE_RSP pRsp, ref LJV7IF_PROFILE_INFO pProfileInfo, IntPtr pdwProfileData, uint dwDataSize);
Ejemplo n.º 11
0
        internal static extern int LJV7IF_GetBatchProfileAdvance(int lDeviceId, ref LJV7IF_GET_BATCH_PROFILE_ADVANCE_REQ pReq,
		ref LJV7IF_GET_BATCH_PROFILE_ADVANCE_RSP pRsp, ref LJV7IF_PROFILE_INFO pProfileInfo,
		IntPtr pdwBatchData, uint dwDataSize, [Out]LJV7IF_MEASURE_DATA[] pBatchMeasureData, [Out]LJV7IF_MEASURE_DATA[] pMeasureData);
Ejemplo n.º 12
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ProfileData(int[] receiveBuffer, LJV7IF_PROFILE_INFO profileInfo)
 {
     SetData(receiveBuffer, profileInfo);
 }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        private XmlElement GetProfileAdvanceValues()
        {
            LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();
            LJV7IF_MEASURE_DATA[] measureData = new LJV7IF_MEASURE_DATA[NativeMethods.MeasurementDataCount];

            int profileDataSize = Define.MAX_PROFILE_COUNT +
                (Marshal.SizeOf(typeof(LJV7IF_PROFILE_HEADER)) + Marshal.SizeOf(typeof(LJV7IF_PROFILE_FOOTER))) / Marshal.SizeOf(typeof(int));
            int[] receiveBuffer = new int[profileDataSize];	 // 3,207 (total of the header, the footer, and the 3,200 data entries)
            using (PinnedObject pin = new PinnedObject(receiveBuffer))
            {
                Rc rc = (Rc)NativeMethods.LJV7IF_GetProfileAdvance(Define.DEVICE_ID, ref profileInfo, pin.Pointer,
                (uint)(receiveBuffer.Length * Marshal.SizeOf(typeof(int))), measureData);
                if (rc != Rc.Ok) throw new Exception("Cannot Read Profile Advance Data");
            }
            List<ProfileData> profileDatas = new List<ProfileData>();
            // Output the data of each profile
            profileDatas.Add(new ProfileData(receiveBuffer, 0, profileInfo));
            return GetProfileAdvanceValueXML(new MeasureData(measureData), profileDatas);
        }
Ejemplo n.º 15
0
        internal static extern int LJV7IF_GetProfileAdvance(int lDeviceId, ref LJV7IF_PROFILE_INFO pProfileInfo,
		IntPtr pdwProfileData, uint dwDataSize, [Out]LJV7IF_MEASURE_DATA[] pMeasureData);
Ejemplo n.º 16
0
 private void PreStartHighSpeedDataCommunication()
 {
     LJV7IF_HIGH_SPEED_PRE_START_REQ req = new LJV7IF_HIGH_SPEED_PRE_START_REQ();
             LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();
             int rc = NativeMethods.LJV7IF_PreStartHighSpeedDataCommunication(_currentDeviceId, ref req, ref profileInfo);
             if (rc != (int)Rc.Ok)
             {
                 throw new Exception("Cannot Initialize High Speed Communication Initialization");
             }
 }
Ejemplo n.º 17
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));
        }