/// <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_PROFILE_RSP rsp) { StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format(@" CurrentProfNo : {0}", rsp.dwCurrentProfNo)); sb.AppendLine(string.Format(@" OldestProfNo : {0}", rsp.dwOldestProfNo)); sb.AppendLine(string.Format(@" GetTopProfNo : {0}", rsp.dwGetTopProfNo)); sb.Append(string.Format(@" GetProfCnt : {0}", rsp.byGetProfCnt)); return(sb); }
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);
/// <summary> /// "GetProfile" button clicked. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGetProfile_Click(object sender, EventArgs e) { _sendCommand = SendCommand.GetProfile; using (ProfileForm profileForm = new ProfileForm()) { if (DialogResult.OK == profileForm.ShowDialog()) { _deviceData[_currentDeviceId].ProfileData.Clear(); _deviceData[_currentDeviceId].MeasureData.Clear(); LJV7IF_GET_PROFILE_REQ req = profileForm.Req; LJV7IF_GET_PROFILE_RSP rsp = new LJV7IF_GET_PROFILE_RSP(); LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO(); uint oneProfDataBuffSize = GetOneProfileDataSize(); uint allProfDataBuffSize = oneProfDataBuffSize * req.byGetProfCnt; int[] profileData = new int[allProfDataBuffSize / Marshal.SizeOf(typeof(int))]; using (PinnedObject pin = new PinnedObject(profileData)) { int rc = NativeMethods.LJV7IF_GetProfile(_currentDeviceId, ref req, ref rsp, ref profileInfo, pin.Pointer, allProfDataBuffSize); AddLogResult(rc, Resources.SID_GET_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!!"); } } } } } }
/// <summary> /// "Get high-speed mode profiles" button clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// Get profiles in high-speed mode, and then output profile data to file. /// </remarks> private void btnGetProfileEx_Click(object sender, EventArgs e) { 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 (ProgressForm progressForm = new ProgressForm()) { Cursor.Current = Cursors.WaitCursor; progressForm.Status = Status.Communicating; progressForm.Show(this); progressForm.Refresh(); // Get profiles. 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 (!CheckReturnCode(rc)) return; } // 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)); } progressForm.Status = Status.Saving; progressForm.Refresh(); // Save the file SaveProfile(profileDatas, _txtSavePath.Text); } }
/// <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_PROFILE_RSP rsp) { StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format(@" CurrentProfNo : {0}", rsp.dwCurrentProfNo)); sb.AppendLine(string.Format(@" OldestProfNo : {0}", rsp.dwOldestProfNo)); sb.AppendLine(string.Format(@" GetTopProfNo : {0}", rsp.dwGetTopProfNo)); sb.Append(string.Format(@" GetProfCnt : {0}", rsp.byGetProfCnt)); return sb; }