コード例 #1
0
 private void OptoControl_Load(object sender, EventArgs e)
 {
     MySerialPort.Open();
     MySerialPort.WriteLine("125 0 0");
     MySerialPort.Close();
     MyLabelInterval.Text = MyTrackBarInterval.Value.ToString();
 }
コード例 #2
0
        private void Connect()
        {
            this.portname     = txtPortName.Text;
            this.mySerialPort = new MySerialPort(this.portname, getRatio(), this.receivePath);
            this.mySerialPort.messageIsHere   += new MySerialPort.HandlerReceiveMessage(this.messageReceived);
            this.mySerialPort.tramaHire       += new MySerialPort.HandlerNotifyProgress(this.onTramaHire);
            this.mySerialPort.notifyName      += new MySerialPort.HandlerNotifyProgress(this.onFileNameAddToCahtPanel);
            this.mySerialPort.sendingProgress += new MySerialPort.HandlerNotifyProgress(this.upadateProgressOnChatPanel);

            try {
                if (mySerialPort.Connect())
                {
                    this.lblState.Text      = "OnLine " + portname;
                    this.lblState.ForeColor = Color.Green;
                    this.btnConnect.Text    = "Disconnect";
                    this.myInputBox.ComponentesState(true);
                    this.txtPortName.Enabled     = false;
                    this.txtRatioBaudios.Enabled = false;
                    this.txtSetting.Enabled      = false;
                }
                else
                {
                    this.lblState.Text      = "OfLine";
                    this.lblState.ForeColor = Color.Red;
                    this.btnConnect.Text    = "Reconnect";
                    MessageBox.Show(this, "Connect error");
                }
            }catch (Exception err)
            {
                this.lblState.Text      = err.Message;
                this.lblState.ForeColor = Color.Red;
            }
        }
コード例 #3
0
 /// <summary>
 /// 清除任何使用中的資源。
 /// </summary>
 /// <param name="disposing">如果應該處置 Managed 資源則為 true,否則為 false。</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing && (components != null))
     {
         components.Dispose();
     }
     MySerialPort.Dispose();
     base.Dispose(disposing);
 }
コード例 #4
0
ファイル: SeriaProtocol.cs プロジェクト: liyahui520/LIS
 public bool Close()
 {
     if (Serial != null)
     {
         Serial.Close();
         Serial.Dispose();
         Serial = null;
     }
     return(true);
 }
コード例 #5
0
 public CaseProtocolExecutionForCom(myConnectForCom yourConnectInfo)
 {
     isConnect             = false;
     myExecutionDeviceInfo = yourConnectInfo;
     mySerialPort          = new MySerialPort(false);
     mySerialPort.PortName = yourConnectInfo.portName;
     mySerialPort.BaudRate = yourConnectInfo.baudRate;
     mySerialPort.DataBits = yourConnectInfo.dataBits;
     mySerialPort.StopBits = yourConnectInfo.stopBits;
     mySerialPort.Parity   = yourConnectInfo.parity;
     mySerialPort.Encoding = yourConnectInfo.encoding;
 }
コード例 #6
0
    /// <summary>
    /// 关闭串口
    /// </summary>
    public void SerialStop()
    {
        CancelInvoke("ReadMessage");

        if (myserial == null)
        {
            return;
        }

        myserial.Close();
        myserial = null;

        Debug.LogError("串口关闭成功");
    }
コード例 #7
0
        public MyCommunicate( )
        {
            this._mySerialPortCom = new MySerialPort();                                                                                    // 串口的对象
            this._mySerialPortCom.DataReceived             += new DataReceivedEventHandler(ReceiveDataHandler);                            // 接收数据的处理
            this._mySerialPortCom.UpdateLogContent         += new UpdateLogContentEventHandler(WriteLogHandler);                           // 串口写日志
            this._mySerialPortCom.UpdateSerialPortIsOpened += new UpdateSerialPortIsOpenedEventHandler(UpdateSerialPortIsOpenedHandler);   // 更新串口通断状态信息

            /// TCP通信
            //this._mySocketCom = new MySocketCom();                                                                                          // socket通信的对象
            //this._mySocketCom.UpdateLogContent += new UpdateLogContentEventHandler(WriteLogHandler);                                        // socket写日志
            //this._mySocketCom.DataReceived += new DataReceivedEventHandler(ReceiveDataHandler);                                             // 接收数据的处理
            //this._mySocketCom.UpdateSocketIsConnected += new UpdateSocketIsConnectedEventHandler(UpdateSocketIsConnectedHandler);           // 更新socket通断的状态信息

            /// UDP通信
            this._mySocketCom = new MyUDPCom();                                                                                          // socket通信的对象
            this._mySocketCom.UpdateLogContent        += new UpdateLogContentEventHandler(WriteLogHandler);                              // socket写日志
            this._mySocketCom.DataReceived            += new DataReceivedEventHandler(ReceiveDataHandler);                               // 接收数据的处理
            this._mySocketCom.UpdateSocketIsConnected += new UpdateSocketIsConnectedEventHandler(UpdateSocketIsConnectedHandler);        // 更新socket通断的状态信息
        }
コード例 #8
0
ファイル: SeriaProtocol.cs プロジェクト: liyahui520/LIS
 public bool Start()
 {
     if (Serial == null)
     {
         SerialPortConfig serialPortConfig = bc2800Config.SerialPortConfig;
         Serial          = new MySerialPort(serialPortConfig.PortName, serialPortConfig.Baud, serialPortConfig.Parity, serialPortConfig.DataBits, serialPortConfig.StopBits);
         Serial.Encoding = Encoding.GetEncoding(serialPortConfig.EncodingName);
         Serial.SerialDataReceivedCompleteEventHandler += Serial_SerialDataReceivedCompleteEventHandler;
         Serial.DtrEnable = true;
         Serial.RtsEnable = true;
     }
     if (!Serial.IsOpen)
     {
         if (!Serial.Open())
         {
             this.Error = Serial.Erroe;
             return(false);
         }
     }
     return(true);
 }
コード例 #9
0
        /// <summary>
        /// Test Solenoid procedure
        /// </summary>
        /// <returns></returns>
        private async Task <int> TestSolenoid()
        {
            for (int j = 0; j < 15; j++)
            {
                MessageFromUnit = "";
                MySerialPort.DiscardInBuffer();
                MySerialPort.WriteLine(DeviceCommand.HCM_TEST_SOLENOID);
                await DelayTime(500);

                MessageFromUnit = MySerialPort.ReadExisting();
                if (MessageFromUnit.Contains("HT-TESTS,180"))
                {
                    Solenoid        = true;
                    MessageFromUnit = MessageFromUnit.RemoveLineBreaks();
                    string[] temp = MessageFromUnit.Split(',');
                    SolenoidResult = Convert.ToInt32(temp[3]);
                    break;
                }
            }

            return(SolenoidResult);
        }
コード例 #10
0
    public AnimationController AC;//配置控制器
    public void SerialStart()
    {
        if (myserial != null)
        {
            Debug.LogError("请先关闭串口");
            return;
        }

        if (!this.comName.text.Trim().StartsWith("Com"))
        {
            Debug.LogError("请设置串口名称");
            return;
        }

        if (this.comRate.text.Trim() == "")
        {
            Debug.LogError("请设置串口波特率");
            return;
        }

        int rateValue = 0;

        Int32.TryParse(this.comRate.text.Trim(), out rateValue);
        if (rateValue == 0)
        {
            Debug.LogError("串口波特率设置错误");
            return;
        }

        myserial = new MySerialPort(this.comName.text.Trim(), rateValue, Parity.None, StopBits.None);
        myserial.Open();

        Debug.LogError("串口启动成功");

        InvokeRepeating("ReadMessage", 0.5f, 0.5f);
    }
コード例 #11
0
 // Use this for initialization
 void Start()
 {
     myserial = new MySerialPort("COM24", 115200, Parity.Mark, StopBits.One);
     myserial.Open();
 }
コード例 #12
0
 /// <summary>
 /// Reset items once we disconnect
 /// </summary>
 public void Disconnect()
 {
     MySerialPort.Close();
     HCM           = new Device();
     EnableButtons = true;
 }
コード例 #13
0
        /// <summary>
        /// Get the information from the device once it is connected
        /// </summary>
        public async void Connect()
        {
            HCM = new Device();

            for (int j = 0; j < 15; j++)
            {
                MessageFromUnit = "";
                MySerialPort.DiscardInBuffer();
                MySerialPort.WriteLine(DeviceCommand.DEVICE_INFORMATION);
                await DelayTime(200);

                MessageFromUnit = MySerialPort.ReadExisting();
                string[] temp = MessageFromUnit.Split(',');
                if (temp.Length >= 6)
                {
                    if (MessageFromUnit.Contains("HT-DEVIC,001,HCM001"))
                    {
                        if (temp[3].Length == 9)
                        {
                            temp[3] = temp[3].Substring(1, 8);
                        }
                        HCM.SerialNumber     = temp[3];
                        HCM.RegistrationDate = RegistrationDate.GetRegistrationDate(temp[3]);
                        HCM.HardwareVersion  = temp[4];
                        HCM.FirmwareVersion  = temp[5].RemoveLineBreaks();
                        EnableButtons        = false;
                        break;
                    }
                }
            }


            if (!EnableButtons)
            {
                for (int j = 0; j < 5; j++)
                {
                    MySerialPort.DiscardInBuffer();
                    MySerialPort.DiscardOutBuffer();
                    MySerialPort.WriteLine(DeviceCommand.HCM_DATA_MODE);
                    await DelayTime(200);

                    MessageFromUnit = MySerialPort.ReadExisting();
                    if (MessageFromUnit.Contains("HT-CALIB,001"))
                    {
                        break;
                    }
                }

                for (int j = 0; j < 5; j++)
                {
                    MessageFromUnit = "";
                    MySerialPort.DiscardInBuffer();
                    MySerialPort.WriteLine("HT-DEVIC,060");
                    await DelayTime(200);

                    MessageFromUnit = MySerialPort.ReadExisting();
                    if (MessageFromUnit.Contains("HT-DEVIC,060"))
                    {
                        string[] temp = MessageFromUnit.Split(',');
                        HCM.MACAddress = (temp[2]).RemoveLineBreaks();
                        break;
                    }
                }

                for (int j = 0; j < 5; j++)
                {
                    MessageFromUnit = "";
                    MySerialPort.DiscardInBuffer();
                    MySerialPort.WriteLine("HT-DEVIC,056");
                    await DelayTime(200);

                    MessageFromUnit = MySerialPort.ReadExisting();
                    if (MessageFromUnit.Contains("HT-DEVIC,056"))
                    {
                        string[] temp = MessageFromUnit.Split(',');
                        temp[3]       = temp[3].RemoveLineBreaks();
                        HCM.BuildDate = temp[2] + " - " + temp[3];
                        break;
                    }
                }

                for (int j = 0; j < 5; j++)
                {
                    MessageFromUnit = "";
                    MySerialPort.DiscardInBuffer();
                    MySerialPort.WriteLine(DeviceCommand.HCM_GET_LAST_CALIBRATED_DATE);
                    await DelayTime(200);

                    MessageFromUnit = MySerialPort.ReadExisting();
                    if (MessageFromUnit.Contains("HT-CALIB,007"))
                    {
                        string[] temp = MessageFromUnit.Split(',');
                        HCM.LastCalibratedDate = temp[4] + "/" + temp[5] + "/20" + temp[3];
                        break;
                    }
                }

                for (int j = 0; j < 5; j++)
                {
                    MessageFromUnit = "";
                    MySerialPort.DiscardInBuffer();
                    MySerialPort.WriteLine(DeviceCommand.HCM_GET_NEXT_CALIBRATION_DATE);
                    await DelayTime(200);

                    MessageFromUnit = MySerialPort.ReadExisting();
                    if (MessageFromUnit.Contains("HT-CALIB,007"))
                    {
                        string[] temp = MessageFromUnit.Split(',');
                        HCM.NextCalibrationDate = temp[4] + "/" + temp[5] + "/20" + temp[3];
                        break;
                    }
                }

                HCM.BootloaderVersion = "1400";

                DisplayMessage("Completed", MessageTypeEnum.Info);
            }
            else
            {
                DisplayMessage("Cannot set device into data mode", MessageTypeEnum.Critical);
            }
        }
コード例 #14
0
ファイル: TEST.cs プロジェクト: lulianqi/AutoTest
        private void TEST_Load(object sender, EventArgs e)
        {
            //string filePath = @"C:\Users\administer\Desktop\asd\encode";

            //Stream myStm = CsvFileHelper.OpenFile(@"C:\Users\administer\Desktop\encode");
            //Stream myStm1 = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite);
            //Stream myStm2= new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);

            StreamReader myCsvRd    = new StreamReader(@"C:\Users\administer\Desktop\encode", Encoding.Unicode);
            string       tempReader = myCsvRd.ReadLine();

            myCsvRd.Dispose();
            StreamWriter myCsvSw = new StreamWriter(@"C:\Users\administer\Desktop\encode", false, Encoding.Unicode);

            myCsvSw.Write("abc𪚥");
            myCsvSw.Dispose();


            CsvFileHelper myCsv = new CsvFileHelper(@"C:\Users\administer\Desktop\my8.csv", Encoding.UTF8);
            var           xxxx  = myCsv.GetListCsvData();

            myCsv.Dispose();

            //CsvFileHelper.SaveCsvFile(@"C:\Users\administer\Desktop\my6.csv", xxxx, true, new System.Text.UTF8Encoding(false));

            //CsvFileHelper.SaveCsvFile(@"C:\Users\administer\Desktop\my6.csv", xxxx);
            CsvFileHelper.SaveCsvFile(@"C:\Users\administer\Desktop\my8.csv", xxxx);
            CsvFileHelper.SaveCsvFile(@"C:\Users\administer\Desktop\my9.csv", xxxx, true, new System.Text.UTF8Encoding(false));

            //MessageBox.Show(CsvFileHelper.name);

            for (int i = 0; i < 10; i++)
            {
                ListViewItem tempLv     = new ListViewItem(new string[] { "11", "22", "33" });
                Button       tempButton = new Button();
                tempButton.Text = "test";
                //tempButton.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
                //tempButton.FlatStyle = FlatStyle.Flat;
                tempLv.Tag = tempButton;
                listViewWithButton1.AddItemEx(tempLv);
            }
            listViewWithButton1.ButtonClickEvent += new EventHandler((ag1, ag2) => { MessageBox.Show((ag1 as ListViewItem).Index.ToString()); });

            //AT_RemoteRunnerLoad();
            //AT_RemoteRunnerLoad();
            //AT_RemoteRunnerLoad();
            //AT_RemoteRunnerLoad();

            string xxxxx = null;

            xxxxx = xxxxx.MyAddValue("cnm");
            xxxxx = xxxxx.MyAddValue("cnm2");
            xxxxx = xxxxx.MyAddValue("cnm3");
            xxxxx = xxxxx.MyAddValue("cn44m");
            return;

            System.Diagnostics.Stopwatch myWatch = new System.Diagnostics.Stopwatch();

            threadTest2();

            int mt = 0xffff;

            for (int i = 0; i < 32; i++)
            {
                mt = mt >> 1;
            }



            List <string> myRandom = new List <string>();

            myWatch.Start();
            Thread.Sleep(5);
            myWatch.Stop();
            MessageBox.Show("time:" + myWatch.ElapsedMilliseconds + "*" + myWatch.Elapsed);
            for (int i = 0; i < 100; i++)
            {
                myRandom.Add(MyCommonTool.GenerateRandomStr(30, 10));
            }
            for (int i = 0; i < 100; i++)
            {
                myRandom.Add(MyCommonTool.GenerateRandomStr(30, 1));
            }
            for (int i = 0; i < 100; i++)
            {
                myRandom.Add(MyCommonTool.GenerateRandomStr(30, 2));
            }
            for (int i = 0; i < 100; i++)
            {
                myRandom.Add(MyCommonTool.GenerateRandomStr(30, 3));
            }
            for (int i = 0; i < 100; i++)
            {
                myRandom.Add(MyCommonTool.GenerateRandomStr(30, 4));
            }

            threadTest3();
            //return;

            myWatch.Start();
            var y = 0;
            var x = 10;

            while (y < x)
            {
                y = y + 1;
            }

            myWatch.Stop();
            MessageBox.Show("time:" + myWatch.ElapsedMilliseconds + "*" + myWatch.Elapsed);

            ////测试方法重写后,强制调用父类方法
            //cc kk = new ccc();
            //MessageBox.Show(" "+kk.getI());

            ////测试堆栈数据(class struck)
            //cc myCc = new cc();
            //cc myCc1 = new cc();
            //cc myCc2 = new cc();
            //ss mySs1 = new ss(myCc);
            //ss mySs2 = new ss(myCc);
            //ss mySs3 = mySs1;
            //object mySs4 = new ss(myCc);
            //var mySs5 = new ss(myCc);
            //ss mySs6 = mySs5;
            //cs myCs1 = new cs();
            //ss cnm = myCs1.ms;
            //cnm.i = 3456;
            //myCc.i = 9;
            //myCc.str = "cm";
            //mySs1.i = 19;
            //mySs1.str = "sNM";
            //mySs1.sc.i = 7;
            //mySs1.sc.str = "cnm";
            //mySs3.sc.i = 77;
            //mySs1.sc.str = "cnmcnm";
            //myTest1(mySs1);
            //myTest1(mySs3);
            //myTest1(myCs1.ms);
            //myTest1(ref myCs1.ms);
            //myTest2(mySs1);
            //myTest2(mySs3);
            //myTest2(myCs1.ms);

            //var tempTest3 = myTest3();
            //MessageBox.Show(tempTest3.strs[0]);


            ////测试CPU时间片
            //threadTest();


            string tempStr   = null;
            bool   stempBool = true;

            myWatch.Start();
            for (int i = 0; i < 1000; i++)
            {
                if (stempBool == true)
                {
                    continue;
                }
            }
            myWatch.Stop();
            MessageBox.Show("time:" + myWatch.ElapsedMilliseconds + "*" + myWatch.Elapsed);

            ////测试拆装性能
            //myWatch.Reset();
            //myWatch.Start();
            //for (int i = 0; i < 10000; i++)
            //{
            //    object myObj = myCc;
            //}
            //myWatch.Stop();
            //MessageBox.Show("time:" + myWatch.ElapsedMilliseconds + "*" + myWatch.Elapsed);

            //object Obj = myCc;
            //myWatch.Reset();
            //myWatch.Start();
            //for (int i = 0; i < 10000; i++)
            //{
            //    cc nowCc = (cc)Obj;
            //}
            //myWatch.Stop();
            //MessageBox.Show("time:" + myWatch.ElapsedMilliseconds + "*" + myWatch.Elapsed);

            //var x =(CaseAction)Enum.Parse(typeof(CaseAction), "Goto");
            //var x = CaseAction.Alarm;
            //string cc = null;
            mySP          = new MySerialPort(true);
            mySP.Encoding = System.Text.Encoding.GetEncoding("utf-8");
            mySP.OnMySerialPortReceiveData += new MySerialPort.delegateReceiveData(mySP_OnMySerialPortReceiveData);
            mySP.OnMySerialPortThrowError  += new MySerialPort.delegateThrowError(mySP_OnMySerialPortThrowError);
        }
コード例 #15
0
        public static void Main()
        {
            try
            {
                mcp23017            = new MCP23017();     //the MCP is what allows us to talk with the RGB LCD panel. I need it in this class so I can read the button presses from the User...
                mMenu               = new Menu(mcp23017); //Configure this one first so that errors can be written to the LCD Shield
                mMenu.MenuSelection = MenuSelection.PrintLabel;

                //Setup the interrupt port for button presses from the LCD Shield.
                //Here I have the Interrupt pin from the LCD Shield (configured in the MCP23017 class) going to the Netduino Digital Pin 5
                btnShield = new InterruptPort(Pins.GPIO_PIN_D5, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);
                // Bind the interrupt handler to the pin's interrupt event.
                btnShield.OnInterrupt += new NativeEventHandler(btnShield_OnInterrupt);

                //Configure the MUX which allows me to expand my serial ports. Here I am using digital pins 9 thru 10 to send the necessary signals to switch my MUX channels
                OutputPort DigitalPin9  = new OutputPort(Pins.GPIO_PIN_D9, false);  //Goes to S0
                OutputPort DigitalPin10 = new OutputPort(Pins.GPIO_PIN_D10, false); //Goes to S1
                OutputPort DigitalPin11 = new OutputPort(Pins.GPIO_PIN_D11, false); //Goes to S2
                OutputPort DigitalPin12 = new OutputPort(Pins.GPIO_PIN_D12, false); //Goes to S3
                Mux = new CD74HC4067(DigitalPin9, DigitalPin10, DigitalPin11, DigitalPin12);
                Mux.SetPort(MuxChannel.C0);                                         //default it to C0 which is data coming in from the Indicators Serial Port

                Settings                    = new Settings();
                Settings.Increments         = new double[] { .001, .01, .1, 1, 10, 100 };
                Settings.IncrementSelection = 3;
                Settings.RetrieveSettingsFromSDCard(WORKINGDIRECTORY, "LabelFormat.txt", "Job.txt", "Operation.txt", "ShopTrakTransactionsURL.txt",
                                                    "PieceWeight.txt", "NetWeightAdjustment.txt", "BackgroundColor.txt");

                mMenu.SetBackLightColor(Settings.BacklightColor);

                // initialize the serial port for data being input via COM1
                mIndicatorScannerSerialPort = new MySerialPort(SerialPorts.COM1, BaudRate.Baudrate9600, Parity.None, DataBits.Eight, StopBits.One);
                // initialize the serial port for data being output via COM3
                mPrinterSerialPort = new MySerialPort(SerialPorts.COM3, BaudRate.Baudrate9600, Parity.None, DataBits.Eight, StopBits.One);
                // open the serial-ports, so we can send & receive data
                mIndicatorScannerSerialPort.Open();
                mPrinterSerialPort.Open();
                // add an event-handler for handling incoming data
                mIndicatorScannerSerialPort.DataReceived += new SerialDataReceivedEventHandler(IndicatorScannerSerialPort_DataReceived);


                //Setup the Onboard button; InterruptEdgeLevelLow only fires the event the first time that the button descends
                btnBoard = new InterruptPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
                // Create an event handler for the button
                btnBoard.OnInterrupt += new NativeEventHandler(btnBoard_OnInterrupt);

                // write your code here
                var webServer = new WebServer();
                webServer.AddRequestFilter(new RequestFilter());
                var fileAndDirectoryService = new FileAndDirectoryService();
                fileAndDirectoryService.SetSDCardManager(new SDCardManager(WORKINGDIRECTORY));
                webServer.SetFileAndDirectoryService(fileAndDirectoryService);
                /*Setting a default controller removes the ability to browse the files and folder of the root web directory*/
                //webServer.RouteTable.DefaultControllerName = "Scale";
                webServer.StartServer(80);//If port is not specified, then default is port 8500
                webServer.SetHostName("Cart Scale");

                //Display appropriate information to the user...
                mMenu.DisplayInformation(Settings);
            }
            catch (Exception objEx)
            {
                Debug.Print("Exception caught in Main()\r\n");
                Debug.Print(objEx.Message);
                mMenu.DisplayError(objEx);
            }

            //We are done. The thread must sleep or else the netduino turns off...
            Thread.Sleep(Timeout.Infinite);
        }
コード例 #16
0
        /**
         * Retrieves a serial port connection interface for the provided port with
         * the given serial port parameters.
         *
         * @param port Serial port name.
         * @param serialPortParameters Serial port parameters.
         *
         * @return The serial port connection interface.
         *
         * @throws ArgumentNullException if {@code port == null} or
         *                              if {@code serialPortParameters == null}.
         *
         * @see #createConnectiontionInterface(String, int)
         * @see com.digi.xbee.api.connection.IConnectionInterface
         * @see com.digi.xbee.api.connection.serial.SerialPortParameters
         */
        public static IConnectionInterface CreateConnectiontionInterface(string port, SerialPortParameters serialPortParameters)
        {
            IConnectionInterface connectionInterface = new MySerialPort(port, serialPortParameters);

            return(connectionInterface);
        }
コード例 #17
0
        /**
         * Retrieves a serial port connection interface for the provided port with
         * the given baud rate.
         *
         * @param port Serial port name.
         * @param baudRate Serial port baud rate.
         *
         * @return The serial port connection interface.
         *
         * @throws ArgumentNullException if {@code port == null}.
         *
         * @see #createConnectiontionInterface(String, SerialPortParameters)
         * @see com.digi.xbee.api.connection.IConnectionInterface
         */
        public static IConnectionInterface CreateConnectiontionInterface(string port, int baudRate)
        {
            IConnectionInterface connectionInterface = new MySerialPort(port, baudRate);

            return(connectionInterface);
        }
コード例 #18
0
 public void MySerialWriteLine()
 {
     MySerialPort.Open();
     MySerialPort.WriteLine(MyTrackBarInterval.Value.ToString() + " " + Convert.ToInt16(direction).ToString() + " " + Convert.ToInt16(enabled).ToString());
     MySerialPort.Close();
 }
コード例 #19
0
 /// <summary>
 /// Resets unit on current port
 /// </summary>
 public void Reset()
 {
     MySerialPort.WriteLine("HT-DEVIC,010");
     EnableButtons = true;
 }
コード例 #20
0
 /// <summary>
 /// 关闭所有变量,使它们都invalidition
 /// </summary>
 private void CloseAllVariable( )
 {
     this._mySerialPortCom       = null;
     this._mySocketCom           = null;
     this._bolFlagCommunicateWay = false;
 }