/// <summary> /// AnalyzeProfileData /// </summary> /// <param name="profileCount">Number of profiles that were read</param> /// <param name="profileInfo">Profile information structure</param> /// <param name="profileData">Acquired profile data</param> private void ExtractProfileData(int profileCount, ref LJV7IF_PROFILE_INFO profileInfo, int[] profileData) { try { int dataUnit = ProfileData.CalculateDataSize(profileInfo); ExtractProfileData(profileCount, ref profileInfo, profileData, 0, dataUnit); } catch (Exception) { throw; } }
/// <summary> /// "High-speed mode get profiles" button pressed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _btnGetProfile_Click(object sender, EventArgs e) { LJV7IF_GET_PROFILE_REQ req = new LJV7IF_GET_PROFILE_REQ(); req.byTargetBank = ProfileBank.Active; req.byPosMode = 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 = MAX_PROFILE_COUNT + (Marshal.SizeOf(typeof(LJV7IF_PROFILE_HEADER)) + Marshal.SizeOf(typeof(LJV7IF_PROFILE_FOOTER))) / sizeof(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(DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer, (uint)(receiveBuffer.Length * sizeof(int))); if (!CheckReturnCode(rc)) { return; } } // Output profile data 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 file SaveProfile(profileDatas, _txtSavePath.Text); } }
public List <DataLib.CartData> GetStoredProfiles() { try { var profDataList = new List <DataLib.CartData> (); 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]; Rc rc; // Get profiles. using (PinnedObject pin = new PinnedObject(receiveBuffer)) { rc = (Rc)NativeMethods.LJV7IF_GetProfile(Define.DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer, (uint)(receiveBuffer.Length * Marshal.SizeOf(typeof(int)))); } // CheckReturnValue(rc); // 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)); } foreach (var profile in profileDatas) { profDataList.Add(profile.GetCartData(_scalingMultiplier)); } return(profDataList); } catch (Exception) { throw; } }
/// <summary> /// AnalyzeProfileData /// </summary> /// <param name="profileCount">Number of profiles that were read</param> /// <param name="profileInfo">Profile information structure</param> /// <param name="profileData">Acquired profile data</param> /// <param name="startProfileIndex">Start position of the profiles to copy</param> /// <param name="dataUnit">Profile data size</param> private void ExtractProfileData(int profileCount, ref LJV7IF_PROFILE_INFO profileInfo, int[] profileData, int startProfileIndex, int dataUnit) { try { int readPropfileDataSize = ProfileData.CalculateDataSize(profileInfo); int[] tempRecvieProfileData = new int[readPropfileDataSize]; // Profile data retention for (int i = 0; i < profileCount; i++) { Array.Copy(profileData, (startProfileIndex + i * dataUnit), tempRecvieProfileData, 0, readPropfileDataSize); _deviceData.ProfileData.Add(new ProfileData(tempRecvieProfileData, profileInfo)); } } catch (Exception) { throw; } }
/// <summary> /// "Advanced mode get batch profiles" button pressed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _btnGetBatchProfileAdvance_Click(object sender, EventArgs e) { MessageBox.Show("Start advanced mode get batch profiles.\r\nCheck that LJ-Navigator 2 is not starting up"); LJV7IF_GET_BATCH_PROFILE_ADVANCE_REQ req = new LJV7IF_GET_BATCH_PROFILE_ADVANCE_REQ(); req.byPosMode = 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.MesurementDataCount]; LJV7IF_MEASURE_DATA[] measureData = new LJV7IF_MEASURE_DATA[NativeMethods.MesurementDataCount]; int profileDataSize = MAX_PROFILE_COUNT + (Marshal.SizeOf(typeof(LJV7IF_PROFILE_HEADER)) + Marshal.SizeOf(typeof(LJV7IF_PROFILE_FOOTER))) / sizeof(int); int measureDataSize = Marshal.SizeOf(typeof(LJV7IF_MEASURE_DATA)) * NativeMethods.MesurementDataCount / sizeof(int); int[] receiveBuffer = new int[(profileDataSize + measureDataSize) * 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_GetBatchProfileAdvance(DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer, (uint)(receiveBuffer.Length * sizeof(int)), batchMeasureData, measureData); if (!CheckReturnCode(rc)) { return; } // Output profile data 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 in the batch. req.byPosMode = BatchPos.Spec; req.dwGetBatchNo = rsp.dwGetBatchNo; do { // Update 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(DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer, (uint)(receiveBuffer.Length * sizeof(int)), batchMeasureData, measureData); 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 file SaveProfile(profileDatas, _txtSavePath.Text); } }
/// <summary> /// "High-speed mode get batch profiles" button pressed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _btnGetBatchProfile_Click(object sender, EventArgs e) { // Specify get target batch. LJV7IF_GET_BATCH_PROFILE_REQ req = new LJV7IF_GET_BATCH_PROFILE_REQ(); req.byTargetBank = ProfileBank.Active; req.byPosMode = 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 = MAX_PROFILE_COUNT + (Marshal.SizeOf(typeof(LJV7IF_PROFILE_HEADER)) + Marshal.SizeOf(typeof(LJV7IF_PROFILE_FOOTER))) / sizeof(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(DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer, (uint)(receiveBuffer.Length * sizeof(int))); if (!CheckReturnCode(rc)) { return; } // Output profile data int unitSize = ProfileData.CalculateDataSize(profileInfo); for (int i = 0; i < rsp.byGetProfCnt; i++) { profileDatas.Add(new ProfileData(receiveBuffer, unitSize * i, profileInfo)); } // Get all profiles in the batch. req.byPosMode = BatchPos.Spec; req.dwGetBatchNo = rsp.dwGetBatchNo; do { // Update 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(DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer, (uint)(receiveBuffer.Length * sizeof(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 file SaveProfile(profileDatas, _txtSavePath.Text); } }
/// <summary> /// 「高機能モードバッチプロファイル取得」ボタン押下 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _btnGetBatchProfileAdvance_Click(object sender, EventArgs e) { MessageBox.Show("高機能モードバッチプロファイル取得を開始します。\nLJ-Navigator 2 が起動していないことをご確認のうえ、OKを押してください。"); LJV7IF_GET_BATCH_PROFILE_ADVANCE_REQ req = new LJV7IF_GET_BATCH_PROFILE_ADVANCE_REQ(); req.byPosMode = 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.MesurementDataCount]; LJV7IF_MEASURE_DATA[] measureData = new LJV7IF_MEASURE_DATA[NativeMethods.MesurementDataCount]; int profileDataSize = MAX_PROFILE_COUNT + (Marshal.SizeOf(typeof(LJV7IF_PROFILE_HEADER)) + Marshal.SizeOf(typeof(LJV7IF_PROFILE_FOOTER))) / sizeof(int); int measureDataSize = Marshal.SizeOf(typeof(LJV7IF_MEASURE_DATA)) * NativeMethods.MesurementDataCount / sizeof(int); int[] receiveBuffer = new int[(profileDataSize + measureDataSize) * 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>(); // プロファイルを取得 using (PinnedObject pin = new PinnedObject(receiveBuffer)) { Rc rc = (Rc)NativeMethods.LJV7IF_GetBatchProfileAdvance(DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer, (uint)(receiveBuffer.Length * sizeof(int)), batchMeasureData, measureData); if (!CheckReturnCode(rc)) { return; } // 各プロファイルデータを出力 int unitSize = ProfileData.CalculateDataSize(profileInfo) + measureDataSize; for (int i = 0; i < rsp.byGetProfCnt; i++) { profileDatas.Add(new ProfileData(receiveBuffer, unitSize * i, profileInfo)); } // バッチ内のプロファイルをすべて取得 req.byPosMode = BatchPos.Spec; req.dwGetBatchNo = rsp.dwGetBatchNo; do { // 取得プロファイル位置を更新 req.dwGetProfNo = rsp.dwGetBatchTopProfNo + rsp.byGetProfCnt; req.byGetProfCnt = (byte)Math.Min((uint)(byte.MaxValue), (rsp.dwGetBatchProfCnt - req.dwGetProfNo)); rc = (Rc)NativeMethods.LJV7IF_GetBatchProfileAdvance(DEVICE_ID, ref req, ref rsp, ref profileInfo, pin.Pointer, (uint)(receiveBuffer.Length * sizeof(int)), batchMeasureData, measureData); 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(); // ファイル保存 SaveProfile(profileDatas, _txtSavePath.Text); } }