コード例 #1
0
ファイル: MainForm.cs プロジェクト: stellant/Profilometer
        /// <summary>
        /// "SetSetting" button clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSetSetting_Click(object sender, EventArgs e)
        {
            using (SettingForm settingForm = new SettingForm(true))
            {
                if (DialogResult.OK == settingForm.ShowDialog())
                {
                    LJV7IF_TARGET_SETTING targetSetting = settingForm.TargetSetting;
                    using (PinnedObject pin = new PinnedObject(settingForm.Data))
                    {
                        uint dwError = 0;
                        int rc = NativeMethods.LJV7IF_SetSetting(_currentDeviceId, settingForm.Depth, targetSetting,
                            pin.Pointer, (uint)settingForm.Data.Length, ref dwError);
                        // @Point
                        // # There are three setting areas: a) the write settings area, b) the running area, and c) the save area.
                        //   * Specify a) for the setting level when you want to change multiple settings. However, to reflect settings in the LJ-V operations, you have to call LJV7IF_ReflectSetting.
                        //	 * Specify b) for the setting level when you want to change one setting but you don't mind if this setting is returned to its value prior to the change when the power is turned off.
                        //	 * Specify c) for the setting level when you want to change one setting and you want this new value to be retained even when the power is turned off.

                        // @Point
                        //  As a usage example, we will show how to use SettingForm to configure settings such that sending a setting, with SettingForm using its initial values,
                        //  will change the sampling period in the running area to "100 Hz."
                        //  Also see the GetSetting function.

                        AddLogResult(rc, Resources.SID_SET_SETTING);
                        if (rc != (int)Rc.Ok)
                        {
                            AddError(dwError);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: stellant/Profilometer
        /// <summary>
        /// "GetSetting" button clicked.
        /// </summary>
        /// <param name="sender"></param>
        private void btnGetSetting_Click(object sender, EventArgs e)
        {
            using (SettingForm settingForm = new SettingForm(false))
            {
                if (DialogResult.OK == settingForm.ShowDialog())
                {
                    LJV7IF_TARGET_SETTING targetSetting = settingForm.TargetSetting;
                    byte[] data = new byte[settingForm.DataLength];
                    using (PinnedObject pin = new PinnedObject(data))
                    {
                        int rc = NativeMethods.LJV7IF_GetSetting(_currentDeviceId, settingForm.Depth, targetSetting,
                            pin.Pointer, (uint)settingForm.DataLength);
                        // @Point
                        //  We have prepared an object for reading the sampling period into the setting's initial value.
                        //  Also see the SetSetting function.

                        AddLogResult(rc, Resources.SID_GET_SETTING);
                        if (rc == (int)Rc.Ok)
                        {
                            AddLog("\t    0  1  2  3  4  5  6  7");
                            StringBuilder sb = new StringBuilder();
                            // Get data display
                            for (int i = 0; i < settingForm.DataLength; i++)
                            {
                                if ((i % 8) == 0) sb.Append(string.Format("  [0x{0:x4}] ", i));

                                sb.Append(string.Format("{0:x2} ", data[i]));
                                if (((i % 8) == 7) || (i == settingForm.DataLength - 1))
                                {
                                    AddLog(sb.ToString());
                                    sb.Remove(0, sb.Length);
                                }
                            }
                        }
                    }
                }
            }
        }