コード例 #1
0
 private void btnBegin_Click(object sender, EventArgs e)
 {
     if (btnBegin.Text == "开始")
     {
         if (btnSerial.Text != "打开串口" || btnListen.Text != "开始监听")
         {
             Counter = int.Parse(Tim.Text) / 100;
             if (Counter < 1)
             {
                 Info     = "时间间隔过小";
                 Tim.Text = "1000";
                 Counter  = 10;
             }
             SendTimer.Start(); //开启定时器
             btnBegin.Text = "停止";
         }
         else
         {
             Info = "端口未打开!";
         }
     }
     else
     {
         SendTimer.Stop(); //停止定时器
         btnBegin.Text = "开始";
     }
 }
コード例 #2
0
        private void Open_Btn_Click(object sender, EventArgs e)
        {
            serialPort1.PortName = comboBox1.Text.Trim();
            serialPort1.BaudRate = Convert.ToInt32(textBox1.Text.Trim());

            serialPort1.Open();
            SendTimer.Start();
        }
コード例 #3
0
 private void Start()
 {
     try
     {
         deviceClient = DeviceClient.Create(Properties.AzureSettings.Default.Host,
                                            new DeviceAuthenticationWithRegistrySymmetricKey(Properties.AzureSettings.Default.DeviceId,
                                                                                             Properties.AzureSettings.Default.AccessKey), TransportType.Mqtt);
     }
     catch { ErrorText = "Error: Can't create cloud client"; }
     SendTimer.Start();
     CloudButtonContent = "Stop";
 }
コード例 #4
0
        private void SendTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            Interlocked.Increment(ref _currentIndex);

            if (_currentIndex <= Tasks.Count)
            {
                Tasks[_currentIndex].Start();

                ProgressAction(_currentIndex, TotalNumberOfTasks);
            }
            else
            {
                SendTimer.Stop();
            }
        }
コード例 #5
0
ファイル: Client.cs プロジェクト: Dhoine/WeatherBotClient
        private void Client_Load(object sender, EventArgs e)
        {
            var items = new MenuItem[1];

            ReadCaps();
            items[0] = new MenuItem("Exit", ExitHandler);
            backgroundNotifyIcon.ContextMenu = new ContextMenu(items);
            backgroundNotifyIcon.Visible     = true;
            ConnectionTimer.Interval         = 2000;
            ConnectionTimer.Start();
            SendTimer.Interval      = 60000;
            GuiUpdateTimer.Interval = 5000;
            GuiUpdateTimer.Start();
            SendTimer.Start();
        }
コード例 #6
0
        private void SendMessage()
        {
            IsAutoMessage    = Auto_SendMessage.Checked;
            Protocol_Context = SendTextBox.Text.Trim();
            Send_Protocol();

            if (IsAutoMessage)
            {
                SendTimer.Start();
            }
            else
            {
                serialPort.Write(Sendbytes, 0, 8);
            }
        }
コード例 #7
0
        private void Start()
        {
            try
            {
                ErrorText = "";
                X509Certificate  CaCert     = X509Certificate.CreateFromCertFile(Properties.AmazonSettings.Default.RootCA);
                X509Certificate2 ClientCert = new X509Certificate2(Properties.AmazonSettings.Default.DeviceCA, Properties.AmazonSettings.Default.DeviceCAPassword);
                string           ClientId   = Guid.NewGuid().ToString();

                IotClient = new MqttClient(Properties.AmazonSettings.Default.IotEndpoint, 8883, true, CaCert, ClientCert, MqttSslProtocols.TLSv1_2);

                IotClient.Connect(ClientId);
                SendTimer.Start();
                CloudButtonContent = "Stop";
            }
            catch (Exception ex) { ErrorText = "Error: Can't create cloud client"; }
        }
コード例 #8
0
        private void SendTimer_Tick(object sender, EventArgs e)
        {
            SendTimer.Stop();

            try
            {
                string[] SendMessageContent = SendProtocol.Split(' ');
                for (int i = 0; i < 8; i++)
                {
                    SendByte[i] = Convert.ToByte(SendMessageContent[i], 16);
                }
                serialPort1.Write(SendByte, 0, SendByte.Length);
            }
            catch (Exception ex)
            {
                MessageBox.Show("发送错误");
            }
            SendTimer.Start();
        }
コード例 #9
0
 private void Start()
 {
     try
     {
         Capturer                = new WasapiLoopbackCapture();
         TargetFormat            = new WaveFormat(16000, 8, 1);
         SendTimer               = Stopwatch.StartNew();
         Capturer.DataAvailable += (aud, args) =>
         {
             try
             {
                 if (args.BytesRecorded > 0)
                 {
                     lock (TempBuffer)
                     {
                         if (!SendTimer.IsRunning)
                         {
                             SendTimer.Restart();
                         }
                         TempBuffer.AddRange(args.Buffer.Take(args.BytesRecorded));
                         if (TempBuffer.Count > 200000)
                         {
                             SendTimer.Reset();
                             SendTempBuffer();
                         }
                         else if (SendTimer.Elapsed.TotalMilliseconds > 1000)
                         {
                             SendTimer.Reset();
                             SendTempBuffer();
                         }
                     }
                 }
             }
             catch
             {
             }
         };
         Capturer.StartRecording();
     }
     catch
     {
     }
 }
コード例 #10
0
        private void Start(CloudType cloudType)
        {
            try
            {
                if (cloudType == CloudType.Test)
                {
                    string path = Path.GetRandomFileName();
                    path         = path.Replace(".", ""); // Remove period.
                    deviceClient = new DeviceClient("testdev", path);
                    System.Diagnostics.Process.Start("https://quickstart.internetofthings.ibmcloud.com/#/device/" + path);
                }
                else
                {
                    deviceClient = new DeviceClient(Properties.IBMWatsonsSettings.Default.OrgId,
                                                    Properties.IBMWatsonsSettings.Default.DeviceType,
                                                    Properties.IBMWatsonsSettings.Default.DeviceId, "token",
                                                    Properties.IBMWatsonsSettings.Default.AuthToken);
                }


                ErrorText = "";
                deviceClient.connect();
                deviceClient.subscribeCommand("testcmd", "json", 0);
                SendTimer.Start();
            }
            catch (Exception ex)
            {
                if (CloudButtonContent == "Stop")
                {
                    Stop();
                    TestButtonEnable   = true;
                    CloudButtonContent = "Push";
                }
                if (TestButtonContent == "Stop testing")
                {
                    Stop();
                    CloundButtonEnable = true;
                    TestButtonContent  = "Test connection";
                }
                ErrorText = "Error: Can't create cloud client";
            }
        }
コード例 #11
0
        private void SetWriteTimeout(TimeSpan timeout, bool synchronous)
        {
            if (synchronous)
            {
                CancelSendTimer();

                // 0 == infinite for winsock timeouts, so we should preempt and throw
                if (timeout <= TimeSpan.Zero)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                              new TimeoutException(SR.Format(SR.TcpConnectionTimedOut, timeout)));
                }

                if (UpdateTimeout(_sendTimeout, timeout))
                {
                    lock (ThisLock)
                    {
                        ThrowIfNotOpen();
                        _socket.SendTimeout = TimeoutHelper.ToMilliseconds(timeout);
                    }
                    _sendTimeout = timeout;
                }
            }
            else
            {
                _sendTimeout = timeout;
                if (timeout == TimeSpan.MaxValue)
                {
                    CancelSendTimer();
                }
                else
                {
                    SendTimer.Change(timeout, TimeSpan.FromMilliseconds(-1));
                }
            }
        }
コード例 #12
0
 private void Stop()
 {
     Capturer?.StopRecording();
     SendTimer?.Reset();
 }
コード例 #13
0
ファイル: Form1.cs プロジェクト: vebin/AtlantisIoT
 private void button1_Click(object sender, EventArgs e)
 {
     SendTimer.Start();
 }
コード例 #14
0
 private void Close_Btn_Click(object sender, EventArgs e)
 {
     serialPort1.Close();
     SendTimer.Stop();
 }
コード例 #15
0
 private void SendTimer_Tick(object sender, EventArgs e)
 {
     SendTimer.Stop();
     serialPort.Write(Sendbytes, 0, 8);
     SendTimer.Start();
 }
コード例 #16
0
ファイル: Form1.cs プロジェクト: vebin/AtlantisIoT
 private void button2_Click(object sender, EventArgs e)
 {
     SendTimer.Stop();
 }
コード例 #17
0
 private void Stop()
 {
     SendTimer.Stop();
     CloudButtonContent = "Push";
 }
コード例 #18
0
ファイル: Form1.cs プロジェクト: Edin023/RobotArm
 public Form1()
 {
     InitializeComponent();
     SendTimer.Start();
     BaseRadio.Checked = true;
 }
コード例 #19
0
 private void Stop()
 {
     SendTimer.Stop();
 }