Exemple #1
0
 public TriggerInfo(DateTime timestamp, NeurotransmitterEffect effect, float strength, string presynapticId)
 {
     this.Timestamp     = timestamp;
     this.Effect        = effect;
     this.Strength      = strength;
     this.PresynapticId = presynapticId;
 }
Exemple #2
0
 public TerminalCreated(Guid id, Guid presynapticNeuronId, Guid postsynapticNeuronId, NeurotransmitterEffect effect, float strength)
 {
     this.Id = id;
     this.PresynapticNeuronId  = presynapticNeuronId;
     this.PostsynapticNeuronId = postsynapticNeuronId;
     this.Effect   = effect;
     this.Strength = strength;
 }
Exemple #3
0
 public NeuronResult(DateTime timestamp, string id, string data, NeurotransmitterEffect effect, int charge)
 {
     this.Timestamp = timestamp;
     this.Id        = id;
     this.Data      = data;
     this.Effect    = effect;
     this.Charge    = charge;
 }
Exemple #4
0
        private static void CreateTerminalFromDynamic(dynamic dynamicTerminal, Dictionary <string, object> bodyAsDictionary, out Guid terminalId, out Guid presynapticNeuronId,
                                                      out Guid postsynapticNeuronId, out NeurotransmitterEffect effect, out float strength, out string externalReferenceUrl, out string userId)
        {
            terminalId           = Guid.Parse(dynamicTerminal.Id.ToString());
            presynapticNeuronId  = Guid.Parse(dynamicTerminal.PresynapticNeuronId.ToString());
            postsynapticNeuronId = Guid.Parse(dynamicTerminal.PostsynapticNeuronId.ToString());
            string ne = dynamicTerminal.Effect.ToString();

            if (Enum.IsDefined(typeof(NeurotransmitterEffect), (int.TryParse(ne, out int ine) ? (object)ine : ne)))
            {
                effect = (NeurotransmitterEffect)Enum.Parse(typeof(NeurotransmitterEffect), dynamicTerminal.Effect.ToString());
            }
Exemple #5
0
 public Terminal(string targetId, NeurotransmitterEffect effect, float strength)
 {
     this.TargetId = targetId;
     this.Effect   = effect;
     this.Strength = strength;
 }
Exemple #6
0
        public Terminal(Guid id, Neuron presynapticNeuron, Neuron postsynapticNeuron, NeurotransmitterEffect effect, float strength)
        {
            AssertionConcern.AssertArgumentValid(i => i != Guid.Empty, id, Messages.Exception.IdEmpty, nameof(id));
            AssertionConcern.AssertArgumentNotNull(presynapticNeuron, nameof(presynapticNeuron));
            AssertionConcern.AssertArgumentValid(n => n.Active, presynapticNeuron, Messages.Exception.NeuronInactive, nameof(presynapticNeuron));
            AssertionConcern.AssertArgumentNotNull(postsynapticNeuron, nameof(postsynapticNeuron));
            AssertionConcern.AssertArgumentValid(n => n.Active, postsynapticNeuron, Messages.Exception.NeuronInactive, nameof(postsynapticNeuron));
            AssertionConcern.AssertArgumentValid(e => e != NeurotransmitterEffect.NotSet, effect, Messages.Exception.ValidEffect, nameof(effect));
            AssertionConcern.AssertArgumentValid(s => s > 0 && s <= 1, strength, Messages.Exception.StrengthInvalid, nameof(strength));
            AssertionConcern.AssertArgumentValid(g => g != presynapticNeuron.Id, postsynapticNeuron.Id, Messages.Exception.PostCannotBeTheSameAsPre, nameof(postsynapticNeuron));
            AssertionConcern.AssertArgumentValid(g => g != presynapticNeuron.Id, id, Messages.Exception.InvalidTerminalIdCreation, nameof(id));
            AssertionConcern.AssertArgumentValid(g => g != postsynapticNeuron.Id, id, Messages.Exception.InvalidTerminalIdCreation, nameof(id));

            this.Id = id;
            this.ApplyChange(new TerminalCreated(id, presynapticNeuron.Id, postsynapticNeuron.Id, effect, strength));
        }
Exemple #7
0
 public async Task CreateTerminal(string avatarUrl, string id, string presynapticNeuronId, string postsynapticNeuronId, NeurotransmitterEffect effect, float strength, CancellationToken token = default(CancellationToken))
 {
     await this.terminalClient.CreateTerminal(avatarUrl, id, presynapticNeuronId, postsynapticNeuronId, effect, strength, token);
 }
        private async Task CreateTerminalInternal(string cortexInBaseUrl, string id, string presynapticNeuronId, string postsynapticNeuronId, NeurotransmitterEffect effect, float strength, string authorId, CancellationToken token = default(CancellationToken))
        {
            var data = new
            {
                Id = id,
                PresynapticNeuronId  = presynapticNeuronId,
                PostsynapticNeuronId = postsynapticNeuronId,
                Effect   = effect.ToString(),
                Strength = strength.ToString(),
                AuthorId = authorId
            };

            await this.requestProvider.PostAsync(
                $"{cortexInBaseUrl}{HttpTerminalClient.terminalsPath}",
                data
                );
        }
 public async Task CreateTerminal(string cortexInBaseUrl, string id, string presynapticNeuronId, string postsynapticNeuronId, NeurotransmitterEffect effect, float strength, string authorId, CancellationToken token = default(CancellationToken)) =>
 await HttpTerminalClient.exponentialRetryPolicy.ExecuteAsync(
     async() => await this.CreateTerminalInternal(cortexInBaseUrl, id, presynapticNeuronId, postsynapticNeuronId, effect, strength, authorId, token).ConfigureAwait(false));
Exemple #10
0
        public CreateTerminal(Guid id, Guid presynapticNeuronId, Guid postsynapticNeuronId, NeurotransmitterEffect effect, float strength, Guid authorId)
        {
            AssertionConcern.AssertArgumentValid(
                g => g != Guid.Empty,
                id,
                Messages.Exception.InvalidId,
                nameof(id)
                );
            AssertionConcern.AssertArgumentValid(
                g => g != Guid.Empty,
                presynapticNeuronId,
                Messages.Exception.InvalidId,
                nameof(presynapticNeuronId)
                );
            AssertionConcern.AssertArgumentValid(
                g => g != Guid.Empty,
                postsynapticNeuronId,
                Messages.Exception.InvalidId,
                nameof(postsynapticNeuronId)
                );
            AssertionConcern.AssertArgumentValid(
                g => g != Guid.Empty,
                authorId,
                Messages.Exception.InvalidId,
                nameof(authorId)
                );

            this.Id = id;
            this.PresynapticNeuronId  = presynapticNeuronId;
            this.PostsynapticNeuronId = postsynapticNeuronId;
            this.Effect   = effect;
            this.Strength = strength;
            this.AuthorId = authorId;
        }
Exemple #11
0
        public CreateTerminal(Guid id, Guid presynapticNeuronId, Guid postsynapticNeuronId, NeurotransmitterEffect effect, float strength, string externalReferenceUrl, string userId)
        {
            AssertionConcern.AssertArgumentValid(
                g => g != Guid.Empty,
                id,
                Messages.Exception.InvalidId,
                nameof(id)
                );
            AssertionConcern.AssertArgumentValid(
                g => g != Guid.Empty,
                presynapticNeuronId,
                Messages.Exception.InvalidId,
                nameof(presynapticNeuronId)
                );
            AssertionConcern.AssertArgumentValid(
                g => g != Guid.Empty,
                postsynapticNeuronId,
                Messages.Exception.InvalidId,
                nameof(postsynapticNeuronId)
                );
            AssertionConcern.AssertArgumentNotEmpty(
                userId,
                Messages.Exception.InvalidUserId,
                nameof(userId)
                );

            this.Id = id;
            this.PresynapticNeuronId  = presynapticNeuronId;
            this.PostsynapticNeuronId = postsynapticNeuronId;
            this.Effect               = effect;
            this.Strength             = strength;
            this.ExternalReferenceUrl = externalReferenceUrl;
            this.UserId               = userId;
        }
Exemple #12
0
        private async Task CreateTerminalInternal(string avatarUrl, string id, string presynapticNeuronId, string postsynapticNeuronId, NeurotransmitterEffect effect, float strength, string externalReferenceUrl, string bearerToken, CancellationToken token = default(CancellationToken))
        {
            var data = new
            {
                Id = id,
                PresynapticNeuronId  = presynapticNeuronId,
                PostsynapticNeuronId = postsynapticNeuronId,
                Effect               = effect.ToString(),
                Strength             = strength.ToString(),
                ExternalReferenceUrl = externalReferenceUrl
            };

            await this.requestProvider.PostAsync(
                $"{avatarUrl}{HttpTerminalClient.terminalsPath}",
                data,
                bearerToken
                );
        }
Exemple #13
0
 public async Task CreateTerminal(string avatarUrl, string id, string presynapticNeuronId, string postsynapticNeuronId, NeurotransmitterEffect effect, float strength, string externalReferenceUrl, string bearerToken, CancellationToken token = default(CancellationToken)) =>
 await HttpTerminalClient.exponentialRetryPolicy.ExecuteAsync(
     async() => await this.CreateTerminalInternal(avatarUrl, id, presynapticNeuronId, postsynapticNeuronId, effect, strength, externalReferenceUrl, bearerToken, token).ConfigureAwait(false));
Exemple #14
0
 public Terminal(string id, string presynapticNeuronIdCore, string postsynapticNeuronIdCore, NeurotransmitterEffect effect, float strength)
 {
     this.Id = id;
     this.PresynapticNeuronIdCore  = presynapticNeuronIdCore;
     this.PostsynapticNeuronIdCore = postsynapticNeuronIdCore;
     this.Effect   = effect;
     this.Strength = strength;
 }
Exemple #15
0
 private static float GetChargeByEffect(IEnumerable <TriggerInfo> effectiveTriggers, NeurotransmitterEffect effect)
 {
     // sum triggers within the last refractory period
     return(effectiveTriggers.Sum(
                ti => ti.Effect == effect ?
                Constants.SpikeDepolarizationAmount * ti.Strength * ((int)effect) :
                0
                ));
 }