Exemple #1
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);
            }
        }
Exemple #2
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!!");
                            }

                        }
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// High-speed data communication "Start" button clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>Perform the preparations for starting high-speed data communication, and then start high-speed data communication.</remarks>
        private void btnBeginHighSpeedCommunicationEx_Click(object sender, EventArgs e)
        {
            // Stop and finalize high-speed data communication.
            NativeMethods.LJV7IF_StopHighSpeedDataCommunication(Define.DEVICE_ID);
            NativeMethods.LJV7IF_HighSpeedDataCommunicationFinalize(Define.DEVICE_ID);

            // Initialize the data.
            ThreadSafeBuffer.Clear(Define.DEVICE_ID);
            Rc rc = Rc.Ok;

            // Initialize the high-speed communication path
            // High-speed communication start preparations
            LJV7IF_HIGH_SPEED_PRE_START_REQ req = new LJV7IF_HIGH_SPEED_PRE_START_REQ();
            try
            {
                uint frequency = Convert.ToUInt32(_txtCallbackFrequency.Text);
                uint threadId  = (uint)Define.DEVICE_ID;

                if (_rdUsb.Checked)
                {
                    // Initialize USB high-speed data communication
                    rc = (Rc)NativeMethods.LJV7IF_HighSpeedDataUsbCommunicationInitalize(Define.DEVICE_ID, _callback, frequency, threadId);
                }
                else
                {
                    // Generate the settings for Ethernet communication.
                    ushort highSpeedPort = 0;
                    _ethernetConfig.abyIpAddress = new byte[] {
                        Convert.ToByte(_txtIpFirstSegment.Text),
                        Convert.ToByte(_txtIpSecondSegment.Text),
                        Convert.ToByte(_txtIpThirdSegment.Text),
                        Convert.ToByte(_txtIpFourthSegment.Text)
                    };
                    _ethernetConfig.wPortNo = Convert.ToUInt16(_txtCommandPort.Text);
                    highSpeedPort = Convert.ToUInt16(_txtHighSpeedPort.Text);

                    // Initialize Ethernet high-speed data communication
                    rc = (Rc)NativeMethods.LJV7IF_HighSpeedDataEthernetCommunicationInitalize(Define.DEVICE_ID, ref _ethernetConfig,
                        highSpeedPort, _callback, frequency, threadId);
                }
                if (!CheckReturnCode(rc)) return;
                req.bySendPos = Convert.ToByte(_txtStartProfileNo.Text);
            }
            catch (FormatException ex)
            {
                MessageBox.Show(this, ex.Message);
                return;
            }
            catch (OverflowException ex)
            {
                MessageBox.Show(this, ex.Message);
                return;
            }

            // High-speed data communication start preparations
            LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();
            rc = (Rc)NativeMethods.LJV7IF_PreStartHighSpeedDataCommunication(Define.DEVICE_ID, ref req, ref profileInfo);
            if (!CheckReturnCode(rc)) return;

            // Start high-speed data communication.
            rc = (Rc)NativeMethods.LJV7IF_StartHighSpeedDataCommunication(Define.DEVICE_ID);
            if (!CheckReturnCode(rc)) return;

            _lblReceiveProfileCount.Text = "0";
            _timerHighSpeed.Start();
        }
Exemple #4
0
        /// <summary>
        /// "GetBatchProfileAdvance" button clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGetBatchProfileAdvance_Click(object sender, EventArgs e)
        {
            _sendCommand = SendCommand.GetBatchProfileAdvance;

            using (GetBatchprofileAdvanceForm getBatchprofileAdvanceForm = new GetBatchprofileAdvanceForm())
            {
                if (DialogResult.OK == getBatchprofileAdvanceForm.ShowDialog())
                {
                    _deviceData[_currentDeviceId].ProfileData.Clear();
                    _deviceData[_currentDeviceId].MeasureData.Clear();
                    _measureDatas.Clear();

                    // Set the command function
                    LJV7IF_GET_BATCH_PROFILE_ADVANCE_REQ req = getBatchprofileAdvanceForm.Req;
                    LJV7IF_GET_BATCH_PROFILE_ADVANCE_RSP rsp = new LJV7IF_GET_BATCH_PROFILE_ADVANCE_RSP();
                    LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();
                    uint oneDataSize = GetOneProfileDataSize() + (uint)Utility.GetByteSize(Utility.TypeOfStruct.MEASURE_DATA) * (uint)NativeMethods.MeasurementDataCount;
                    uint allDataSize = oneDataSize * getBatchprofileAdvanceForm.Req.byGetProfCnt;
                    int[] profileData = new int[allDataSize / Marshal.SizeOf(typeof(int))];
                    LJV7IF_MEASURE_DATA[] measureData = new LJV7IF_MEASURE_DATA[NativeMethods.MeasurementDataCount];
                    LJV7IF_MEASURE_DATA[] batchMeasureData = new LJV7IF_MEASURE_DATA[NativeMethods.MeasurementDataCount];

                    using (PinnedObject pin = new PinnedObject(profileData))
                    {
                        // Send the command
                        int rc = NativeMethods.LJV7IF_GetBatchProfileAdvance(_currentDeviceId, ref req, ref rsp,
                            ref profileInfo, pin.Pointer, allDataSize, batchMeasureData, measureData);
                        // @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_ADVANCE);
                        if (rc == (int)Rc.Ok)
                        {
                            _measureDatas.Add(new MeasureData(0, measureData));
                            AddLog(Utility.ConvertToLogString(rsp).ToString());
                            AddLog(Utility.ConvertToLogString(profileInfo).ToString());
                            for (int i = 0; i < NativeMethods.MeasurementDataCount; i++)
                            {
                                AddLog(string.Format("  OUT{0:00}: {1}", (i + 1), Utility.ConvertToLogString(measureData[i]).ToString()));
                            }

                            AnalyzeBatchData((int)rsp.byGetProfCnt, ref profileInfo, false, profileData, 0);

                            // Profile export
                            if (DataExporter.ExportOneProfile(_deviceData[_currentDeviceId].ProfileData.ToArray(), 0, _txtboxProfileFilePath.Text))
                            {
                                AddLog(@"###Saved!!");
                            }
                        }
                    }
                }
            }
        }
        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);
Exemple #6
0
        /// <summary>
        /// "Get advanced mode profiles" button clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// Get profiles in advanced mode, and then output profile data to file.
        /// </remarks>
        private void btnGetProfileAdvanceEx_Click(object sender, EventArgs e)
        {
            LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();
            LJV7IF_MEASURE_DATA[] measureData = new LJV7IF_MEASURE_DATA[NativeMethods.MeasurementDataCount];		 // OUT1 to OUT16 measurement value

            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 (!CheckReturnCode(rc)) return;
            }

            List<ProfileData> profileDatas = new List<ProfileData>();
            // Output the data of each profile
            profileDatas.Add(new ProfileData(receiveBuffer, 0, profileInfo));

            // Save the file
            SaveProfile(profileDatas, _txtSavePath.Text);
        }
Exemple #7
0
        /// <summary>
        /// "PreStartHighSpeedDataCommunication" button clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPreStartHighSpeedDataCommunication_Click(object sender, EventArgs e)
        {
            _sendCommand = SendCommand.PreStartHighSpeedDataCommunication;

            using (PreStartHighSpeedForm preStartHighSpeedForm = new PreStartHighSpeedForm())
            {
                if (DialogResult.OK == preStartHighSpeedForm.ShowDialog())
                {
                    LJV7IF_HIGH_SPEED_PRE_START_REQ req = preStartHighSpeedForm.Req;
                    // @Point
                    // # SendPos is used to specify which profile to start sending data from during high-speed communication.
                    // # When "Overwrite" is specified for the operation when memory full and
                    //   "0: From previous send complete position" is specified for the send start position,
                    //    if the LJ-V continues to accumulate profiles, the LJ-V memory will become full,
                    //    and the profile at the previous send complete position will be overwritten with a new profile.
                    //    In this situation, because the profile at the previous send complete position is not saved, an error will occur.

                    LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();

                    int rc = NativeMethods.LJV7IF_PreStartHighSpeedDataCommunication(_currentDeviceId, ref req, ref profileInfo);
                    AddLogResult(rc, Resources.SID_PRE_START_HIGH_SPEED_DATA_COMMUNICATION);
                    if (rc == (int)Rc.Ok)
                    {
                        // Response data display
                        AddLog(Utility.ConvertToLogString(profileInfo).ToString());
                        _profileInfo[_currentDeviceId] = profileInfo;
                    }
                }
            }
        }
        internal static extern int LJV7IF_GetProfileAdvance(int lDeviceId, ref LJV7IF_PROFILE_INFO pProfileInfo,
		IntPtr pdwProfileData, uint dwDataSize, [Out]LJV7IF_MEASURE_DATA[] pMeasureData);
Exemple #9
0
        /// <summary>
        /// "GetStorageBatchProfile" button clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGetStorageBatchProfile_Click(object sender, EventArgs e)
        {
            _sendCommand = SendCommand.GetStorageBatchProfile;

            using (GetStorageBatchProfileForm getStorageBatchProfileForm = new GetStorageBatchProfileForm())
            {
                if (DialogResult.OK == getStorageBatchProfileForm.ShowDialog())
                {
                    _deviceData[_currentDeviceId].ProfileData.Clear();
                    _deviceData[_currentDeviceId].MeasureData.Clear();
                    _measureDatas.Clear();
                    // Set the function data
                    LJV7IF_GET_BATCH_PROFILE_STORAGE_REQ req = getStorageBatchProfileForm.Req;
                    LJV7IF_STORAGE_INFO storageInfo = new LJV7IF_STORAGE_INFO();
                    LJV7IF_GET_BATCH_PROFILE_STORAGE_RSP rsp = new LJV7IF_GET_BATCH_PROFILE_STORAGE_RSP();
                    LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();
                    uint oneDataSize = GetOneProfileDataSize() + (uint)(Utility.GetByteSize(Utility.TypeOfStruct.MEASURE_DATA) * (uint)NativeMethods.MeasurementDataCount);
                    uint allDataSize = oneDataSize * getStorageBatchProfileForm.Req.byGetProfCnt;
                    LJV7IF_MEASURE_DATA[] measureData = new LJV7IF_MEASURE_DATA[NativeMethods.MeasurementDataCount];
                    int[] profileData = new int[allDataSize / Marshal.SizeOf(typeof(int))];
                    uint offsetTime = 0;

                    using (PinnedObject pin = new PinnedObject(profileData))
                    {
                        // Send the command
                        int rc = NativeMethods.LJV7IF_GetStorageBatchProfile(_currentDeviceId, ref req, ref storageInfo,
                            ref rsp, ref profileInfo, pin.Pointer, allDataSize, ref offsetTime, measureData);
                        // @Point
                        // # Terminology
                        //  * Base time … time expressed with 32 bits (<- the time when the setting was changed)
                        //  * Accumulated date and time	 … counter value that indicates the elapsed time, in units of 10 ms, from the base time
                        // # The accumulated date and time are stored in the accumulated data.
                        // # The accumulated time of read data is calculated as shown below.
                        //   Accumulated time = "base time (stBaseTime of LJV7IF_GET_STORAGE_RSP)" + "accumulated date and time × 10 ms"

                        // @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,
                        //   specify the batch number (dwGetBatchNo), and then set the number to start reading profiles
                        //   from (dwGetTopProfNo) 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_STORAGE_BATCH_PROFILE);
                        if (rc == (int)Rc.Ok)
                        {
                            AnalyzeBatchData((int)rsp.byGetProfCnt, ref profileInfo, false, profileData, 0);

                            _measureDatas.Add(new MeasureData(offsetTime, measureData));
                            // Response data display
                            AddLog(Utility.ConvertToLogString(storageInfo).ToString());
                            AddLog(Utility.ConvertToLogString(rsp).ToString());
                            AddLog(Utility.ConvertToLogString(profileInfo).ToString());
                            AddLog(string.Format(@"offsetTime	:{0}", offsetTime));
                        }
                    }
                }
            }
        }
Exemple #10
0
        /// <summary>
        /// "GetStorageProfile" button clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGetStorageProfile_Click(object sender, EventArgs e)
        {
            _sendCommand = SendCommand.GetStorageProfile;

            using (GetStorageDataForm getStorageData = new GetStorageDataForm())
            {
                if (DialogResult.OK == getStorageData.ShowDialog())
                {
                    _deviceData[_currentDeviceId].ProfileData.Clear();
                    _deviceData[_currentDeviceId].MeasureData.Clear();
                    _measureDatas.Clear();
                    LJV7IF_GET_STORAGE_REQ req = getStorageData.Req;
                    // @Point
                    // # dwReadArea is the target surface to read.
                    //   The target surface to read indicates where in the internal memory usage area to read.
                    // # The method to use in specifying dwReadArea varies depending on how internal memory is allocated.
                    //   * Double buffer
                    //      0 indicates the active surface, 1 indicates surface A, and 2 indicates surface B.
                    //   * Entire area (overwrite)
                    //      Fixed to 1
                    //   * Entire area (do not overwrite)
                    //      After a setting modification, data is saved in surfaces 1, 2, 3, and so on in order, and 0 is set as the active surface.
                    // # For details, see "9.2.9.2 Internal memory."

                    LJV7IF_STORAGE_INFO storageInfo = new LJV7IF_STORAGE_INFO();
                    LJV7IF_GET_STORAGE_RSP rsp = new LJV7IF_GET_STORAGE_RSP();
                    LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();

                    uint oneDataSize = (uint)(Marshal.SizeOf(typeof(uint)) + (uint)Utility.GetByteSize(Utility.TypeOfStruct.MEASURE_DATA)
                        * (uint)NativeMethods.MeasurementDataCount * 2 + GetOneProfileDataSize());
                    uint allDataSize = Math.Min(Define.READ_DATA_SIZE, oneDataSize * getStorageData.Req.dwDataCnt);
                    byte[] receiveData = new byte[allDataSize];
                    using (PinnedObject pin = new PinnedObject(receiveData))
                    {
                        int rc = NativeMethods.LJV7IF_GetStorageProfile(_currentDeviceId, ref req, ref storageInfo, ref rsp, ref profileInfo, pin.Pointer, allDataSize);
                        // @Point
                        // # Terminology
                        //  * Base time … time expressed with 32 bits (<- the time when the setting was changed)
                        //  * Accumulated date and time	 … counter value that indicates the elapsed time, in units of 10 ms, from the base time
                        // # The accumulated date and time are stored in the accumulated data.
                        // # The accumulated time of read data is calculated as shown below.
                        //   Accumulated time = "base time (stBaseTime of LJV7IF_GET_STORAGE_RSP)" + "accumulated date and time × 10 ms"

                        // @Point
                        // # When reading multiple profiles, 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 number to start reading profiles from (dwStartNo) and the number of profiles to read (byDataCnt)
                        //   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."

                        AddLogResult(rc, Resources.SID_GET_STORAGE_PROFILE);
                        if (rc == (int)Rc.Ok)
                        {
                            // Temporarily retain the get data.
                            int measureDataSize = MeasureData.GetByteSize();
                            int profileDataSize = ProfileData.CalculateDataSize(profileInfo) * Marshal.SizeOf(typeof(int));
                            int profileMeasureDataSize = Utility.GetByteSize(Utility.TypeOfStruct.MEASURE_DATA) * NativeMethods.MeasurementDataCount;
                            int byteSize = measureDataSize + profileDataSize + profileMeasureDataSize;
                            byte[] tempRecvieMeasureData = new byte[profileMeasureDataSize];

                            for (int i = 0; i < (int)rsp.dwDataCnt; i++)
                            {
                                _measureDatas.Add(new MeasureData(receiveData, byteSize * i));
                                _deviceData[_currentDeviceId].ProfileData.Add(new ProfileData(receiveData, (measureDataSize + byteSize * i), profileInfo));
                                Buffer.BlockCopy(receiveData, (measureDataSize + profileDataSize + byteSize * i), tempRecvieMeasureData, 0, profileMeasureDataSize);
                                _deviceData[_currentDeviceId].MeasureData.Add(new MeasureData(tempRecvieMeasureData));
                            }

                            // Response data display
                            AddLog(Utility.ConvertToLogString(storageInfo).ToString());
                            AddLog(Utility.ConvertToLogString(rsp).ToString());
                            AddLog(Utility.ConvertToLogString(profileInfo).ToString());
                        }
                    }
                }
            }
        }
Exemple #11
0
        /// <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!!");
                            }
                        }
                    }
                }
            }
        }
Exemple #12
0
        /// <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);
            }
        }
Exemple #13
0
        /// <summary>
        /// "GetProfileAdvance" button clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGetProfileAdvance_Click(object sender, EventArgs e)
        {
            _sendCommand = SendCommand.GetProfileAdvance;
            _deviceData[_currentDeviceId].ProfileData.Clear();
            _deviceData[_currentDeviceId].MeasureData.Clear();
            _measureDatas.Clear();

            // Set the command function
            LJV7IF_PROFILE_INFO profileInfo = new LJV7IF_PROFILE_INFO();
            uint dataSize = GetOneProfileDataSize();
            int[] profileData = new int[dataSize / Marshal.SizeOf(typeof(int))];
            LJV7IF_MEASURE_DATA[] measureData = new LJV7IF_MEASURE_DATA[NativeMethods.MeasurementDataCount];

            using (PinnedObject pin = new PinnedObject(profileData))
            {
                // Send the command
                int rc = NativeMethods.LJV7IF_GetProfileAdvance(_currentDeviceId, ref profileInfo, pin.Pointer, dataSize, measureData);

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

                    _measureDatas.Add(new MeasureData(0, measureData));
                    AnalyzeProfileData(1, ref profileInfo, profileData);
                    for (int i = 0; i < NativeMethods.MeasurementDataCount; i++)
                    {
                        AddLog(string.Format("  OUT{0:00}: {1}", (i + 1), Utility.ConvertToLogString(measureData[i]).ToString()));
                    }
                }
            }
        }
        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);
Exemple #15
0
        /// <summary>
        /// AnalyzeBatchData
        /// </summary>
        /// <param name="profileCount">Number of profiles that were read</param>
        /// <param name="profileInfo">Profile information structure</param>
        /// <param name="includeTimeData">Whether to include the time offset</param>
        /// <param name="batchData">Acquired batch profile data</param>
        /// <param name="startProfileIndex">Start position of the profiles to copy</param>
        private void AnalyzeBatchData(int profileCount, ref LJV7IF_PROFILE_INFO profileInfo, bool includeTimeData, int[] batchData, int startProfileIndex)
        {
            int offsetTimeSize = (includeTimeData) ? 1 : 0;
            int readPropfileDataSize = ProfileData.CalculateDataSize(profileInfo);
            int readMeasureDataSize = Utility.GetByteSize(Utility.TypeOfStruct.MEASURE_DATA) * (int)NativeMethods.MeasurementDataCount;
            int dataUnit = offsetTimeSize + readPropfileDataSize + readMeasureDataSize / Marshal.SizeOf(typeof(int));
            int[] tempRecvieProfileData = new int[readPropfileDataSize];
            byte[] tempRecvieMeasureData = new byte[readMeasureDataSize];
            uint offestTime = 0;

            // Profile data retention
            for (int i = 0; i < profileCount; i++)
            {
                if (includeTimeData)
                {
                    offestTime = (uint)batchData[startProfileIndex + i * dataUnit];
                }
                Array.Copy(batchData, (startProfileIndex + i * dataUnit + offsetTimeSize), tempRecvieProfileData, 0, readPropfileDataSize);
                _deviceData[_currentDeviceId].ProfileData.Add(new ProfileData(tempRecvieProfileData, profileInfo));

                Buffer.BlockCopy(batchData, (startProfileIndex + i * dataUnit + offsetTimeSize + readPropfileDataSize) * Marshal.SizeOf(typeof(int)),
                    tempRecvieMeasureData, 0, readMeasureDataSize);
                _deviceData[_currentDeviceId].MeasureData.Add(new MeasureData(tempRecvieMeasureData));
                if (includeTimeData)
                {
                    _deviceData[_currentDeviceId].MeasureData[i].OffsetTime = offestTime;
                }
            }
        }
        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);
Exemple #17
0
 /// <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 AnalyzeProfileData(int profileCount, ref LJV7IF_PROFILE_INFO profileInfo, int[] profileData)
 {
     int dataUnit = ProfileData.CalculateDataSize(profileInfo);
     AnalyzeProfileData(profileCount, ref profileInfo, profileData, 0, dataUnit);
 }
        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);
Exemple #19
0
        /// <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 AnalyzeProfileData(int profileCount, ref LJV7IF_PROFILE_INFO profileInfo, int[] profileData, int startProfileIndex, int dataUnit)
        {
            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[_currentDeviceId].ProfileData.Add(new ProfileData(tempRecvieProfileData, profileInfo));
            }
        }
        internal static extern int LJV7IF_PreStartHighSpeedDataCommunication(
		int lDeviceId, ref LJV7IF_HIGH_SPEED_PRE_START_REQ pReq,
		ref LJV7IF_PROFILE_INFO pProfileInfo);
Exemple #21
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_PROFILE_INFO profileInfo)
        {
            StringBuilder sb = new StringBuilder();

            // Profile information of the profile obtained
            sb.AppendLine(string.Format(@"  Profile Data Num			: {0}", profileInfo.byProfileCnt));
            string envelope = profileInfo.byEnvelope == 0
                ? @"OFF"
                : @"ON";
            sb.AppendLine(string.Format(@"  Envelope			: {0}", envelope));
            sb.AppendLine(string.Format(@"  Profile Data Points			: {0}", profileInfo.wProfDataCnt));
            sb.AppendLine(string.Format(@"  X coordinate of the first point	: {0}", profileInfo.lXStart));
                sb.Append(string.Format(@"  X-direction interval		: {0}", profileInfo.lXPitch));

            return sb;
        }