public override void OnAttach(ActorStatus status) { this.status = status; attached = true; endTime = curve[curve.length-1].time; Debug.Log ("end time: " + curve[curve.length-1].time); }
public override void OnApply(ActorStatus status) { if(damageDone){ return; } damageDone = true; if(status.ReadStatus.HP <= 0f) return; if(GetComponent<NetSyncObj>().mode == SFSNetworkManager.Mode.LOCAL){ status.WriteStatus().BaseHP -= damage; float pHp = status.WriteStatus().BaseHP; //pHp -= damage; //Debug.Log ("HP:" + status.WriteStatus().BaseHP); if(pHp < 0) pHp = 0; } else{ Debug.Log ("Remote damage fx"); } //if(status.GetModifiedStatusf(ActorStatus.StatusType.HP) <= 0f){ if(applyForceOnDeath){ ragdollTurner.ReadyExplosion(explosionPosition, explosionForce, explosionRadius); } else{ ragdollTurner.UnreadyExplosion(); } //} animator.SetBool("Hit", true); animationDone = true; }
public override void OnAttach(ActorStatus status) { // Debug.Log ("OnAttach"); this.status = status; ragdollTurner = status.GetComponent<RagdollTurner>(); animator = status.GetComponent<Animator>(); }
public override void OnApply(ActorStatus status) { // Debug.Log ("OnApply"); status.WriteStatus().MoveSpeedModifiers[0] += plusModifier1; status.WriteStatus().MoveSpeedModifiers[1] *= mulModifier2; status.WriteStatus().MoveSpeedModifiers[2] += plusModifier3; status.WriteStatus().MoveSpeedModifiers[3] *= mulModifier4; // Debug.Log (status.GetModifiers(ActorStatus.StatusType.MOVESPEED)[1]); }
// Use this for initialization void Start() { animator = GetComponent<Animator>(); runAnimationNameHash = Animator.StringToHash(runAnimationName); idleAnimationNameHash = Animator.StringToHash(idleAnimationName); charController = GetComponent<CharacterController>(); status = GetComponent<ActorStatus>(); if(animator.layerCount >= 2) animator.SetLayerWeight(1, 1); }
public override void OnApply(ActorStatus status) { float hp = status.ReadStatus.HP; if(isAliveLastFrame){ if(hp <= 0f){ foreach(GameObject gameObj in shutdownChildren){ if(gameObj.activeSelf){ gameObj.SetActive(false); } } ragdollTurner.TurnRagdoll(); } } isAliveLastFrame = hp > 0f; }
public async Task RunAsync_ActorUpdatedMessage_Status(ActorStatus status, bool isUpdate) { // Arrange var logger = new Mock <ILogger <MarketParticipantIngestionFunction> >().Object; var mediator = new Mock <IMediator>(); var parser = new SharedIntegrationEventParser(); var target = new MarketParticipantIngestionFunction(logger, mediator.Object, parser); var message = new ActorUpdatedIntegrationEvent( Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), "fake_value", status, Enumerable.Empty <BusinessRoleCode>(), Enumerable.Empty <EicFunction>(), Enumerable.Empty <Guid>(), Enumerable.Empty <string>()); var bytes = new ActorUpdatedIntegrationEventParser().Parse(message); // Act await target.RunAsync(bytes).ConfigureAwait(false); // Assert if (isUpdate) { mediator.Verify(m => m.Send(It.IsAny <UpdateActorCommand>(), CancellationToken.None), Times.Once); mediator.Verify(m => m.Send(It.IsAny <DeleteActorCommand>(), CancellationToken.None), Times.Never); } else { mediator.Verify(m => m.Send(It.IsAny <UpdateActorCommand>(), CancellationToken.None), Times.Never); mediator.Verify(m => m.Send(It.IsAny <DeleteActorCommand>(), CancellationToken.None), Times.Once); } }
// Run the next step and return a description about what happened public async Task RunAsync() { this.instance.InitRequired(); this.log.Debug(this.status.ToString(), () => new { this.deviceId }); var now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); if (now < this.whenToRun) { return; } switch (this.status) { case ActorStatus.ReadyToStart: if (!this.deviceContext.Connected) { return; } this.whenToRun = 0; this.HandleEvent(ActorEvents.Started); break; case ActorStatus.ReadyToSend: if (!this.deviceContext.Connected) { return; } this.status = ActorStatus.Sending; this.actorLogger.SendingTelemetry(); await this.sendTelemetryLogic.RunAsync(); break; } }
public void Run() { this.log.Debug(this.status.ToString(), () => new { this.deviceId }); var now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); if (now < this.whenToRun) { return; } switch (this.status) { case ActorStatus.ReadyToStart: this.whenToRun = 0; this.HandleEvent(ActorEvents.Started); return; case ActorStatus.ReadyToFetch: this.status = ActorStatus.Fetching; this.actorLogger.FetchingDevice(); this.fetchLogic.RunAsync(); return; case ActorStatus.ReadyToRegister: this.status = ActorStatus.Registering; this.actorLogger.RegisteringDevice(); this.registerLogic.RunAsync(); return; case ActorStatus.ReadyToConnect: this.status = ActorStatus.Connecting; this.actorLogger.ConnectingDevice(); this.connectLogic.RunAsync(); return; } }
private Actor CreateActorInstance(Exception recreateCause = null) { try { _messageHandlerStack = ImmutableStack <MessageHandler> .Empty; var actor = NewActorInstance(); actor.Init(this); //Init is idempotent so even if NewActorInstance() returns the same instance again this call is safe to make. _actorStatus = ActorStatus.Normal; //if _messageHandlers, still is empty, it means we had no Becomes in the constructor, use default-handling, i.e. HandleMessage if (_messageHandlerStack.IsEmpty) { _messageHandlerStack = _messageHandlerStack.Push((m, s) => actor.HandleMessage(m, s)); } actor.PreStart(); var isFirstStart = recreateCause == null; if (_system.Settings.DebugLifecycle) { Publish(new DebugLogEvent(_path.ToString(), SafeGetTypeForLogging(actor), isFirstStart ? "Started (" + actor + ")" : "Restarted (" + actor + ") due to " + ExceptionFormatter.DebugFormat(recreateCause))); } if (isFirstStart) { actor.PreFirstStart(); } else { actor.PostRestart(recreateCause); } return(actor); } catch (Exception ex) { throw new CreateActorFailedException(this, "An error occured while creating the actor. See inner exception", ex); } }
public override void OnApply(ActorStatus status) { float hp = status.ReadStatus.HP; if(GetComponent<NetSyncObj>().mode == SFSNetworkManager.Mode.LOCAL){ if(hp <= 0f && !startDeathTimer){ startDeathTimer = true; } if(hp > 0f && startDeathTimer){ startDeathTimer = false; deathTimer = 0f; } if(revive){ revive = false; status.WriteStatus().BaseHP = 1; ragdollTurner.UnturnRagdoll(); } } else{ if(lastFrameHP <= 0 && hp > 0){ Debug.Log ("unturn ragdoll"); ragdollTurner.UnturnRagdoll(); } } }
public DeviceConnectionActor( ILogger logger, IActorsLogger actorLogger, CredentialsSetup credentialsSetupLogic, FetchFromRegistry fetchFromRegistryLogic, Register registerLogic, Connect connectLogic, Deregister deregisterLogic, Disconnect disconnectLogic, IInstance instance) { this.log = logger; this.actorLogger = actorLogger; this.credentialsSetupLogic = credentialsSetupLogic; this.fetchFromRegistryLogic = fetchFromRegistryLogic; this.registerLogic = registerLogic; this.connectLogic = connectLogic; this.deregisterLogic = deregisterLogic; this.disconnectLogic = disconnectLogic; this.instance = instance; this.Message = null; this.Client = null; this.Device = null; this.status = ActorStatus.None; this.deviceModel = null; this.deviceId = null; this.deviceStateActor = null; this.failedDeviceConnectionsCount = 0; this.failedRegistrationsCount = 0; this.failedFetchCount = 0; }
/// <summary> /// Invoke this method before calling Execute(), to initialize the actor /// with details like the device id. SetupAsync() should be called only once. /// </summary> public void Setup( string deviceId, IDeviceStateActor deviceStateActor, IDeviceConnectionActor deviceConnectionActor, PropertiesLoopSettings loopSettings) { if (this.status != ActorStatus.None) { this.log.Error("The actor is already initialized", () => new { CurrentDeviceId = this.deviceId }); throw new DeviceActorAlreadyInitializedException(); } this.deviceId = deviceId; this.deviceStateActor = deviceStateActor; this.deviceConnectionActor = deviceConnectionActor; this.loopSettings = loopSettings; this.updatePropertiesLogic.Init(this, this.deviceId); this.deviceSetDeviceTagLogic.Init(this, this.deviceId); this.actorLogger.Init(deviceId, "Properties"); this.status = ActorStatus.ReadyToStart; }
/// <summary> /// Invoke this method before calling Execute(), to initialize the actor /// with details like the device model and message type to simulate. /// </summary> public void Init( ISimulationContext simulationContext, string deviceId, DeviceModel deviceModel, DeviceModel.DeviceModelMessage message, IDeviceStateActor deviceStateActor, IDeviceConnectionActor context) { this.instance.InitOnce(); this.simulationContext = simulationContext; this.deviceModel = deviceModel; this.Message = message; this.deviceId = deviceId; this.deviceStateActor = deviceStateActor; this.deviceContext = context; this.sendTelemetryLogic.Init(this, this.deviceId, this.deviceModel); this.actorLogger.Init(deviceId, "Telemetry"); this.status = ActorStatus.ReadyToStart; this.instance.InitComplete(); }
public override void OnApply(ActorStatus status) { status.WriteStatus().SetMotionModifier(0, motion); Debug.Log ("apply motion: " + motion); }
/// <summary>アクターのステータスをチェックし、処理をおこなう。</summary> public virtual void CheckStatus() { if (this.status != this.StatusNextFrame) this.status = this.StatusNextFrame; //@e Set dead flags for all the children if the player is dead. //@j 自分が死亡していたら、子すべてに死亡フラグを立てる。 if( this.Status == ActorStatus.Dead) { foreach(Actor actorChild in children) { actorChild.Status = ActorStatus.Dead; } } //@e Visit children with recursive call. //@j 再帰処理で子を巡回していく。 foreach(Actor actorChild in children) { actorChild.CheckStatus(); } //@j 死亡フラグのたっている子をリストから削除。 //@e Delete a child where the dead flag is set from a list. children.RemoveAll(CheckDeadActor); }
public void HandleEvent(ActorEvents e) { switch (e) { case ActorEvents.Started: if (this.loopSettings.SchedulableFetches <= 0) { return; } this.loopSettings.SchedulableFetches--; this.actorLogger.ActorStarted(); this.ScheduleCredentialsSetup(); break; case ActorEvents.FetchFailed: if (this.loopSettings.SchedulableFetches <= 0) { return; } this.loopSettings.SchedulableFetches--; this.failedFetchCount++; this.actorLogger.DeviceFetchFailed(); this.ScheduleFetch(); break; case ActorEvents.DeviceNotFound: if (this.loopSettings.SchedulableRegistrations <= 0) { return; } this.loopSettings.SchedulableRegistrations--; this.actorLogger.DeviceNotFound(); this.ScheduleRegistration(); break; case ActorEvents.DeviceRegistered: this.simulationContext.RateLimiting.DeviceQuotaNotExceeded(); this.actorLogger.DeviceRegistered(); this.ScheduleConnection(); break; case ActorEvents.RegistrationFailed: if (this.loopSettings.SchedulableRegistrations <= 0) { return; } this.loopSettings.SchedulableRegistrations--; this.failedRegistrationsCount++; this.actorLogger.DeviceRegistrationFailed(); this.ScheduleRegistration(); break; case ActorEvents.CredentialsSetupCompleted: this.actorLogger.DeviceCredentialsReady(); this.ScheduleConnection(); break; case ActorEvents.FetchCompleted: this.actorLogger.DeviceFetched(); this.ScheduleConnection(); break; case ActorEvents.AuthFailed: this.actorLogger.DeviceConnectionAuthFailed(); this.ScheduleFetch(); break; case ActorEvents.ConnectionFailed: this.failedDeviceConnectionsCount++; this.actorLogger.DeviceConnectionFailed(); this.ScheduleConnection(); break; case ActorEvents.Connected: this.actorLogger.DeviceConnected(); this.status = ActorStatus.Done; break; case ActorEvents.Disconnected: this.actorLogger.DeviceDisconnected(); // TODO: this works for the time being, but disconnection should not always lead to a deregistration // e.g. there are simulation scenarios where the device might just need to disconnect this.ScheduleDeregistration(); break; case ActorEvents.DisconnectionFailed: this.actorLogger.DeviceDisconnectionFailed(); this.ScheduleDisconnection(); break; case ActorEvents.DeviceDeregistered: this.actorLogger.DeviceDeregistered(); this.status = ActorStatus.Deleted; break; case ActorEvents.DeregisterationFailed: this.actorLogger.DeviceDeregistrationFailed(); this.ScheduleDeregistration(); break; case ActorEvents.TelemetryClientBroken: case ActorEvents.PropertiesClientBroken: // Change the status asap, so the client results disconnected // to other actors - see the 'Connected' property - to avoid // hub traffic from starting right now this.status = ActorStatus.None; this.DisposeClient(); this.ScheduleConnection(); break; case ActorEvents.DeviceQuotaExceeded: this.simulationContext.RateLimiting.DeviceQuotaExceeded(); this.actorLogger.DeviceQuotaExceeded(); this.PauseForDeviceQuotaExceeded(); break; default: throw new ArgumentOutOfRangeException(nameof(e), e, null); } }
public async Task RunAsync() { this.instance.InitRequired(); this.log.Debug(this.status.ToString(), () => new { this.deviceId }); switch (this.status) { case ActorStatus.ReadyToStart: this.whenToRun = 0; this.HandleEvent(ActorEvents.Started); return; case ActorStatus.WaitingForDeviceQuota: this.status = ActorStatus.ReadyToStart; this.HandleEvent(ActorEvents.Started); break; case ActorStatus.ReadyToSetupCredentials: this.status = ActorStatus.PreparingCredentials; this.actorLogger.PreparingDeviceCredentials(); await this.credentialsSetupLogic.RunAsync(); return; case ActorStatus.ReadyToFetch: this.status = ActorStatus.Fetching; this.actorLogger.FetchingDevice(); await this.fetchFromRegistryLogic.RunAsync(); return; case ActorStatus.ReadyToRegister: this.status = ActorStatus.Registering; this.actorLogger.RegisteringDevice(); await this.registerLogic.RunAsync(); return; case ActorStatus.ReadyToConnect: this.status = ActorStatus.Connecting; this.actorLogger.ConnectingDevice(); await this.connectLogic.RunAsync(); return; case ActorStatus.ReadyToDeregister: this.status = ActorStatus.Deregistering; this.actorLogger.DeregisteringDevice(); await this.deregisterLogic.RunAsync(); return; case ActorStatus.ReadyToDisconnect: this.status = ActorStatus.Disconnecting; this.actorLogger.DisconnectingDevice(); await this.disconnectLogic.RunAsync(); return; } }
protected override void OnStart() { base.OnStart(); _targetStatus = GameManager.Instance.Player.AStatus; }
private void CreateActorInstanceDueToFailure(Exception cause) { Debug.Assert(_mailbox.IsSuspended, "Mailbox must be suspended during restart, status=" + (_mailbox is MailboxBase ? (_mailbox as MailboxBase).GetMailboxStatusForDebug() : "unknown")); Debug.Assert(_failPerpatrator == this, "Perpetrator should be this instance"); //Stop all children Children.GetChildrenRefs().ForEach(c => c.Stop()); //If we have children we must wait for, then set status to creating, so we know what to do when all children have terminated var weHaveChildrenWeMustWaitFor = InterlockedSpin.ConditionallySwap(ref _actorStatus, _ => Children.HasChildrenThatAreTerminating(), ActorStatus.Creating(cause)); if (!weHaveChildrenWeMustWaitFor) { FinishCreateActorInstanceDueToFailure(cause); } }
/// <summary> /// Checks if AI/Human Resistance player/actor captured by an Erasure team at the node (must have invisibility 1 or less). Returns null if not. /// parameters vary if an 'APB' or a 'SecurityAlert' in play /// ActorID is default '999' for player /// </summary> /// <param name="node"></param> /// <returns></returns> public CaptureDetails CheckCaptured(int nodeID, int actorID = 999) { CaptureDetails details = null; Node node = GameManager.i.dataScript.GetNode(nodeID); Team team = null; if (node != null) { //get correct player status depending on who is in charge of Resistance ActorStatus status = ActorStatus.Active; if (GameManager.i.sideScript.resistanceOverall == SideState.Human) { status = GameManager.i.playerScript.status; } else { status = GameManager.i.aiRebelScript.status; } //correct state if (status == ActorStatus.Active) { //Player if (actorID == GameManager.i.playerScript.actorID) { //check player at node if (nodeID == GameManager.i.nodeScript.GetPlayerNodeID()) { //Erasure team picks up player/actor immediately if invisibility low enough if (CheckCaptureVisibility(GameManager.i.playerScript.Invisibility) == true) { int teamID = node.CheckTeamPresent(teamErasureID); if (teamID > -1) { team = GameManager.i.dataScript.GetTeam(teamID); if (team != null) { //Player Captured details = new CaptureDetails { node = node, team = team, actor = null }; Debug.LogFormat("[Ply] CaptureManager.cs -> CheckCaptured: Resistance Player is captured by an Erasure team at {0}, {1}, id {2}{3}", node.nodeName, node.Arc.name, node.nodeID, "\n"); //history GameManager.i.dataScript.AddHistoryPlayer(new HistoryActor() { text = "CAPTURED by an Erasure Team", district = node.nodeName }); } else { Debug.LogError(string.Format("Invalid team (Null) for teamID {0}", teamID)); } } //Security Alert -> check if an Erasure team is in a neighbouring node if (GameManager.i.turnScript.authoritySecurityState == AuthoritySecurityState.SecurityAlert) { team = CheckCaptureAlert(node); if (team != null) { //Player Captured details = new CaptureDetails { node = node, team = team, actor = null }; Debug.LogFormat("[Ply] CaptureManager.cs -> CheckCaptured: Resistance Player is captured by an Erasure team at {0}, {1}, id {2}{3}", node.nodeName, node.Arc.name, node.nodeID, "\n"); //history GameManager.i.dataScript.AddHistoryPlayer(new HistoryActor() { text = "CAPTURED by an Erasure Team", district = node.nodeName }); } } } } else { Debug.LogError(string.Format("Player not at the nodeID {0}", nodeID)); } } else { //Actor Actor actor = GameManager.i.dataScript.GetActor(actorID); if (actor != null) { //Erasure team picks up player/actor immediately if invisibility 0 if (CheckCaptureVisibility(actor.GetDatapoint(ActorDatapoint.Invisibility2)) == true) { int teamID = node.CheckTeamPresent(teamErasureID); if (teamID > -1) { team = GameManager.i.dataScript.GetTeam(teamID); if (team != null) { //Actor Captured details = new CaptureDetails { node = node, team = team, actor = actor }; Debug.LogFormat("[Ply] CaptureManager.cs -> CheckCaptured: {0}, {1}, is captured by an Erasure team at {2}, {3}, id {4}{5}", actor.actorName, actor.arc.name, node.nodeName, node.Arc.name, node.nodeID, "\n"); } else { Debug.LogError(string.Format("Invalid team (Null) for teamID {0}", teamID)); } } //Security Alert -> Check if an Erasure team is in a neighbouring node if (GameManager.i.turnScript.authoritySecurityState == AuthoritySecurityState.SecurityAlert) { team = CheckCaptureAlert(node); if (team != null) { //Actor Captured details = new CaptureDetails { node = node, team = team, actor = actor }; Debug.LogFormat("[Ply] CaptureManager.cs -> CheckCaptured: {0}, {1}, is captured by an Erasure team at {2}, {3}, id {4}{5}", actor.actorName, actor.arc.name, node.nodeName, node.Arc.name, node.nodeID, "\n"); } } } } else { Debug.LogError(string.Format("Invalid actor (Null) for actorID {0}", actorID)); } } } } else { Debug.LogError(string.Format("Invalid node (Null) for nodeID {0}", nodeID)); } //return CaptureDetails return(details); }
public void Attack() { // Not implemented Status = ActorStatus.Attacking; }
private void RecreateActor(Exception cause) { if (_actor == null) { //The actor has not yet been created. We can use a simpler approach Publish(new DebugLogEvent(_path.ToString(), SafeGetTypeForLogging(), "Changing recreate into Create after " + cause)); CreateActorInstanceDueToFailure(cause); } else if (_actorStatus.IsNotCreatingRecreatingOrTerminating) { var failedActor = _actor; if (failedActor != null) { //TODO: Stash optional message object optionalMessage = null; ActorRef optionalSender = null; if (_currentMessage != null) { optionalMessage = _currentMessage.Message; optionalSender = _currentMessage.Sender; } try { try { failedActor.PreRestart(cause, optionalMessage, optionalSender); } catch (Exception e) { Publish(new ErrorLogEvent(_path.ToString(), SafeGetTypeForLogging(failedActor), "Exception thrown during actor.PreRestart()", e)); } } finally { ClearActor(failedActor); } Debug.Assert(_mailbox.IsSuspended, "Mailbox must be suspended during restart, status=" + (_mailbox is MailboxBase ? (_mailbox as MailboxBase).GetMailboxStatusForDebug() : "unknown")); //If we have children we must wait for, then set status to recreating, so we know what to do when all children have terminated var weHaveChildrenWeMustWaitFor = InterlockedSpin.ConditionallySwap(ref _actorStatus, _ => Children.HasChildrenThatAreTerminating(), _ => ActorStatus.Recreating(cause)); if (!weHaveChildrenWeMustWaitFor) { //No children we must wait for. Continue with recreating FinishRecreateActor(failedActor, cause); } } } else { ResumeActor(null); } }
static ActorStatus() { _NormalInstance = new ActorStatus(); _TerminatingInstance = new ActorStatus(); }
public override void OnAttach(ActorStatus _status) { // Debug.Log("OnAttach"); status = _status; }
private void Awake() { _planetLayer = LayerMask.GetMask("Planets"); _actorStatus = GetComponent <ActorStatus>(); }
public async Task RunAsync() { this.log.Debug(this.status.ToString(), () => new { this.deviceId }); var now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); if (now < this.whenToRun) { return; } switch (this.status) { case ActorStatus.ReadyToStart: this.whenToRun = 0; this.HandleEvent(ActorEvents.Started); return; case ActorStatus.ReadyToSetupCredentials: this.status = ActorStatus.PreparingCredentials; this.actorLogger.PreparingDeviceCredentials(); await this.credentialsSetupLogic.RunAsync(); return; case ActorStatus.ReadyToFetch: this.status = ActorStatus.Fetching; this.actorLogger.FetchingDevice(); await this.fetchFromRegistryLogic.RunAsync(); return; case ActorStatus.ReadyToRegister: this.status = ActorStatus.Registering; this.actorLogger.RegisteringDevice(); await this.registerLogic.RunAsync(); return; case ActorStatus.ReadyToConnect: this.status = ActorStatus.Connecting; this.actorLogger.ConnectingDevice(); await this.connectLogic.RunAsync(); return; case ActorStatus.ReadyToDeregister: this.status = ActorStatus.Deregistering; this.actorLogger.DeregisteringDevice(); await this.deregisterLogic.RunAsync(); return; case ActorStatus.ReadyToDisconnect: this.status = ActorStatus.Disconnecting; this.actorLogger.DisconnectingDevice(); await this.disconnectLogic.RunAsync(); return; } }
public void Update(double timeElapsed) { // Partially implemented Status = ActorStatus.Idle; }
public void HandleEvent(ActorEvents e) { switch (e) { case ActorEvents.Started: if (this.loopSettings.SchedulableFetches <= 0) { return; } this.loopSettings.SchedulableFetches--; this.actorLogger.ActorStarted(); this.ScheduleCredentialsSetup(); break; case ActorEvents.FetchFailed: if (this.loopSettings.SchedulableFetches <= 0) { return; } this.loopSettings.SchedulableFetches--; this.failedFetchCount++; this.actorLogger.DeviceFetchFailed(); this.ScheduleFetch(); break; case ActorEvents.DeviceNotFound: if (this.loopSettings.SchedulableRegistrations <= 0) { return; } this.loopSettings.SchedulableRegistrations--; this.actorLogger.DeviceNotFound(); this.ScheduleRegistration(); break; case ActorEvents.DeviceRegistered: this.actorLogger.DeviceRegistered(); this.ScheduleConnection(); break; case ActorEvents.RegistrationFailed: if (this.loopSettings.SchedulableRegistrations <= 0) { return; } this.loopSettings.SchedulableRegistrations--; this.failedRegistrationsCount++; this.actorLogger.DeviceRegistrationFailed(); this.ScheduleRegistration(); break; case ActorEvents.CredentialsSetupCompleted: this.actorLogger.DeviceCredentialsReady(); this.ScheduleConnection(); break; case ActorEvents.FetchCompleted: this.actorLogger.DeviceFetched(); this.ScheduleConnection(); break; case ActorEvents.AuthFailed: this.actorLogger.DeviceConnectionAuthFailed(); this.ScheduleFetch(); break; case ActorEvents.ConnectionFailed: this.failedDeviceConnectionsCount++; this.actorLogger.DeviceConnectionFailed(); this.ScheduleConnection(); break; case ActorEvents.Connected: this.actorLogger.DeviceConnected(); this.status = ActorStatus.Done; break; case ActorEvents.Disconnected: this.actorLogger.DeviceDisconnected(); // TODO: this works for the time being, but disconnection should not always lead to a deregistration // e.g. there are simulation scenarios where the device might just need to disconnect this.ScheduleDeregistration(); break; case ActorEvents.DisconnectionFailed: this.actorLogger.DeviceDisconnectionFailed(); this.ScheduleDisconnection(); break; case ActorEvents.DeviceDeregistered: this.actorLogger.DeviceDeregistered(); this.status = ActorStatus.Deleted; break; case ActorEvents.DeregisterationFailed: this.actorLogger.DeviceDeregistrationFailed(); this.ScheduleDeregistration(); break; case ActorEvents.TelemetryClientBroken: this.Client?.DisconnectAsync(); this.Client = null; this.ScheduleConnection(); break; default: throw new ArgumentOutOfRangeException(nameof(e), e, null); } }
public virtual void OnDetach(ActorStatus status) { }
public void Stop() { this.status = ActorStatus.Stopped; }
public void HandleEvent(ActorEvents e) { switch (e) { case ActorEvents.Started: if (this.loopSettings.SchedulableFetches <= 0) { return; } this.loopSettings.SchedulableFetches--; this.actorLogger.ActorStarted(); this.ScheduleFetch(); break; case ActorEvents.FetchFailed: if (this.loopSettings.SchedulableFetches <= 0) { return; } this.loopSettings.SchedulableFetches--; this.failedFetchCount++; this.actorLogger.DeviceFetchFailed(); this.ScheduleFetch(); break; case ActorEvents.DeviceNotFound: if (this.loopSettings.SchedulableRegistrations <= 0) { return; } this.loopSettings.SchedulableRegistrations--; this.actorLogger.DeviceNotFound(); this.ScheduleRegistration(); break; case ActorEvents.DeviceRegistered: this.actorLogger.DeviceRegistered(); this.ScheduleConnection(); break; case ActorEvents.RegistrationFailed: if (this.loopSettings.SchedulableRegistrations <= 0) { return; } this.loopSettings.SchedulableRegistrations--; this.failedRegistrationsCount++; this.actorLogger.DeviceRegistrationFailed(); this.ScheduleRegistration(); break; case ActorEvents.FetchCompleted: this.actorLogger.DeviceFetched(); this.ScheduleConnection(); break; case ActorEvents.ConnectionFailed: this.failedDeviceConnectionsCount++; this.actorLogger.DeviceConnectionFailed(); this.ScheduleConnection(); break; case ActorEvents.Connected: this.actorLogger.DeviceConnected(); this.status = ActorStatus.Done; break; default: throw new ArgumentOutOfRangeException(nameof(e), e, null); } }
private void Reset() { this.status = ActorStatus.ReadyToStart; }
public virtual void OnApply(ActorStatus status) { }