コード例 #1
0
 public FormDataClass(AmountConverter aAmountConverter, WalletSendFormBase aWalletSendFormBase)
 {
     _Amount            = "";
     SendAction         = new SendAction();
     AmountConverter    = aAmountConverter;
     WalletSendFormBase = aWalletSendFormBase;
 }
コード例 #2
0
        public void Setup()
        {
            // Setup known state valid State.required for a Send to be valid

            ValidEdgeCurrencyWalletsState = new EdgeCurrencyWalletsState();
            // setup wallet

            var edgeCurrencyWallet = new EdgeCurrencyWallet
            {
                SelectedCurrencyCode = "AGLD"
            };

            edgeCurrencyWallet.Balances.Add("AGLD", AgldStartBalance); //1.5 AGLD

            ValidEdgeCurrencyWalletsState.EdgeCurrencyWallets.Add(
                WalletId,
                edgeCurrencyWallet);
            EdgeCurrencyWalletsState.Initialize(ValidEdgeCurrencyWalletsState);

            SendAction = new SendAction
            {
                CurrencyCode         = "AGLD",
                DestinationAddress   = "0xe3d6f1e0434b870c3b3a0066bdcbffd4ba3f7ea6",
                EdgeCurrencyWalletId = "1fu3+YTRMVRb6R6uwO7DDCH31iVKkBMtkYHLA0P3hMo=",
                NativeAmount         = "500000000000000000", // 0.5 AGLD
                Fee = FeeOption.Standard,
            };
        }
コード例 #3
0
 /// <summary>
 /// 创建一个工作任务单元 并指定读取流和写入流的实现
 /// </summary>
 /// <param name="channel"></param>
 /// <param name="receiveFunc">自定义从缓冲区读取数据的方法</param>
 /// <param name="sendFunc">自定义写入缓冲区数据的方法</param>
 public Task(BaseChannel channel, ReceiveAction receiveFunc, SendAction sendFunc)
 {
     _Chan         = channel;
     receiveAction = receiveFunc;
     sendAction    = sendFunc;
     cglock.DoWork();
 }
コード例 #4
0
        public static async Task SendAsync(this Session session, string output,
                                           CancellationToken cancellationToken = default)
        {
            var action = new SendAction(new ActionContext(session.Expectable, session.ItemsCache))
            {
                Output = output
            };

            await new SendActionHandler().Handle(action, cancellationToken);
        }
コード例 #5
0
        /// <summary>
        /// 创建一个工作任务单元
        /// </summary>
        /// <param name="channel"></param>
        public Task(BaseChannel channel)
        {
            _Chan         = channel;
            receiveAction = (x, y) => {
                return(y.Read(64));
            };
            sendAction = (x, y) => {
                return(y.Write(x.GetTX()));
            };

            cglock.DoWork();
        }
コード例 #6
0
        public string Post(string blindName, [FromQuery] string action)
        {
            SendAction _action = SendAction.Down;

            if (action == "up")
            {
                _action = SendAction.Up;
            }
            else if (action == "stop")
            {
                _action = SendAction.Stop;
            }
            else if (action == "prog")
            {
                _action = SendAction.Prog;
            }

            RemoteController remote = null;

            using (var db = new LiteDatabase(@"remotes.db"))
            {
                var remotes = db.GetCollection <RemoteController>("remotes");
                remote = remotes.FindOne(x => x.Name == blindName);
                if (remote == null)
                {
                    remote = new RemoteController()
                    {
                        CurrentCounter = 0, Id = remotes.FindAll().ToArray().Count() > 0 ? remotes.FindAll().ToArray().Max(x => x.Id) + 1 : 0, Name = blindName
                    };
                    remotes.Insert(remote);
                }
                try
                {
                    var remoteId = Convert.ToInt32(remote.Id.ToString(), 16);
                    new Commands().Send(remoteId, remote.CurrentCounter + 1, _action);
                    remote.CurrentCounter++;
                    remotes.Update(remote);
                    return("done");
                }
                catch (Exception ex)
                {
                    return(ex.Message);
                }
            }
        }
コード例 #7
0
        public async Task Send(SendAction sendAction)
        {
            if (sendAction.Content.Length > 200)
            {
                await Clients.Client(Context.ConnectionId).ShowMessage(new PlayerMessage()
                {
                    Channel  = "闲聊",
                    Content  = "输入内容过多,不能超过100个字",
                    Sender   = _account.PlayerName,
                    PlayerId = _account.PlayerId
                });

                return;
            }

            var result = await DoCommand(async() => {
                var playerId = _account.PlayerId;

                var command = new SendMessageCommand(playerId, sendAction.Channel, sendAction.Content);
                await _bus.SendCommand(command);
            });
        }
コード例 #8
0
 public FormDataClass(AmountConverter aAmountConverter)
 {
     _Amount         = "";
     SendAction      = new SendAction();
     AmountConverter = aAmountConverter;
 }
コード例 #9
0
        public void Send(int remote, int counter, SendAction action)
        {
            int line = 0;

            try
            {
                var checksum = 0;
                Setup.GpioInitialise();

                IO.GpioSetMode(SystemGpio.Bcm04, PinMode.Output);

                Waves.GpioWaveAddNew();
                byte[] frame = new byte[7];
                line = 4;


                frame[0] = 0xA7;                                   // Encryption key. Doesn't matter much
                frame[1] = Convert.ToByte((int)action << 4);       // Which action did you chose? The 4 LSB will be the checksum
                frame[2] = Convert.ToByte(counter >> 8);           // Rolling code (big endian)
                frame[3] = Convert.ToByte((counter & 0xFF));       // Rolling code
                frame[4] = Convert.ToByte(remote >> 16);           // Remote address
                frame[5] = Convert.ToByte(((remote >> 8) & 0xFF)); //Remote address
                frame[6] = Convert.ToByte((remote & 0xFF));        // Remote address
                line     = 5;

                foreach (var f in frame)
                {
                    checksum = checksum ^ f ^ (f >> 4);
                }
                line      = 6;
                checksum &= 0b1111; // We keep the last 4 bits only

                line      = 7;
                frame[1] |= Convert.ToByte(checksum);
                line      = 8;

                for (int i = 1; i < frame.Length; i++) // obfuscate
                {
                    frame[i] ^= frame[i - 1];
                }
                line = 9;
                var     wf         = new List <PulseNew>();
                BitMask pinBitMask = (BitMask)Enum.Parse(typeof(BitMask), (1 << (int)TXGPIO).ToString());
                wf.Add(new PulseNew()
                {
                    GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 9415
                });
                wf.Add(new PulseNew()
                {
                    GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 89565
                });
                for (int i = 0; i < 2; i++)
                {
                    wf.Add(new PulseNew()
                    {
                        GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 2560
                    });
                    wf.Add(new PulseNew()
                    {
                        GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 2560
                    });
                }

                wf.Add(new PulseNew()
                {
                    GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 4550
                });
                wf.Add(new PulseNew()
                {
                    GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 640
                });

                for (int i = 0; i < 56; i++)
                {
                    var check = (frame[i / 8] >> (7 - (i % 8))) & 1;
                    if (check == 1)
                    {
                        wf.Add(new PulseNew()
                        {
                            GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 640
                        });
                        wf.Add(new PulseNew()
                        {
                            GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 640
                        });
                    }
                    else
                    {
                        wf.Add(new PulseNew()
                        {
                            GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 640
                        });
                        wf.Add(new PulseNew()
                        {
                            GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 640
                        });
                    }
                }
                wf.Add(new PulseNew()
                {
                    GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 30415
                });



                //1
                for (int i = 0; i < 7; i++)
                {
                    wf.Add(new PulseNew()
                    {
                        GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 2560
                    });
                    wf.Add(new PulseNew()
                    {
                        GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 2560
                    });
                }

                wf.Add(new PulseNew()
                {
                    GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 4550
                });
                wf.Add(new PulseNew()
                {
                    GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 640
                });

                for (int i = 0; i < 56; i++)
                {
                    var check = (frame[i / 8] >> (7 - (i % 8))) & 1;
                    if (check == 1)
                    {
                        wf.Add(new PulseNew()
                        {
                            GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 640
                        });
                        wf.Add(new PulseNew()
                        {
                            GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 640
                        });
                    }
                    else
                    {
                        wf.Add(new PulseNew()
                        {
                            GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 640
                        });
                        wf.Add(new PulseNew()
                        {
                            GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 640
                        });
                    }
                }
                wf.Add(new PulseNew()
                {
                    GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 30415
                });



                //2
                for (int i = 0; i < 7; i++)
                {
                    wf.Add(new PulseNew()
                    {
                        GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 2560
                    });
                    wf.Add(new PulseNew()
                    {
                        GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 2560
                    });
                }
                wf.Add(new PulseNew()
                {
                    GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 4550
                });
                wf.Add(new PulseNew()
                {
                    GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 640
                });

                for (int i = 0; i < 56; i++)
                {
                    var check = (frame[i / 8] >> (7 - (i % 8))) & 1;
                    if (check == 1)
                    {
                        wf.Add(new PulseNew()
                        {
                            GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 640
                        });
                        wf.Add(new PulseNew()
                        {
                            GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 640
                        });
                    }
                    else
                    {
                        wf.Add(new PulseNew()
                        {
                            GpioOn = pinBitMask, GpioOff = BitMask.None, DurationMicroSecs = 640
                        });
                        wf.Add(new PulseNew()
                        {
                            GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 640
                        });
                    }
                }
                wf.Add(new PulseNew()
                {
                    GpioOn = BitMask.None, GpioOff = pinBitMask, DurationMicroSecs = 30415
                });

                line = 10;
                //var wid = (uint)Waves.GpioWaveAddGeneric((uint)wf.Count, wf.ToArray());

                GpioWaveAddGeneric(Convert.ToUInt32(wf.Count), wf.ToArray());
                var wid = (uint)Waves.GpioWaveCreate();
                line = 11;
                Waves.GpioWaveTxSend(wid, WaveMode.OneShot);
                line = 12;
                while (Waves.GpioWaveTxBusy() == 1)
                {
                }
                line = 13;
                Waves.GpioWaveDelete(wid);
                line = 14;
                Setup.GpioTerminate();
                line = 15;
            }
            catch (Exception ex)
            {
                throw new Exception("line=" + line + "message2" + ex.Message);
            }
        }