Ejemplo n.º 1
0
        private GrpcTxEvent ConvertEvent(TxEvent @event)
        {
            var payloads = ByteString.CopyFrom(_serializer.Serialize(@event.Payloads), Encoding.UTF8);

            return(new GrpcTxEvent()
            {
                ServiceName = _serviceConfig.ServiceName,
                InstanceId = _serviceConfig.InstanceId,
                Timestamp = @event.Timestamp,
                GlobalTxId = @event.GlobalTxId,
                LocalTxId = @event.LocalTxId,
                ParentTxId = @event.ParentTxId ?? "",
                Type = @event.Type.ToString(),
                Timeout = @event.Timeout,
                CompensationMethod = @event.CompensationMethod,
                RetryMethod = @event.RetryMethod ?? "",
                Retries = @event.Retries,
                Payloads = payloads
            });
        }
Ejemplo n.º 2
0
 public void UpdateRecipes(string[] ids, string[] names, string[] cookbooks, string[] decriptions, long[] blockIntervals, string[] coinInputs, string[] itemInputs, string[] outputTables, string[] outputs, TxEvent evt) =>
 TxEventMessageHandler(() => new UpdateRecipes(ids, names, cookbooks, decriptions, blockIntervals, coinInputs, itemInputs, outputTables, outputs), evt);
Ejemplo n.º 3
0
 public void UpdateCookbooks(string[] ids, string[] names, string[] developers, string[] descriptions, string[] versions, string[] supportEmails, TxEvent evt) =>
 TxEventMessageHandler(() => new UpdateCookbooks(ids, names, developers, descriptions, versions, supportEmails), evt);
Ejemplo n.º 4
0
 public void SetItemString(string item, string field, string value, TxEvent evt) =>
 TxEventMessageHandler(() => new SetItemString(item, field, value), evt);
Ejemplo n.º 5
0
 public void SendCoins(string denom, long count, string receiver, TxEvent evt) =>
 TxEventMessageHandler(() => new SendCoins(JsonConvert.SerializeObject(new Coin[] { new Coin(denom, count) }), receiver), evt);
Ejemplo n.º 6
0
 public void RegisterProfile(string name, TxEvent evt) =>
 TxEventMessageHandler(() => new RegisterProfile(name, false), evt);
Ejemplo n.º 7
0
 public void ExecuteRecipe(string recipe, string cookbook, string[] itemInputs, TxEvent evt) =>
 TxEventMessageHandler(() => new ExecuteRecipe(recipe, cookbook, itemInputs), evt);
Ejemplo n.º 8
0
 public void FulfillTrade(string tradeId, string[] itemIds, TxEvent evt) =>
 TxEventMessageHandler(() => new FulfillTrade(tradeId, itemIds), evt);
Ejemplo n.º 9
0
 public void CreateTrade(string[] coinInputs, string[] itemInputs, string[] coinOutputs, string[] itemOutputs, string extraInfo, TxEvent evt) =>
 TxEventMessageHandler(() => new CreateTrade(coinInputs, itemInputs, coinOutputs, itemOutputs, extraInfo), evt);
Ejemplo n.º 10
0
 public void EnableRecipes(string[] recipeIds, TxEvent evt) =>
 TxEventMessageHandler(() => new EnableRecipes(recipeIds), evt);
Ejemplo n.º 11
0
 public void CreateCookbooks(string[] ids, string[] names, string[] developers, string[] descriptions, string[] versions, string[] supportEmails, long[] levels, long[] costsPerBlock, TxEvent evt) =>
 TxEventMessageHandler(() => new CreateCookbooks(ids, names, developers, descriptions, versions, supportEmails, levels, costsPerBlock), evt);
Ejemplo n.º 12
0
 public void CheckExecution(string execId, bool payForCompletion, TxEvent evt) =>
 TxEventMessageHandler(() => new CheckExecution(execId, payForCompletion), evt);
Ejemplo n.º 13
0
 public void CancelTrade(string tradeId, TxEvent evt) =>
 TxEventMessageHandler(() => new CancelTrade(tradeId), evt);
Ejemplo n.º 14
0
        private void DefineRegisters()
        {
            Registers.RxBufferBaseAddress.Define(this)
            // this is not consistent with the documentation
            // that states that only 21 bits are used for the address,
            // but otherwise the sample fails
            .WithValueField(0, 32, out rxBufferAddress, name: "RX_SADDR")
            ;

            Registers.RxBufferSize.Define(this)
            .WithValueField(0, 20, out rxBufferSize, name: "RX_SIZE")
            .WithReservedBits(20, 12)
            ;

            Registers.RxStreamConfiguration.Define(this)
            .WithTag("CONTINOUS", 0, 1)
            .WithReservedBits(1, 3)
            .WithFlag(4, out rxStreamEnabled, name: "EN")
            .WithTag("PENDING", 5, 1)
            .WithTag("CLR", 6, 1)
            .WithReservedBits(7, 25)
            ;

            Registers.TxBufferBaseAddress.Define(this)
            // this is not consistent with the documentation
            // that states that only 21 bits are used for the address,
            // but otherwise the sample fails
            .WithValueField(0, 32, out txBufferAddress, name: "TX_SADDR")
            ;

            Registers.TxBufferSize.Define(this)
            .WithValueField(0, 20, out txBufferSize, name: "TX_SIZE")
            .WithReservedBits(20, 12)
            ;

            Registers.TxStreamConfiguration.Define(this)
            .WithTag("CONTINOUS", 0, 1)
            .WithReservedBits(1, 3)
            .WithFlag(4, name: "EN",
                      valueProviderCallback: _ => false, // the transfer is instant + we don't support the continous mode, so we disable right away
                      writeCallback: (_, val) =>
            {
                if (!val)
                {
                    return;
                }

                this.Log(LogLevel.Debug, "Starting a DMA TX transaction");
                var data = machine.SystemBus.ReadBytes(txBufferAddress.Value, (int)txBufferSize.Value);
#if DEBUG_PACKETS
                this.Log(LogLevel.Noisy, "Read data from the memory @ 0x{0:X}: {1}", txBufferAddress.Value, Misc.PrettyPrintCollectionHex(data));
#endif

                HandleIncomingBytes(data);
                TxEvent.Blink();
            })
            .WithFlag(5, FieldMode.Read, name: "PENDING", valueProviderCallback: _ => false)
            .WithTag("CLR", 6, 1)
            .WithReservedBits(7, 25)
            ;

            Registers.CommandBufferBaseAddress.Define(this)
            .WithValueField(0, 21, name: "CMD_SADDR")
            .WithReservedBits(21, 11)
            ;

            Registers.CommandBufferSize.Define(this)
            .WithValueField(0, 20, name: "CMD_SIZE")
            .WithReservedBits(20, 12)
            ;

            Registers.CommandStreamConfiguration.Define(this)
            .WithTag("CONTINOUS", 0, 1)
            .WithReservedBits(1, 3)
            .WithTag("EN", 4, 1)
            .WithTag("PENDING", 5, 1)
            .WithTag("CLR", 6, 1)
            .WithReservedBits(7, 25)
            ;

            Registers.Status.Define(this)
            .WithTag("BUSY", 0, 1)
            .WithTag("ARB_LOST", 1, 1)
            .WithReservedBits(2, 30)
            ;

            Registers.Setup.Define(this)
            .WithTag("DO_RST", 0, 1)
            .WithReservedBits(1, 31)
            ;
        }
Ejemplo n.º 15
0
        public void GetPylons(long count, TxEvent evt) =>
#if DEBUG
        TxEventMessageHandler(() => new GetPylons(count), evt);
Ejemplo n.º 16
0
        public AlphaResponse Send(TxEvent @event)
        {
            var grpcAck = _client.OnTxEvent(ConvertEvent(@event));

            return(new AlphaResponse(grpcAck.Aborted));
        }
Ejemplo n.º 17
0
 public void GetTransaction(string txHash, TxEvent evt) =>
 TxEventMessageHandler(() => new GetTransaction(txHash), evt);
 public AlphaResponse Send(TxEvent @event)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 19
0
 public void TxEventMessageHandler(Func <IpcMessage> msg, TxEvent evt) => IpcInteraction.Stage(msg, (s, e) => { evt.Invoke(s, ((TxResponse)e).Transactions); });