public LGTVControl(string communicationType, RS232Class rs232, RJ45Class rj45, JObject jsonFile, string tvID)
 {
     _comRS232          = rs232;
     _comRJ45           = rj45;
     _communicationType = communicationType;
     _jsonFile          = jsonFile;
     _tvID = tvID;
 }
 public SAMSUNGTVControl(string communicationType, RS232Class rs232, RJ45Class rj45, JObject jsonFile, string tvID)
 {
     _comRS232          = rs232;
     _comRJ45           = rj45;
     _communicationType = communicationType;
     _jsonFile          = jsonFile;
     _tvID = tvID;
     if (_tvID.Length == 1)
     {
         _tvID = "0" + _tvID;
     }
 }
Пример #3
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            string tvModelSelected        = string.Empty;
            string tvSeriesSelected       = string.Empty;
            string tvCommTypeSelected     = string.Empty;
            string tvIDSelected           = string.Empty;
            string tvIDSAMSUNG            = string.Empty;
            string tvIDLG                 = string.Empty;
            string tvIPAddressSelected    = string.Empty;
            string tvEthernetPortSelected = string.Empty;

            string SQLRequest = "SELECT * FROM client";

            DataTable dt = GetData(SQLRequest);

            if (dt.Rows.Count != 0)
            {
                tvModelSelected    = dt.Rows[0]["tvModel"].ToString();
                tvSeriesSelected   = dt.Rows[0]["tvSeries"].ToString();
                tvCommTypeSelected = dt.Rows[0]["commType"].ToString();
                tvIDSelected       = dt.Rows[0]["tvID"].ToString();

                tvIPAddressSelected    = dt.Rows[0]["tvIPAddress"].ToString();
                tvEthernetPortSelected = dt.Rows[0]["tvEthernetPort"].ToString();

                txtTVModel.Text           = tvModelSelected;
                txtTVSeries.Text          = tvSeriesSelected;
                txtTVID.Text              = tvIDSelected;
                txtCommunicationType.Text = tvCommTypeSelected;

                if (tvCommTypeSelected == "RJ45 MDC")
                {
                    txtCom.Text      = "";
                    txtBaudRate.Text = "";
                    txtParity.Text   = "";
                    txtDatabits.Text = "";
                    txtStopbits.Text = "";

                    if (!ValidateIPv4(tvIPAddressSelected))
                    {
                        MessageBox.Show("Invalid IP Address !");
                    }
                    if (!IsPortValid(tvEthernetPortSelected))
                    {
                        MessageBox.Show("Invalid Port number !");
                    }

                    if (ValidateIPv4(tvIPAddressSelected) && IsPortValid(tvEthernetPortSelected))
                    {
                        _rs232Class = null;
                        _rj45Class  = new RJ45Class(tvIPAddressSelected, int.Parse(tvEthernetPortSelected));
                    }
                }
                else
                {
                    string portComSelected  = "COM1";
                    string baudRateSelected = "9600";
                    string paritySelected   = "None";
                    string databitsSelected = "8";
                    string stopbitsSelected = "One";

                    txtCom.Text      = portComSelected;
                    txtBaudRate.Text = baudRateSelected;
                    txtParity.Text   = paritySelected;
                    txtDatabits.Text = databitsSelected;
                    txtStopbits.Text = stopbitsSelected;

                    _rs232Class = new RS232Class(portComSelected, baudRateSelected, paritySelected, databitsSelected, stopbitsSelected);
                    _rj45Class  = null;
                }

                switch (tvModelSelected)
                {
                case "SAMSUNG":
                    _tvControl = new SAMSUNGTVControl(tvCommTypeSelected, _rs232Class, _rj45Class, _jsonFile, tvIDSAMSUNG);
                    break;

                case "LG":
                    _tvControl = new LGTVControl(tvCommTypeSelected, _rs232Class, _rj45Class, _jsonFile, tvIDLG);
                    break;
                }

                _continue         = true;
                btnRunApp.Enabled = true;
            }
        }