Exemplo n.º 1
0
        public void GetAndResolveReceiveBag(object obj)
        {
            this.dtuid = obj as string;
            ReceiveBytes receivedata = ReceiveBytes.GetReceiveBytes();

            while (true)
            {
                if (receivedata.GetDtuReceivedBytesCount(this.dtuid) > 7)
                {
                    ReceiveDataInfo recedata = receivedata.GetReceivePackage(this.dtuid);
                    if (recedata != null)
                    {
                        try
                        {
                            var bt = new object();
                            bt = ReloveCustomTransData.GetInstance.ProtocolOrder(recedata);
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex.Message);
                        }
                    }
                    else
                    {
                        Thread.Sleep(10);
                    }
                }
                else
                {
                    Thread.Sleep(1000);
                }
            }
        }
Exemplo n.º 2
0
        public void Print()
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                sb.Clear();
                string value = "NetBenchmark";
                Console.CursorTop  = 0;
                Console.CursorLeft = 0;

                sb.AppendLine("-".PadRight(WIDTH, '-'));
                int span = WIDTH / 2 - value.Length / 2;
                sb.AppendLine("".PadLeft(span) + value);

                value = "Copyright © beetlex.io 2019-2020 email:[email protected]";
                span  = WIDTH / 2 - value.Length / 2;
                sb.AppendLine("".PadLeft(span) + value);


                value = Name;
                span  = 70 / 2 - value.Length / 2;
                sb.AppendLine("".PadLeft(span) + value);

                value = $"{Stopwatch.Elapsed}";
                span  = WIDTH / 2 - value.Length / 2;
                sb.AppendLine("".PadLeft(span) + value);

                sb.AppendLine("-".PadRight(WIDTH, '-'));
                sb.Append("|");
                value = $"Name|".PadLeft(18);
                sb.Append(value);

                value = $"Max|".PadLeft(10);
                sb.Append(value);

                value = $"Avg|".PadLeft(10);
                sb.Append(value);

                value = $"Min|".PadLeft(10);
                sb.Append(value);

                value = $"RPS/Total|".PadLeft(26);
                sb.Append(value);
                sb.AppendLine("");

                sb.AppendLine("-".PadRight(WIDTH, '-'));
                Success.Print(sb);
                Error.Print(sb);
                ReceiveBytes.Print(sb, 1024, "(KB)");
                SendBytes.Print(sb, 1024, "(KB)");
                sb.AppendLine("-".PadRight(WIDTH, '-'));
                mTimesStatistics.Print(sb);
                sb.AppendLine("-".PadRight(WIDTH, '-'));
                Console.WriteLine(sb);
                System.Threading.Thread.Sleep(1000);
            }
        }
Exemplo n.º 3
0
            public override void OnCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
            {
                Log.Info(TAG + DexService.Operation,
                         $"Characteristic {characteristic.Uuid} Changed => {characteristic.GetValue()?.ToListOfByte()}");

                base.OnCharacteristicChanged(gatt, characteristic);

                try
                {
                    if (!characteristic.Uuid.Equals(DEX_CHARACTERISTIC_DATAWRITE))
                    {
                        return;
                    }

                    if (DEX_CHARACTERISTIC_DATAWRITE.Equals(characteristic.Uuid))
                    {
                        byte[] receive = characteristic.GetValue();
                        lock (DataReadOperationSync)
                        {
                            var characteristicValue = new string(Encoding.Default.GetChars(receive));

                            mReceiveBuffer.Append(characteristicValue);

                            Log.Info(TAG + DexService.Operation,
                                     $"Data Received => {receive.ToListOfByte()}");

                            DexService.LogMessage2($"Data Received => {receive.ToListOfByte()}", false);

                            if (DexService.Stacking)
                            {
                                DexService.StackList.Add(receive);
                            }

                            ReceiveBytes = ByteHelper.Combine(ReceiveBytes, receive);

                            Log.Info(TAG + DexService.Operation,
                                     $"ReceivedBytes is now  => {ReceiveBytes.ToListOfByte()}");
                        }
                    }
                }
                catch (Java.IO.IOException e)
                {
                    e.PrintStackTrace();
                }
                catch (InterruptedException e)
                {
                    e.PrintStackTrace();
                }
                catch (Exception exception)
                {
                    Log.Error(TAG, $"Error dans OnCharacteristicChanged {exception.Message}");
                }

                //Log.Info(DexService.TAG + DexService.Operation, $"Characteristic UUID IS => {characteristic.Uuid}");
                //Log.Info(DexService.TAG + DexService.Operation, $"DEX UUID IS            => {DexService.DEX_CHARACTERISTIC_DATAWRITE}");
            }
Exemplo n.º 4
0
 private void OnStatistics(object state)
 {
     if (Status)
     {
         Success.Calculate();
         Error.Calculate();
         ReceiveBytes.Calculate();
         SendBytes.Calculate();
     }
 }
Exemplo n.º 5
0
 public async void Run()
 {
     Status = true;
     foreach (var item in Testers)
     {
         await OnPreheating(item);
     }
     Stopwatch.Restart();
     Success.Reset();
     Error.Reset();
     ReceiveBytes.Reset();
     SendBytes.Reset();
     foreach (var item in Testers)
     {
         Task.Run(() => OnRunItem(item));
     }
     mStatisticsTimer = new System.Threading.Timer(OnStatistics, null, 1000, 1000);
 }
Exemplo n.º 6
0
        public async Task ExecuteOnClient()
        {
            ReceiveBytes = new ReceiveBytes <Stream>(Transport, () => Task.FromResult((Stream) new MemoryStream()), 1 << 20 /*1MB*/);
            Result       = await ReceiveBytes.AwaitFlowResult();

            return;

            if (ReceiveBytes == null)
            {
                ReceiveBytes = new ReceiveBytes <Stream>(Transport, null, 1 << 20 /*1MB*/);
            }
            if (ReceiveBytesStream == null)
            {
                ReceiveBytesStream         = new ReceiveBytesStream(Document, ReceiveBytes);
                ReceiveBytesStream.Command = this;
                ReceiveBytesStream.OnDispose.Add(LockAction);
            }
            Result = await ReceiveBytesStream.AwaitFlowResult();
        }
        private void recieveDataMonitor()
        {
            while (true)
            {
                Thread.Sleep(ReadBufferInterval);

                if (Status != DeviceStatus.Online)
                {
                    continue;
                }

                var buff = AtUsbHid.ReadBuffer();
                if (buff != null && buff.Length != 0)
                {
                    Task.Factory.StartNew(() => ReceiveBytes?.Invoke(buff));
                }
            }
            // ReSharper disable once FunctionNeverReturns
        }
Exemplo n.º 8
0
 /// <summary>
 /// The wrapper_ receive data.
 /// </summary>
 /// <param name="buff"></param>
 private void Wrapper_ReceiveData(ReceiveDataInfo buff)
 {
     try
     {
         if (buff != null)
         {
             if (DataHexShowStringLogEventArgs != null)
             {
                 DataHexShowStringLogEventArgs(buff);
             }
             var str = new StringBuilder();
             str.Append(buff.Sender).Append(ValueHelper.ByteToHexStr(buff.PackagesBytes));
             Log.Debug(str.ToString());
             ReceiveBytes.GetReceiveBytes().AddReceiveBytes(buff.Sender, buff.PackagesBytes);
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex.Message);
     }
 }
Exemplo n.º 9
0
 public void StopService()
 {
     ReceiveBytes.GetReceiveBytes().AddNewDtuReceiveDataEventArgs -= ResolveThread_AddNewDtuReceiveDataEventArgs;
 }
Exemplo n.º 10
0
 public void StartSerive()
 {
     ReceiveBytes.GetReceiveBytes().AddNewDtuReceiveDataEventArgs += ResolveThread_AddNewDtuReceiveDataEventArgs;
 }
Exemplo n.º 11
0
 public void ReceiveCompleted(IClient client, SocketAsyncEventArgs e)
 {
     ReceiveBytes.Add(e.BytesTransferred);
 }