Example #1
0
        /// <summary>
        /// Get the string for log output.
        /// </summary>
        /// <param name="obj">Structure that you want to convert to a string</param>
        /// <returns>String for log output</returns>
        public static StringBuilder ConvertToLogString(LJV7IF_GET_BATCH_PROFILE_RSP rsp)
        {
            StringBuilder sb = new StringBuilder();

            // Profile information of the profile obtained
            sb.AppendLine(string.Format(@"  CurrentBatchNo			: {0}", rsp.dwCurrentBatchNo));
            sb.AppendLine(string.Format(@"  CurrentBatchProfCnt		: {0}", rsp.dwCurrentBatchProfCnt));
            sb.AppendLine(string.Format(@"  OldestBatchNo			: {0}", rsp.dwOldestBatchNo));
            sb.AppendLine(string.Format(@"  OldestBatchProfCnt		: {0}", rsp.dwOldestBatchProfCnt));
            sb.AppendLine(string.Format(@"  GetBatchNo			: {0}", rsp.dwGetBatchNo));
            sb.AppendLine(string.Format(@"  GetBatchProfCnt			: {0}", rsp.dwGetBatchProfCnt));
            sb.AppendLine(string.Format(@"  GetBatchTopProfNo		: {0}", rsp.dwGetBatchTopProfNo));
            sb.AppendLine(string.Format(@"  GetProfCnt			: {0}", rsp.byGetProfCnt));
            sb.Append(string.Format(@"  CurrentBatchCommited		: {0}", rsp.byCurrentBatchCommited));

            return(sb);
        }
Example #2
0
        internal static extern int LJV7IF_GetBatchProfile(int lDeviceId, ref LJV7IF_GET_BATCH_PROFILE_REQ pReq,
		ref LJV7IF_GET_BATCH_PROFILE_RSP pRsp, ref LJV7IF_PROFILE_INFO pProfileInfo,
		IntPtr pdwBatchData, uint dwDataSize);
Example #3
0
        /// <summary>
        /// "GetBatchProfile" button clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGetBatchProfile_Click(object sender, EventArgs e)
        {
            _sendCommand = SendCommand.GetBatchProfile;

            using (GetBatchProfileForm getBatchProfileForm = new GetBatchProfileForm())
            {
                if (DialogResult.OK == getBatchProfileForm.ShowDialog())
                {
                    _deviceData[_currentDeviceId].ProfileData.Clear();
                    _deviceData[_currentDeviceId].MeasureData.Clear();
                    // Set the command function
                    LJV7IF_GET_BATCH_PROFILE_REQ req = getBatchProfileForm.Req;
                    LJV7IF_GET_BATCH_PROFILE_RSP rsp = new LJV7IF_GET_BATCH_PROFILE_RSP();
                    LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();
                    uint oneDataSize = GetOneProfileDataSize();
                    uint allDataSize = oneDataSize * getBatchProfileForm.Req.byGetProfCnt;
                    int[] profileData = new int[allDataSize / Marshal.SizeOf(typeof(int))];

                    using (PinnedObject pin = new PinnedObject(profileData))
                    {
                        // Send the command
                        int rc = NativeMethods.LJV7IF_GetBatchProfile(_currentDeviceId, ref req, ref rsp, ref profileInfo, pin.Pointer, allDataSize);
                        // @Point
                        // # When reading all the profiles from a single batch, the specified number of profiles may not be read.
                        // # To read the remaining profiles after the first set of profiles have been read,
                        //    set the specification method (byPosMode)to 0x02, specify the batch number (dwGetBatchNo),
                        //    and then set the number to start reading profiles from (dwGetProfNo) and the number of profiles to read (byGetProfCnt) to values
                        //    that specify a range of profiles that have not been read to read the profiles in order.
                        // # For the basic code, see "btnGetBatchProfileEx_Click."

                        // Result output
                        AddLogResult(rc, Resources.SID_GET_BATCH_PROFILE);
                        if (rc == (int)Rc.Ok)
                        {
                            // Response data display
                            AddLog(Utility.ConvertToLogString(rsp).ToString());
                            AddLog(Utility.ConvertToLogString(profileInfo).ToString());

                            AnalyzeProfileData((int)rsp.byGetProfCnt, ref profileInfo, profileData);

                            // Profile export
                            if (DataExporter.ExportOneProfile(_deviceData[_currentDeviceId].ProfileData.ToArray(), 0, _txtboxProfileFilePath.Text))
                            {
                                AddLog(@"###Saved!!");
                            }

                        }
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// "Get high-speed mode batch profiles" button clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// Read one batch worth of committed profiles that have been acquired with batch measurement in high-speed mode.
        /// </remarks>
        private void btnGetBatchProfileEx_Click(object sender, EventArgs e)
        {
            // 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];

            using (ProgressForm progressForm = new ProgressForm())
            {
                Cursor.Current = Cursors.WaitCursor;

                progressForm.Status = Status.Communicating;
                progressForm.Show(this);
                progressForm.Refresh();

                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))));
                    // @Point
                    // # When reading all the profiles from a single batch, the specified number of profiles may not be read.
                    // # To read the remaining profiles after the first set of profiles have been read, set the specification method (byPosMode)to 0x02,
                    //   specify the batch number (dwGetBatchNo), and then set the number to start reading profiles from (dwGetProfNo) and
                    //   the number of profiles to read (byGetProfCnt) to values that specify a range of profiles that have not been read to read the profiles in order.
                    // # In more detail, this process entails:
                    //   * First configure req as listed below and call this function again.
                    //      byPosMode = LJV7IF_BATCH_POS_SPEC
                    //      dwGetBatchNo = batch number that was read
                    //      byGetProfCnt = Profile number of unread in the batch
                    //   * Furthermore, if all profiles in the batch are not read,update the starting position for reading profiles (req.dwGetProfNo) and
                    //     the number of profiles to read (req.byGetProfCnt), and then call LJV7IF_GetBatchProfile again. (Repeat this process until all the profiles have been read.)

                    if (!CheckReturnCode(rc)) return;

                    // 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 (!CheckReturnCode(rc)) return;
                        for (int i = 0; i < rsp.byGetProfCnt; i++)
                        {
                            profileDatas.Add(new ProfileData(receiveBuffer, unitSize * i, profileInfo));
                        }
                    } while (rsp.dwGetBatchProfCnt != (rsp.dwGetBatchTopProfNo + rsp.byGetProfCnt));
                }

                progressForm.Status = Status.Saving;
                progressForm.Refresh();
                // Save the file
                SaveProfile(profileDatas, _txtSavePath.Text);
            }
        }
 internal static extern int LJV7IF_GetBatchProfile(int lDeviceId, ref LJV7IF_GET_BATCH_PROFILE_REQ pReq,
                                                   ref LJV7IF_GET_BATCH_PROFILE_RSP pRsp, ref LJV7IF_PROFILE_INFO pProfileInfo,
                                                   IntPtr pdwBatchData, uint dwDataSize);
Example #6
0
        /// <summary>
        /// Get the string for log output.
        /// </summary>
        /// <param name="obj">Structure that you want to convert to a string</param>
        /// <returns>String for log output</returns>
        public static StringBuilder ConvertToLogString(LJV7IF_GET_BATCH_PROFILE_RSP rsp)
        {
            StringBuilder sb = new StringBuilder();

            // Profile information of the profile obtained
            sb.AppendLine(string.Format(@"  CurrentBatchNo			: {0}", rsp.dwCurrentBatchNo));
            sb.AppendLine(string.Format(@"  CurrentBatchProfCnt		: {0}", rsp.dwCurrentBatchProfCnt));
            sb.AppendLine(string.Format(@"  OldestBatchNo			: {0}", rsp.dwOldestBatchNo));
            sb.AppendLine(string.Format(@"  OldestBatchProfCnt		: {0}", rsp.dwOldestBatchProfCnt));
            sb.AppendLine(string.Format(@"  GetBatchNo			: {0}", rsp.dwGetBatchNo));
            sb.AppendLine(string.Format(@"  GetBatchProfCnt			: {0}", rsp.dwGetBatchProfCnt));
            sb.AppendLine(string.Format(@"  GetBatchTopProfNo		: {0}", rsp.dwGetBatchTopProfNo));
            sb.AppendLine(string.Format(@"  GetProfCnt			: {0}", rsp.byGetProfCnt));
            sb.Append(string.Format    (@"  CurrentBatchCommited		: {0}", rsp.byCurrentBatchCommited));

            return sb;
        }