private void ReceivedMessage(string msg)
        {
            string[] cmd = msg.ToLower().Split('>');
            switch (cmd[0])
            {
            case "<appc":
                CmmModule.SendData(CommCommands.DATAACQSTATUS);
                LogMessage(msg);
                break;

            case "der":
                LogMessage(msg);
                //"DER>SH:{0}>H:{1}>W{2}>X:{3}>Y:{4}>";
                int showhide = Convert.ToInt32(cmd[1].Split(':')[1]);
                if (showhide == 1)
                {
                    if (!backgroundWorkerStartCamera.IsBusy)
                    {
                        backgroundWorkerStartCamera.RunWorkerAsync(msg);
                    }
                }
                //else if (showhide == 0)
                //{
                //    StopCamera();
                //    this.WindowState = FormWindowState.Minimized;
                //}
                break;

            case "<pic":
                LogMessage(msg);
                //   TakePic();
                this.BeginInvoke(new ReadCommFiledelegate(TakePic));
                break;

            case "oto":
            {
                //"Oto>SH:{0}>H:{1}>W{2}>X:{3}>Y:{4}>";
                showhide = Convert.ToInt32(cmd[1].Split(':')[1]);
                if (showhide == 1)
                {
                    //int height = Convert.ToInt32(cmd[2].Split(':')[1]);
                    //int width = Convert.ToInt32(cmd[3].Split(':')[1]);
                    //int mainscWidht = Convert.ToInt32(cmd[4].Split(':')[1]);
                    //int mainscheight = Convert.ToInt32(cmd[5].Split(':')[1]);
                    //this.Width = mainscWidht / 2;
                    //this.Height = mainscheight - 30;
                    //this.Left = mainscWidht - mainscWidht / 2;
                    //this.Top = 60;
                    //this.TopMost = true;
                    //videoSourcePlayer.Height = tabPage1.Height;
                    //videoSourcePlayer.Width = tabPage1.Width;
                    //this.Location = new Point(mainscWidht - mainscWidht / 2, 70);
                    //this.WindowState = FormWindowState.Normal;
                    //  StartMicorCamera(1);
                    if (!backgroundWorkerStartCamera.IsBusy)
                    {
                        backgroundWorkerStartCamera.RunWorkerAsync(msg);
                    }
                    LogMessage(msg);
                }
                //else if (showhide == 0)
                //{

                //    this.WindowState = FormWindowState.Minimized;
                //}
            }
            break;

            case "<stopdermo":
            case "<stopoto":
                if (!backgroundWorkerStopCamera.IsBusy)
                {
                    backgroundWorkerStopCamera.RunWorkerAsync();
                }
                LogMessage(msg);
                break;

            case "otosaveimage":

                SaveImage(false, cmd[1]);
                break;

            case "dersaveimage":
                SaveImage(true, cmd[1]);
                break;

            case "<startspirofvc":

                this.Invoke(new CallBackDelegatespiro(StartFVC), msg);
                commtoMCC.readData();

                break;

            case "<stopspiro":

                this.Invoke(new CallBackDelegate(Stopspiro));
                commtoMCC.readData();
                break;

            case "<startspirovc":

                this.Invoke(new CallBackDelegatespiro(StartVC), msg);
                commtoMCC.readData();
                break;

            case "connectiontest":

                commtoMCC.SendData("connectedmcc");
                commtoMCC.readData();
                //  commtoMCC.readData();
                break;
            }
            //   CmmModule.readData();
        }
        private void ReceivedMessage(string msg)
        {
            string[] cmd = msg.ToLower().Split('>');
            switch (cmd[0])
            {
            case "<appc":
                CmmModule.SendData(CommCommands.DATAACQSTATUS);
                LogMessage(msg);
                break;

            case "der":
                LogMessage(msg);
                //"DER>SH:{0}>H:{1}>W{2}>X:{3}>Y:{4}>";
                int showhide = Convert.ToInt32(cmd[1].Split(':')[1]);
                if (showhide == 1)
                {
                    if (!backgroundWorkerStartCamera.IsBusy)
                    {
                        backgroundWorkerStartCamera.RunWorkerAsync(msg);
                    }
                }
                break;

            case "<pic":
                LogMessage(msg);
                //   TakePic();
                this.BeginInvoke(new ReadCommFiledelegate(TakePic));
                break;

            case "oto":
            {
                //"Oto>SH:{0}>H:{1}>W{2}>X:{3}>Y:{4}>";
                showhide = Convert.ToInt32(cmd[1].Split(':')[1]);
                if (showhide == 1)
                {
                    if (!backgroundWorkerStartCamera.IsBusy)
                    {
                        backgroundWorkerStartCamera.RunWorkerAsync(msg);
                    }
                    LogMessage(msg);
                }
            }
            break;

            case "<stopdermo":
            case "<stopoto":
                if (!backgroundWorkerStopCamera.IsBusy)
                {
                    backgroundWorkerStopCamera.RunWorkerAsync();
                }
                LogMessage(msg);
                break;

            case "otosaveimage":

                SaveImage(false, cmd[1]);
                break;

            case "dersaveimage":
                SaveImage(true, cmd[1]);
                break;

            case "<startspirofvc":

                this.Invoke(new CallBackDelegatespiro(StartFVC), msg);
                commtoMCC.readData();

                break;

            case "<stopspiro":

                this.Invoke(new CallBackDelegate(Stopspiro));
                commtoMCC.readData();
                break;

            case "<startspirovc":

                this.Invoke(new CallBackDelegatespiro(StartVC), msg);
                commtoMCC.readData();
                break;

            case "connectiontest":

                commtoMCC.SendData("connectedmcc");
                commtoMCC.readData();
                break;

            case "pod":
                if (cmd[2].Equals("d"))
                {
                    _serialDevice.DeployPod(cmd[1]);
                }
                else
                {
                    _serialDevice.RetractPod(cmd[1]);
                }

                commtoMCC.readData();
                break;

            case "seatht":
                _serialDevice.SeatBack(cmd[1]);
                commtoMCC.readData();
                break;

            case "seatrec":
                _serialDevice.Recline(cmd[1]);
                commtoMCC.readData();
                break;

            case "hm":
                _serialDevice.HeightMeasure();
                commtoMCC.readData();
                break;

            case "wm":
                _serialDevice.WeightMeasure();
                commtoMCC.readData();
                break;

            case "stl":
                if (cmd[2].Equals("d"))
                {
                    _serialDevice.DeployStethoscopeLungs(cmd[1]);
                }
                else if (cmd[2].Equals("r"))
                {
                    _serialDevice.RetractStethoscopeLungs(cmd[1]);
                }
                //  _serialDevice.DeployPod(cmd[1]);
                commtoMCC.readData();
                break;

            case "wt":
                _serialDevice.TareWeight();
                commtoMCC.readData();
                break;
            }
        }