public OmniEve() { _lastPulse = DateTime.UtcNow; _state = OmniEveState.Idle; if (Cache.Instance.DirectEve == null) { Logging.Log("OmniEve:OmniEve", "Error on Loading DirectEve, maybe server is down", Logging.Orange); return; } try { // // setup the [ Cache.Instance.DirectEve.OnFrame ] Event triggered on every new frame to call EVEOnFrame() // Cache.Instance.DirectEve.OnFrame += EVEOnFrame; } catch (Exception ex) { Logging.Log("OmniEve:OmniEve", string.Format("DirectEVE.OnFrame: Exception {0}...", ex), Logging.White); } }
private void EVEOnFrame(object sender, EventArgs e) { try { if (!OnFrameValidate()) { return; } //Logging.Log("OmniEve", "OnFrame: this is OmniEve.cs [" + DateTime.UtcNow + "] by default the next InSpace pulse will be in [" + Time.Instance.OmniEvePulseInSpace_milliseconds + "]milliseconds", Logging.Teal); /*if (DateTime.UtcNow < _nextOmniEveAction) * { * Time.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; * Logging.Log("OmniEve:EVEOnFrame", "Logging last known good connection " + Time.Instance.LastKnownGoodConnectedTime, Logging.Teal); * }*/ // When in warp there's nothing we can do, so ignore everything if (Status.Instance.InSpace && Status.Instance.InWarp) { Logging.Log("OmniEve:EVEOnFrame", "We are in space and in warp, we can't do anything, skipping frame", Logging.Teal); return; } switch (_state) { case OmniEveState.Idle: if (_actions.Count > 0) { Logging.Log("OmniEve:EVEOnFrame", "Action entered queue going to NextAction state", Logging.Teal); _state = OmniEveState.NextAction; } break; case OmniEveState.Cleanup: // Remove the eve frame and move to the close frame Cache.Instance.DirectEve.Dispose(); _state = OmniEveState.CloseOmniEve; Cache.Instance.DirectEve.OnFrame -= EVEOnFrame; break; case OmniEveState.NextAction: if (_actions.Count > 0) { lock (_actions) _currentAction = _actions.Dequeue(); } if (_currentAction != null) { Logging.Log("OmniEve:EVEOnFrame", "Popping next action off the queue", Logging.Teal); _state = OmniEveState.InitAction; } else { _state = OmniEveState.Idle; } break; case OmniEveState.InitAction: if (_currentAction != null) { Logging.Log("OmniEve:EVEOnFrame", "Initializing current action", Logging.Teal); _currentAction.Initialize(); _state = OmniEveState.ProcessAction; } break; case OmniEveState.ProcessAction: if (_currentAction != null) { _currentAction.Process(); // If the current action is now done we can stop processing and go back to the idle state if (_currentAction.IsDone()) { Logging.Log("OmniEve:EVEOnFrame", "Current action is done, going back to idle state", Logging.Teal); _state = OmniEveState.Idle; _currentAction = null; } } break; case OmniEveState.CloseOmniEve: break; case OmniEveState.Error: break; } } catch (Exception ex) { Logging.Log("OmniEve:EVEOnFrame", "Exception [" + ex + "]", Logging.Debug); } }
private void EVEOnFrame(object sender, EventArgs e) { try { if (!OnFrameValidate()) return; //Logging.Log("OmniEve", "OnFrame: this is OmniEve.cs [" + DateTime.UtcNow + "] by default the next InSpace pulse will be in [" + Time.Instance.OmniEvePulseInSpace_milliseconds + "]milliseconds", Logging.Teal); /*if (DateTime.UtcNow < _nextOmniEveAction) { Time.Instance.LastKnownGoodConnectedTime = DateTime.UtcNow; Logging.Log("OmniEve:EVEOnFrame", "Logging last known good connection " + Time.Instance.LastKnownGoodConnectedTime, Logging.Teal); }*/ // When in warp there's nothing we can do, so ignore everything if (Status.Instance.InSpace && Status.Instance.InWarp) { Logging.Log("OmniEve:EVEOnFrame", "We are in space and in warp, we can't do anything, skipping frame", Logging.Teal); return; } switch (_state) { case OmniEveState.Idle: if (_actions.Count > 0) { Logging.Log("OmniEve:EVEOnFrame", "Action entered queue going to NextAction state", Logging.Teal); _state = OmniEveState.NextAction; } break; case OmniEveState.Cleanup: // Remove the eve frame and move to the close frame Cache.Instance.DirectEve.Dispose(); _state = OmniEveState.CloseOmniEve; Cache.Instance.DirectEve.OnFrame -= EVEOnFrame; break; case OmniEveState.NextAction: if (_actions.Count > 0) { lock(_actions) _currentAction = _actions.Dequeue(); } if (_currentAction != null) { Logging.Log("OmniEve:EVEOnFrame", "Popping next action off the queue", Logging.Teal); _state = OmniEveState.InitAction; } else { _state = OmniEveState.Idle; } break; case OmniEveState.InitAction: if (_currentAction != null) { Logging.Log("OmniEve:EVEOnFrame", "Initializing current action", Logging.Teal); _currentAction.Initialize(); _state = OmniEveState.ProcessAction; } break; case OmniEveState.ProcessAction: if (_currentAction != null) { _currentAction.Process(); // If the current action is now done we can stop processing and go back to the idle state if (_currentAction.IsDone()) { Logging.Log("OmniEve:EVEOnFrame", "Current action is done, going back to idle state", Logging.Teal); _state = OmniEveState.Idle; _currentAction = null; } } break; case OmniEveState.CloseOmniEve: break; case OmniEveState.Error: break; } } catch(Exception ex) { Logging.Log("OmniEve:EVEOnFrame", "Exception [" + ex + "]", Logging.Debug); } }