Ejemplo n.º 1
0
        private void toolStripBtnConnect_Click(object sender, EventArgs e)
        {
            string strMessage = DeviceType.ToString() + " Disconnected";
            sdk2Com.AHRS_Enabled = false;
            if (base.DeviceConnected)
            {
                if (TimerGetSamples.Enabled)
                    toolStripBtnStop.PerformClick();
                sdk2Com.Disconnect();
                availableModules = INEMO2_MODULES.INEMO2_MODULES_NONE;
            }
            else if (this.sdk2Com.Connect(base.ConnectionString) != INEMO2_DeviceError.INEMO2_ERROR_NONE)
                strMessage = this.DeviceType.ToString() + "  not recognized on " + base.CommunicationPort;

            base.DeviceConnected = sdk2Com.IsConnected();
            toolStripBtnConnect.Checked = base.DeviceConnected;
            Connect.Checked = base.DeviceConnected;
            Settings.Enabled = !base.DeviceConnected;
            toolStripBtnSensorSetting.Enabled = base.DeviceConnected;
            SensorSetting.Enabled = base.DeviceConnected;
            if (base.DeviceConnected)
            {
                availableModules = INEMO2_MODULES.INEMO2_MODULES_NONE;
                sdk2Com.GetModules(ref availableModules);
                sdk2Com.AHRS_Enabled = ModuleAHRS;
                toolStripBtnStart.Enabled = true;
                toolStripBtnStop.Enabled = false;
                if (base.OnMessageToLog != null)
                {
                    base.OnMessageToLog(DeviceType.ToString() + " Connected @ " + base.CommunicationPort);
                }
                string[] fWOnlyVer = FWOnlyVer;
                dlgSensorSetting.GoodVersion = true;
                try
                {
                    if (fWOnlyVer.Length < 2)
                    {
                        throw new InvalidExpressionException("Invalid Number of version digits");
                    }
                    if (VersionToUint64(Convert.ToUInt16(fWOnlyVer[0]), Convert.ToUInt16(fWOnlyVer[1])) < VersionToUint64(2, 2))
                    {
                        throw new InvalidExpressionException("Invalid version number");
                    }
                }
                catch
                {
                    dlgSensorSetting.GoodVersion = false;
                    MessageBox.Show(DeviceType.ToString() + " device firmware not upgraded!\n\nUpgrade the firmware to the version 2.2.0 or higher to use all application functionalities.", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    if (base.OnMessageToLog != null)
                    {
                        base.OnMessageToLog(DeviceType.ToString() + " device firmware not upgraded!");
                    }
                }
                dlgSensorSetting.HWVersion = HardwareVersion;
                dlgSensorSetting.FWVersion = FirmwareVersion;
                dlgSensorSetting.DevGuid = MCUID;
                dlgSensorSetting.SWVersion = Application.ProductName + " " + Application.ProductVersion;
                dlgSensorSetting.CtrlVersion = Assembly.GetExecutingAssembly().GetName().Name + " " + Assembly.GetExecutingAssembly().GetName().Version.ToString();
                dlgSensorSetting.LoadDeviceDataSettings();
                if (base.OnCommunicationSettings_Change != null)
                {
                    base.OnCommunicationSettings_Change();
                }
                if (dlgCom.EnableServer)
                {
                    m_Server = new TCPServer(dlgCom.IpPort);
                    m_Server.OnMessageToLog = (MessageToLog) Delegate.Combine(m_Server.OnMessageToLog, new MessageToLog(TCPMessage));
                    if (m_Server.StartServer())
                    {
                        TimerUpdateTCPLogMessage.Enabled = true;
                        if (base.OnMessageToLog != null)
                        {
                            base.OnMessageToLog("TCP/IP server for demos @ " + m_Server.ServerInfo + " started");
                        }
                    }
                    else
                    {
                        if (base.OnMessageToLog != null)
                        {
                            base.OnMessageToLog("TCP/IP server for demos @ " + m_Server.ServerInfo + " failed to start");
                        }
                        MessageBox.Show("The demo server failed to start on port " + dlgCom.IpPort + ".\nTry to change the port number on communication settings dialog\nand to connect again to the device.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
            }
            else
            {
                toolStripBtnStart.Enabled = false;
                toolStripBtnStop.Enabled = false;
                if ((m_Server != null) && m_Server.Started)
                {
                    m_Server.StopServer();
                    m_Server = null;
                    TimerUpdateTCPLogMessage.Enabled = false;
                    if (base.OnMessageToLog != null)
                    {
                        base.OnMessageToLog("TCP/IP server for demos stopped");
                    }
                }
                if (base.OnMessageToLog != null)
                {
                    base.OnMessageToLog(strMessage);
                }
            }
            if ((m_Server != null) && m_Server.Started)
            {
                if (base.OnTCPState_Change != null)
                {
                    base.OnTCPState_Change(TCP_State.TCP_STATE_SERVER_START, "TCP/IP Demo server started");
                }
            }
            else if (base.OnTCPState_Change != null)
            {
                base.OnTCPState_Change(TCP_State.TCP_STATE_SERVER_STOP, "TCP/IP Demo server stopped");
            }
        }
Ejemplo n.º 2
0
 public void InitComponent()
 {
     dlgCom = new ComSettings();
     sdk2Com = new INEMO2_Device();
     dlgSensorSetting = new frmSensorSettings(sdk2Com);
     DeviceData = new INEMO2_FrameData();
     toolStripTxtSamples.Text = "1000";
     toolStripTxtSamples.AutoSize = false;
     toolStripTxtSamples.Width = 15;
     TCPMessages = new List<string>();
     m_Server = null;
     dbgTrace = null;
     availableModules = INEMO2_MODULES.INEMO2_MODULES_NONE;
     Settings.Click += new EventHandler(Settings_Click);
     toolStripCmbMode.SelectedIndexChanged += new EventHandler(toolStripCmbMode_SelectedIndexChanged);
     toolStripBtnConnect.Click += new EventHandler(toolStripBtnConnect_Click);
     toolStripBtnSensorSetting.Click += new EventHandler(toolStripBtnSensorSetting_Click);
     toolStripBtnStart.Click += new EventHandler(toolStripBtnStart_Click);
     toolStripBtnStop.Click += new EventHandler(toolStripBtnStop_Click);
     Connect.Click += new EventHandler(toolStripBtnConnect_Click);
     SensorSetting.Click += new EventHandler(toolStripBtnSensorSetting_Click);
     Start.Click += new EventHandler(toolStripBtnStart_Click);
     Stop.Click += new EventHandler(toolStripBtnStop_Click);
     ResetDevice.Click += new EventHandler(ResetDevice_Click);
     Enter_DFU_Mode.Click += new EventHandler(Enter_DFU_Mode_Click);
     Trace.Click += new EventHandler(Trace_Click);
     Identify.Click += new EventHandler(Identify_Click);
     toolStripTxtSamples.TextChanged += new EventHandler(toolStripTxtSamples_TextChanged);
     Samples.Click += new EventHandler(Samples_Click);
     Continous.Click += new EventHandler(Continous_Click);
     dlgSensorSetting.OnMessageToLogSettings = (MessageToLog) Delegate.Combine(dlgSensorSetting.OnMessageToLogSettings, new MessageToLog(MessageToLogFromSetting));
     TimerGetSamples.Interval = 30;
     TimerGetSamples.Enabled = false;
     base.DeviceConnected = false;
     toolStripBtnStart.Enabled = false;
     toolStripBtnStop.Enabled = false;
     toolStripLblNumSamples.Visible = false;
     toolStripBtnSensorSetting.Enabled = false;
     SensorSetting.Enabled = false;
     Start.Enabled = false;
     Stop.Enabled = false;
     toolStripProgressBarAcqSample.Visible = true;
     toolStripCmbMode.SelectedIndex = 1;
     Clear();
 }
Ejemplo n.º 3
0
 public INEMO2_DeviceError GetModules(ref INEMO2_MODULES modules)
 {
     return(INEMO2_GetModules(m_DeviceHandle, ref modules));
 }
Ejemplo n.º 4
0
 private static extern INEMO2_DeviceError INEMO2_GetModules(INEMO2_DeviceHandle hDevHandle, ref INEMO2_MODULES pModules);
Ejemplo n.º 5
0
 public INEMO2_DeviceError GetModules(ref INEMO2_MODULES modules)
 {
     return INEMO2_GetModules(this.m_DeviceHandle, ref modules);
 }
Ejemplo n.º 6
0
 private static extern INEMO2_DeviceError INEMO2_GetModules(INEMO2_DeviceHandle hDevHandle, ref INEMO2_MODULES pModules);