public void Run() { OnExecuting?.Invoke(this, new SimulatorEventArgs(_args)); foreach (var battery in _args.Batteries) { Discharge(battery, _args.GetDischargeCurrent(battery.Uid), _args.CycleDuration); } Executed?.Invoke(this, new SimulatorEventArgs(_args)); }
public void Run() { OnExecuting?.Invoke(this, new SimulatorEventArgs(_args)); if (!_args.NetworkOutdated) { return; } CalculateDistances(); CalculateOrientations(); _args.NetworkOutdated = false; Executed?.Invoke(this, new SimulatorEventArgs(_args)); }
protected void ExecuteCore() { OnExecuting?.Invoke(); try { HandleExecuteCore(); } catch (Exception ex) { OnExecutionError?.Invoke(ex); throw; } finally { OnExecuted?.Invoke(); } }
public void TryExecute(object state) { if (_suspended) { return; } try { OnExecuting?.Invoke(); _executedTimes++; if ((StopCondition != null && !StopCondition.Compile().Invoke()) || (ExecuteTimes != 0 && ExecuteTimes < _executedTimes)) { return; } _timer.Dispose(); SchedulerState = SchedulerState.Finished; } catch (Exception ex) { ExecuteResult = new ExecuteResult(ex); SchedulerState = SchedulerState.Filed; } }
public void Run() { OnExecuting?.Invoke(this, new SimulatorEventArgs(_args)); var tx = new Vertex(); float a = _args.AttenuationExponent; float c = GetFriisConstant(_args.TxWavelength); _args.RxValues = new float[_args.RadioBox.TotalData]; /* * - parallelize the loop * - make a wrapper object to get the Index and the rx position vector 'Rx' * - calculate the adapted friis transmission and save it in the corresponding RxValues[d.Index] */ _args.RxPositions .AsParallel() .Select((rx, i) => new { Index = i, Rx = rx }) .ForAll(d => _args.RxValues[d.Index] = GetAdaptedFriisAttenuation(c, Vertex.GetLength(tx, d.Rx), a)); // log finished process Executed?.Invoke(this, new SimulatorEventArgs(_args)); _log.Trace($"{_args.Name} calculated {_args.RadioBox.TotalData} values."); }
/// <summary> /// The method shall be called in the Run method before the run of the concrete simulator /// </summary> protected virtual void BeforeExecution() { _log.Trace($"Start executing {this.Arguments.Name}"); OnExecuting?.Invoke(this, new SimulatorEventArgs(this.Arguments)); }