private void PeripheralCtrl_Load(object sender, EventArgs e)
        {
            UInt16 LastErrCode;

            byte[] byLibVersion = new byte[PeripheralCtrl_API.IMC_LIB_VERSION_SIZE];
            LastErrCode = PeripheralCtrl_API.PeripheralCtrl_GetLibVersion(byLibVersion);
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to get library version");
                return;
            }
            int nRealSize;

            StaticLibVersionValue.Text = ConvertByte2String(byLibVersion, byLibVersion.Length, out nRealSize);

            // Initialize the Peripheral Control library.
            LastErrCode = PeripheralCtrl_API.PeripheralCtrl_Initialize();
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to start up the PeripheralCtrl library");
                return;
            }

            for (int i = 0; i < (int)PeripheralCtrl_API.PERIPHERAL_TYPE.PERIPHERAL_SIZE; i++)
            {
                ComboPeripheralCtrl.Items.Add(peripheralCtrlItemTable[i].name);
            }

            ComboPeripheralCtrl.SelectedIndex = 0;
            ComboPeripheralCtrlValue.Items.Add(strPeripheralCtrlValue[0]);
            ComboPeripheralCtrlValue.Items.Add(strPeripheralCtrlValue[1]);
            ComboPeripheralCtrlValue.SelectedIndex = 0;
        }
        // Set/Get Peripheral control
        bool AccessPeripheralCtrl(bool bSet)
        {
            UInt16 LastErrCode;

            PeripheralCtrl_API.PERIPHERAL_TYPE nType = peripheralCtrlItemTable[ComboPeripheralCtrl.SelectedIndex].index;
            int nEnable;

            if (bSet)
            {
                nEnable     = ComboPeripheralCtrlValue.SelectedIndex;
                LastErrCode = PeripheralCtrl_API.PeripheralCtrl_SetPeripheralControl(nType, nEnable);
                if (LastErrCode != IMC_ERR_NO_ERROR)
                {
                    MessageBox.Show("Fails to set peripheral control");
                    return(false);
                }
            }
            else
            {
                LastErrCode = PeripheralCtrl_API.PeripheralCtrl_GetPeripheralControl(nType, out nEnable);

                if (LastErrCode != IMC_ERR_NO_ERROR)
                {
                    MessageBox.Show("Fails to get peripheral control");
                    return(false);
                }
                ComboPeripheralCtrlValue.SelectedIndex = (nEnable == 1? 1:0);
            }
            return(true);
        }
Exemplo n.º 3
0
        public void SetRearViewSource(byte source)
        {
            if (curr_rearview_src == source)
            {
                return;
            }

            UInt16 LastErrCode;

            LastErrCode = PeripheralCtrl_API.PeripheralCtrl_SetRearViewSource(source);
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to switch to desktop" + LastErrCode.ToString("X4"));
                return;
            }

            curr_rearview_src = source;

            if (curr_rearview_src == PeripheralCtrl_API.REAR_VIEW_SRC_SYSTEM)
            {
                btnMainSrc.Enabled = false;
                btnExtSrc.Enabled  = true;
            }
            else
            {
                btnMainSrc.Enabled = true;
                btnExtSrc.Enabled  = false;
            }
        }
Exemplo n.º 4
0
        private void RearViewForm_Load(object sender, EventArgs e)
        {
            UInt16 LastErrCode;

            byte[] byLibVersion = new byte[PeripheralCtrl_API.IMC_LIB_VERSION_SIZE];
            LastErrCode = PeripheralCtrl_API.PeripheralCtrl_GetLibVersion(byLibVersion);
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to get library version " + LastErrCode.ToString("X4"));
                return;
            }

            tbLibVersion.Text = System.Text.Encoding.Default.GetString(byLibVersion);

            // Initialize the Peripheral Control library.
            LastErrCode = PeripheralCtrl_API.PeripheralCtrl_Initialize();
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to start up the PeripheralCtrl library " + LastErrCode.ToString("X4"));
                return;
            }

            byte curr_source;

            LastErrCode = PeripheralCtrl_API.PeripheralCtrl_GetRearViewSource(out curr_source);
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to get RearView Source " + LastErrCode.ToString("X4"));
                return;
            }

            SetRearViewSource(PeripheralCtrl_API.REAR_VIEW_SRC_SYSTEM);

            cbAutoSwitchTime.SelectedIndex = 0;

            int auto_switch = 0;

            LastErrCode = PeripheralCtrl_API.PeripheralCtrl_GetAutoRearView(out auto_switch);
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to get auto RearView " + LastErrCode.ToString("X4"));
                return;
            }

            if (auto_switch == 0)
            {
                checkBoxAutoSwitchBaseDI.Checked = false;
            }
            else
            {
                checkBoxAutoSwitchBaseDI.Checked = true;
            }

            init_once = true;
        }
        private void PeripheralCtrl_Closed(object sender, EventArgs e)
        {
            UInt16 LastErrCode;

            LastErrCode = PeripheralCtrl_API.PeripheralCtrl_Deinitialize();
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to clear up the peripheral control library");
                return;
            }
        }
Exemplo n.º 6
0
        private void RearViewForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            SetRearViewSource(PeripheralCtrl_API.REAR_VIEW_SRC_SYSTEM);

            UInt16 LastErrCode;

            LastErrCode = PeripheralCtrl_API.PeripheralCtrl_Deinitialize();
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to clear up the peripheral control library");
                return;
            }
        }
Exemplo n.º 7
0
        private void checkBoxAutoSwitchBaseDI_CheckedChanged(object sender, EventArgs e)
        {
            UInt16 LastErrCode;

            if (!init_once)
            {
                return;
            }

            int auto_switch = (checkBoxAutoSwitchBaseDI.Checked ? 1 : 0);

            LastErrCode = PeripheralCtrl_API.PeripheralCtrl_SetAutoRearView(auto_switch);
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to set auto switch " + LastErrCode.ToString("X4"));
                return;
            }
        }