/// <summary> /// return true if ta is before tb (eveluates (ta less than tb) /// </summary> /// <param name="ta">Time ta</param> /// <param name="tb">time tb</param> /// <returns>true if ta is before tb (eveluates (ta less than tb)</returns> public static bool IsBefore(ITime ta, ITime tb) { double a; double b; bool isTaBeforeTb; if (ta is ITimeSpan) { a = ((ITimeSpan) ta).End.ModifiedJulianDay; } else { a = ((ITimeStamp) ta).ModifiedJulianDay; } if (tb is ITimeSpan) { b = ((ITimeSpan) tb).Start.ModifiedJulianDay; } else { b = ((ITimeStamp) tb).ModifiedJulianDay; } isTaBeforeTb = (a < b); return isTaBeforeTb; }
public HttpClient(IConnectionManager connectionManager, IWebRequest webRequest, IReynaLogger logger, ITime time) { this.ConnectionManager = connectionManager; _webRequest = webRequest; _logger = logger; _time = time; }
public ScreenBlock(ITime time) { InitializeComponent(); Icon = Properties.Resources.Sleeping_2; _time = time; _lastValue = 5; debug.DataBindings.Add("Text", this, "Debug"); }
public Time(ITime time) : this() { if(time != null) { _Time = time; _Request.Reset(); _Time.GetTick().OnValue += _Timing; } }
public EnemyDeathEngine(IEntityFunctions entityFunctions, IEntityStreamConsumerFactory consumerFactory, ITime time, WaitForSubmissionEnumerator waitForSubmission) { _entityFunctions = entityFunctions; _consumerFactory = consumerFactory; _time = time; _waitForSubmission = waitForSubmission; _animations = new FasterList <IEnumerator>(); _consumer = _consumerFactory.GenerateConsumer <DeathComponent>( ECSGroups.EnemiesGroup, "EnemyDeathEngine", 10); }
public static IList <SalesReportViewModel> GetAllByFeature(IUnitOfWork db, ITime time, FilterPeriod period, int featureId) { DateTime fromDate = GetFromPeriod(time, period); var items = db.SalesReports.GetSalesByFeatureReport(fromDate, featureId); return(items.Select(i => new SalesReportViewModel(i)).ToList()); }
public ITime NextClock(ITime currentClock) { switch (currentClock) { case StandardTime t1: return(new MetricTime()); case MetricTime t2: return(new BinaryTime(14)); default: return(new StandardTime()); } }
public override IValueSet GetValues(ITime time, string linkID) { int timesCount = ((SmartOutputLink)this.SmartOutputLinks[0]).SmartBuffer.TimesCount; if (timesCount > _maxBufferSize) { _maxBufferSize = timesCount; } return(base.GetValues(time, linkID)); }
public static TimeChooserDialog GetInstance(ITime initialTime) { if (_singleton == null) { _singleton = new TimeChooserDialog(); } _singleton.Clock.DisplayMode = ClockDisplayMode.Hours; _singleton.Clock.Time = new DateTime(1, 1, 1, initialTime.Hour, initialTime.Minute, 0); _singleton._previousChosenTime = initialTime; return(_singleton); }
public void Setup() { var dbFactory = new DbFactory(); _time = new TimeService(dbFactory); _log = LogFactory.Console; _apiKey = "ck_075cade343b3655bf41c8f8c8f04ffb210b81016"; _apiSecret = "cs_33fa9ebd809013bc5aa8a62b5d13534ec22ca0cb"; _endPoint = "http://www.cibortv.com/wp-json/wc/v3/"; }
private void SendSourceAfterGetValuesCallEvent(ITime time, string LinkID) { Oatc.OpenMI.Sdk.Backbone.Event eventA = new Oatc.OpenMI.Sdk.Backbone.Event(EventType.SourceAfterGetValuesCall); eventA.Description = "GetValues(t = " + ITimeToString(time) + ", "; eventA.Description += "LinkID: " + LinkID; //TODO: QS = " + _smartOutputLinkSet.GetLink(LinkID).SourceQuantity.ID + " ,QT = " + _smartOutputLinkSet.GetLink(LinkID).TargetQuantity.ID; eventA.Description += ") <<<==="; eventA.Sender = this; eventA.SimulationTime = TimeToTimeStamp(_engineApiAccess.GetCurrentTime()); eventA.SetAttribute("GetValues time argument : ", ITimeToString(time)); SendEvent(eventA); }
public static ServerClient CreateClient( SendMappings sendMappings, NetConnection connection, ITime engineTime, NetworkObjectListTransmitter objectListTransmitter, int index, int userId, string name) { return(new ServerClient(sendMappings, connection, engineTime, objectListTransmitter, index, userId, name)); }
private int GetColumnIndex(ITime startTime) { var result = 0; result = (startTime.Hour - Global.Constant.MinTime) * 2; if (startTime.Minute == 30) { result++; } return(result); }
private ICommandDispatcher CommandDispatcherFactory(ITime time = null) { if (time == null) { time = Substitute.For <ITime>(); } var commandDispatcher = Substitute.For <ICommandDispatcher>(); RegisterObjectStore(commandDispatcher, time); return(commandDispatcher); }
public void Update(ITime engineTime, float deltaSeconds) { LightStyles.AnimateLights(engineTime); VectorUtils.AngleToVectors(Angles, out _viewAngles); foreach (IUpdateable updateable in _updateables) { updateable.Update(deltaSeconds); } }
private int GetColumnIndex(ITime startTime) { var result = 0; result = (startTime.Hour - _minTime) * 2 + 1; if (startTime.Minute == 30) { result++; } return(result); }
public DogfeedService( IProvisioningService provisioningService, IMediator mediator, ILogger logger, ITime time) { this.provisioningService = provisioningService; this.mediator = mediator; this.logger = logger; this.time = time; }
public override void Process(IMarketApi api, ITime time, AmazonReportInfo reportInfo, IList <IReportItemDTO> reportItems) { using (var uow = new UnitOfWork(Log)) { var items = reportItems.Cast <ItemExDTO>().ToList(); Log.Debug("Begin process items"); ProcessItems(uow, items, api.Market, api.MarketplaceId); Log.Debug("End process items"); } }
public override IValueSet GetValues(ITime time, string linkID) { int timesCount = ((SmartOutputLink)this.SmartOutputLinks[0]).SmartBuffer.TimesCount; if (timesCount > _maxBufferSize) { _maxBufferSize = timesCount; } return base.GetValues(time, linkID); }
public ITime Add(ITime other) { var finalMinutes = Minute + other.Minute; var finalHour = Hour + other.Hour; if (finalMinutes > 59) { finalHour++; finalMinutes %= 60; } return(CreateTime_24HourFormat(finalHour, finalMinutes)); }
public bool Equals(ITime other) { if (Hour != other.Hour) { return(false); } if (Minute != other.Minute) { return(false); } return(true); }
public CallAddressProcessing( ILogService log, ITime time, IDbFactory dbFactory, CompanyDTO company) { _log = log; _company = company; _time = time; _dbFactory = dbFactory; _htmlScraper = new HtmlScraperService(log, time, dbFactory); }
public void SetUp() { _time = Substitute.For <ITime>(); _time.UtcNow().Returns(DateTime.UtcNow); _employeeService = new EmployeeService( _time, _employeeRepository, _zoneRepository, _payrollRepository, _liquidationDocumentRepository); }
public BaseOrderRefundService(IRefundApi api, ISystemActionService actionService, IEmailService emailService, ILogService log, ITime time) { _api = api; _log = log; _time = time; _actionService = actionService; _emailService = emailService; }
public UndeliverableAsAddressedTrackingRule(ILogService log, ISystemActionService actionService, IAddressService addressService, IEmailService emailService, ITime time) { _actionService = actionService; _addressService = addressService; _emailService = emailService; _log = log; _time = time; }
public RainfallMeasurementsTimeSet(int measurementCount, double startTimeAsMJD, double endTimeAsMJD) { _timeHorizon = new Time(startTimeAsMJD, endTimeAsMJD - startTimeAsMJD); double deltaT = (endTimeAsMJD - startTimeAsMJD) / (measurementCount - 1); _times = new List <ITime>(); for (int tStep = 0; tStep < measurementCount; tStep++) { ITime timeStamp = new Time(startTimeAsMJD + tStep * deltaT); _times.Add(timeStamp); } }
/// <summary> /// Class constructor. /// </summary> /// <param name="geometricProperty"></param> /// <param name="mappingResolver"></param> /// <param name="mainMatrix"></param> /// <param name="profileValidator"></param> /// <param name="time"></param> /// <param name="naturalFrequency"></param> public CalculateBeamVibration( IGeometricProperty <TProfile> geometricProperty, IMappingResolver mappingResolver, IBeamMainMatrix <TProfile> mainMatrix, IProfileValidator <TProfile> profileValidator, ITime time, INaturalFrequency naturalFrequency) : base(profileValidator, time, naturalFrequency, mainMatrix) { this._geometricProperty = geometricProperty; this._mappingResolver = mappingResolver; }
public PublicationRunnerActionBased(ILogService log, ITime time, IDbFactory dbFactory, ISystemActionService actionService, PublishingMode mode) { _log = log; _time = time; _dbFactory = dbFactory; _actionService = actionService; _mode = mode; }
public CancellationEmailRule(ILogService log, ITime time, IEmailService emailService, ISystemActionService systemAction, CompanyDTO company) { _log = log; _time = time; _systemAction = systemAction; _emailService = emailService; _company = company; }
public Bus(IServiceProvider serviceProvider , IBusSession sessionAccessor , ICommandsEventsStore commandsEventsStore , IMetricService metricService , ITime time) { ServiceProvider = serviceProvider; SessionAccessor = sessionAccessor; CommandsEventsStore = commandsEventsStore; MetricService = metricService; Time = time; }
public CallTrackingProcessing(ILogService log, IDbFactory dbFactory, IEmailService emailService, CompanyDTO company, ITime time) { _log = log; _dbFactory = dbFactory; _emailService = emailService; _company = company; _time = time; }
public Scene(WorldState worldState, EntitySystemMetaData entitySystemMetaData, IModelManager modelManager, ITime engineTime, ICommandContext commandContext) { _engineTime = engineTime ?? throw new ArgumentNullException(nameof(engineTime)); WorldState = worldState ?? throw new ArgumentNullException(nameof(worldState)); EntitySystemMetaData = entitySystemMetaData ?? throw new ArgumentNullException(nameof(entitySystemMetaData)); EntityCreator = new EntityCreator(this); Components = new ComponentSystem(this); Models = modelManager ?? throw new ArgumentNullException(nameof(modelManager)); Physics = new GamePhysics(WorldState.Logger, this, engineTime, Time, WorldState.MapInfo.Model, commandContext); Movement = new GameMovement(WorldState.Logger, this, engineTime, Time, Random, Physics, commandContext); }
public ServerEntities(ILogger logger, IServerEngine serverEngine, ITime engineTime, IEngineModels serverModels, GameServer gameServer) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _serverEngine = serverEngine ?? throw new ArgumentNullException(nameof(serverEngine)); _engineTime = engineTime ?? throw new ArgumentNullException(nameof(engineTime)); _serverModels = serverModels ?? throw new ArgumentNullException(nameof(serverModels)); _gameServer = gameServer ?? throw new ArgumentNullException(nameof(gameServer)); }
public BuildAmazonMultiListingExcel(IDbFactory dbFactory, ILogService log, ITime time, IMarketCategoryService categoryService, CompanyDTO company) { _dbFactory = dbFactory; _log = log; _time = time; _company = company; _categoryService = categoryService; }
public override ITimeSpaceValueSet GetValues(IBaseExchangeItem querySpecifier2) { CheckBuffer(); List <IList <double> > valuesList = new List <IList <double> >(); for (int i = 0; i < ((ITimeSpaceInput)Consumers[0]).TimeSet.Times.Count; i++) { ITime time = ((ITimeSpaceInput)Consumers[0]).TimeSet.Times[i]; valuesList.Add(_buffer.GetValues(time)); } return(new TimeSpaceValueSet <double>(valuesList)); }
public ElasticSearchDbLogger(ITime time) { _time = time; var host = Environment.GetEnvironmentVariable("ElasticSearchHost"); if (string.IsNullOrEmpty(host)) { throw new ConfigurationErrorsException(@"Please define an environment variable of ElasticSearchHost with the hostname of your ES server."); } _connection = new ElasticConnection(host); _serializer = new JsonNetSerializer(); }
public override bool DoValidation(ITime getValuesAt) { try { foreach (var v in _component.Validate()) ProcessValidateMessage(v); if (_component.Status == LinkableComponentStatus.Invalid) AddError = "Status == LinkableComponentStatus.Invalid"; int nProviders = _component.Inputs.Aggregate(0, (sum, o) => o.Provider == null ? sum : sum + 1); int nConsumers = _component.Outputs.Aggregate(0, (sum, o) => sum + o.Consumers.Count); AddDetail = string.Format("Provider count: {0}", nProviders); AddDetail = string.Format("Consumer count: {0}", nConsumers); if (_component is ITimeSpaceComponent) { if (getValuesAt == null) AddWarning = "Cannot validate TimeHorizon as composition time not provided"; else { var extent = ((ITimeSpaceComponent)_component).TimeExtent; if (double.IsInfinity(extent.TimeHorizon.StampAsModifiedJulianDay)) AddError = "Invalid/Unspecified TimeHorizon " + extent.TimeHorizon.ToString(); else { if (extent.TimeHorizon.StampAsModifiedJulianDay > getValuesAt.StampAsModifiedJulianDay) AddError = "Component time horizon does not start until after requested composition run time."; if (!double.IsInfinity(extent.TimeHorizon.DurationInDays)) { var end = extent.TimeHorizon.StampAsModifiedJulianDay + extent.TimeHorizon.DurationInDays; if (end < getValuesAt.StampAsModifiedJulianDay) AddWarning = "Time horizon ends before end of composition run time."; } } } } } catch (System.Exception e) { AddError = Sdk.Utilities.Xml.Persist(e).ToString(); } return _errors.Count == 0; }
public void RunParallel(ITime triggerTime, ParallelizeMode mode) { Event theEvent = new Event(EventType.Informative); theEvent.Description = "Parallel execution feature enabled, with " + mode + " mode."; _runListener.OnEvent(theEvent); switch (mode) { case ParallelizeMode.Standard: runStandardParallel(triggerTime); break; case ParallelizeMode.Aggressive: runAggressiveParallel(triggerTime); break; } }
public override bool DoValidation(ITime getValuesAt) { try { if (_adapter.Adaptee == null) AddError = "Source has Adaptee unspecified"; if (_adapter.Consumers.Count == 0 && _adapter.AdaptedOutputs.Count == 0) AddError = "Adapter unattached, has no consumers or adapters"; } catch (System.Exception e) { AddError = Sdk.Utilities.Xml.Persist(e).ToString(); } return _errors.Count == 0; }
public override bool DoValidation(ITime getValuesAt) { try { if (_source.Component != null) AddError = "Source has Component specified"; if (_source.Consumers.Count == 0 && _source.AdaptedOutputs.Count == 0) AddError = "Source unattached, has no consumers or adapters"; if (!(_source is ITimeSpaceOutput)) AddError = "Source non temporal"; } catch (System.Exception e) { AddError = Sdk.Utilities.Xml.Persist(e).ToString(); } return _errors.Count == 0; }
public override bool DoValidation(ITime getValuesAt) { try { if (_options.RunType != RunType.GetValuesAt) AddError = "Not a GetValuesAt run"; if (_options.GetValuesAt_ActOn == null) AddError = "No output specified to pull values on, need to set in composition View tab"; if (_options.GetValuesAt_RunTo == null || double.IsInfinity(_options.GetValuesAt_RunTo.StampAsModifiedJulianDay)) AddError = "Invalid time specified to pull values too"; } catch (System.Exception e) { AddError = Sdk.Utilities.Xml.Persist(e).ToString(); } return _errors.Count == 0; }
public void RunSequence(ITime triggerTime) { Event theEvent = new Event(EventType.Informative); theEvent.Description = "Parallel execution feature disabled."; _runListener.OnEvent(theEvent); /* try find edge model and trigger them first, is possible */ int edgeModel = 0; foreach (Model uimodel in _models) { if (!isModelEngineComponent(uimodel.LinkableComponent)) continue; int outDegree = 0; LinkableRunEngine runEngine = (LinkableRunEngine)uimodel.LinkableComponent; foreach (ILink link in runEngine.GetProvidingLinks()) { if (isModelEngineComponent(link.TargetComponent)) outDegree++; } theEvent = new Event(EventType.Informative); theEvent.Description = "Out degree of " + uimodel.ModelID + " is " + outDegree + "."; _runListener.OnEvent(theEvent); if (outDegree == 0) { runEngine.RunToTime(triggerTime, -1); edgeModel++; } } /* no edge model was found, perhaps the composition is combined with circles */ if (edgeModel == 0) { theEvent = new Event(EventType.Informative); theEvent.Description = "No edge model found, try invoke all of them."; _runListener.OnEvent(theEvent); foreach (Model uimodel in _models) { if (!isModelEngineComponent(uimodel.LinkableComponent)) continue; LinkableRunEngine runEngine = (LinkableRunEngine)uimodel.LinkableComponent; runEngine.RunToTime(triggerTime, -1); } } }
/// <summary> /// A ValueSet corresponding to a TimeSpan is calculated using interpolation or /// extrapolation in corresponding lists of ValueSets and TimeSpans. /// </summary> /// <param name="requestedTime">Time for which the ValueSet is requested</param> /// <returns>ValueSet that corresponds to requestedTime</returns> private List<double> MapFromTimeSpansToTimeSpan(ITime requestedTime) { try { int m = _values[0].Length; double[][] xr = new double[m][]; // Values to return double trb = requestedTime.StampAsModifiedJulianDay; // Begin time in requester time interval double tre = requestedTime.StampAsModifiedJulianDay + requestedTime.DurationInDays; // End time in requester time interval const int nk = 1; for (int i = 0; i < m; i++) { xr[i] = new double[nk]; } for (int i = 0; i < m; i++) { for (int k = 0; k < nk; k++) { xr[i][k] = 0; } } for (int n = 0; n < _times.Count; n++) { double tbbn = _times[n].StampAsModifiedJulianDay; double tben = _times[n].StampAsModifiedJulianDay + _times[n].DurationInDays; //--------------------------------------------------------------------------- // B: <--------------------------> // R: <-------------------------------------> // -------------------------------------------------------------------------- if (trb <= tbbn && tre >= tben) //Buffered TimeSpan fully included in requested TimeSpan { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) // for all values coorsponding to the same time interval { double sbin = BufferHelper.GetVal(_values[n], i, k); xr[i][k - 1] += sbin * (tben - tbbn) / (tre - trb); } } } //--------------------------------------------------------------------------- // Times[i] Interval: t1|-----------------------|t2 // Requested Interval: rt1|--------------|rt2 // -------------------------------------------------------------------------- else if (tbbn <= trb && tre <= tben) //cover all { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) // for all values coorsponding to the same time interval { xr[i][k - 1] += BufferHelper.GetVal(_values[n], i, k); } } } //--------------------------------------------------------------------------- // Times[i] Interval: t1|-----------------|t2 // Requested Interval: rt1|--------------|rt2 // -------------------------------------------------------------------------- else if (tbbn < trb && trb < tben && tre > tben) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) // for all values coorsponding to the same time interval { double sbin = BufferHelper.GetVal(_values[n], i, k); xr[i][k - 1] += sbin * (tben - trb) / (tben - tbbn); if (n == _times.Count - 1) // extrapolation needed { xr[i][k - 1] += sbin * (tre - tben) / (tben - tbbn); } } } } //--------------------------------------------------------------------------- // Times[i] Interval: t1|-----------------|t2 // Requested Interval: rt1|--------------|rt2 // -------------------------------------------------------------------------- else if (trb < tbbn && tre > tbbn && tre < tben) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) // for all values coorsponding to the same time interval { double sbin = BufferHelper.GetVal(_values[n], i, k); xr[i][k - 1] += sbin * (tre - tbbn) / (tben - tbbn); if (n == 0) // extrapolation needed { xr[i][k - 1] += sbin * (tbbn - trb) / (tben - tbbn); } } } } } if (_relaxationFactor != 1 && (_times.Count >= 2)) { //-------------------------------------------------------------------------- // |--------|---------|--------| B // |----------------| R //--------------------------------------------------------------------------- double tbb0 = _times[0].StampAsModifiedJulianDay; double tbe0 = _times[0].StampAsModifiedJulianDay + _times[0].DurationInDays; //double tbb1 = ((ITimeSpan) times[1]).Start.StampAsModifiedJulianDay; double tbe1 = _times[1].StampAsModifiedJulianDay + _times[1].DurationInDays; if (trb < tbb0 && tre > tbb0) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) { double sbi0 = BufferHelper.GetVal(_values[0], i, k); double sbi1 = BufferHelper.GetVal(_values[1], i, k); xr[i][k - 1] += ((tbb0 - trb) / (tre - trb)) * (sbi0 - (1 - _relaxationFactor) * ((tbb0 - trb) * (sbi1 - sbi0) / (tbe1 - tbe0))); } } } //------------------------------------------------------------------------------------- // |--------|---------|--------| B // |----------------| R //------------------------------------------------------------------------------------- double tbeN_1 = _times[_times.Count - 1].StampAsModifiedJulianDay + _times[_times.Count - 1].DurationInDays; double tbbN_2 = _times[_times.Count - 2].StampAsModifiedJulianDay; if (tre > tbeN_1 && trb < tbeN_1) { //double tbeN_2 = ((ITimeSpan) times[times.Count-2]).End.StampAsModifiedJulianDay; double tbbN_1 = _times[_times.Count - 1].StampAsModifiedJulianDay; for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) { double sbiN_1 = BufferHelper.GetVal(_values[_times.Count - 1], i, k); double sbiN_2 = BufferHelper.GetVal(_values[_times.Count - 2], i, k); xr[i][k - 1] += ((tre - tbeN_1) / (tre - trb)) * (sbiN_1 + (1 - _relaxationFactor) * ((tre - tbbN_1) * (sbiN_1 - sbiN_2) / (tbeN_1 - tbbN_2))); } } } //------------------------------------------------------------------------------------- // |--------|---------|--------| B // |----------------| R //------------------------------------------------------------------------------------- if (trb >= tbeN_1) { double tbeN_2 = _times[_times.Count - 2].StampAsModifiedJulianDay + _times[_times.Count - 2].DurationInDays; //double tbbN_1 = ((ITimeSpan) times[times.Count-1]).Start.StampAsModifiedJulianDay; for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) { double sbiN_1 = BufferHelper.GetVal(_values[_times.Count - 1], i, k); double sbiN_2 = BufferHelper.GetVal(_values[_times.Count - 2], i, k); xr[i][k - 1] = sbiN_1 + (1 - _relaxationFactor) * ((sbiN_1 - sbiN_2) / (tbeN_1 - tbbN_2)) * (trb + tre - tbeN_1 - tbeN_2); } } } //------------------------------------------------------------------------------------- // |--------|---------|--------| B // |----------------| R //------------------------------------------------------------------------------------- if (tre <= tbb0) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) { double sbi0 = BufferHelper.GetVal(_values[0], i, k); double sbi1 = BufferHelper.GetVal(_values[1], i, k); xr[i][k - 1] = sbi0 - (1 - _relaxationFactor) * ((sbi1 - sbi0) / (tbe1 - tbb0)) * (tbe0 + tbb0 - tre - trb); } } } } //------------------------------------------------------------------------------------- List<double> xx = new List<double>(m); for (int i = 0; i < m; i++) { xx.Add(xr[i][0]); } return xx; } catch (Exception e) { throw new Exception("MapFromTimeSpansToTimeSpan Failed", e); } }
public AutomaticUpdater(ITime time) { _time = time; }
public IntervalBasedCallback(IGameObject obj, ITime time) : base(obj) { this.time = time; }
private Velocity(ILength length, ITime time) : base(length, time) { }
/// <summary> /// A ValueSet corresponding to a TimeSpan is calculated using interpolation or /// extrapolation in corresponding lists of ValueSets and TimeStamps. /// </summary> /// <param name="requestedTime">Time for which the ValueSet is requested</param> /// <returns>ValueSet that corresponds to requestedTime</returns> private List<double> MapFromTimeStampsToTimeSpan(ITime requestedTime) { try { int m = _values[0].Length; //int N = times.Count; // Number of time steps in buffer double[][] xr = new double[m][]; // Values to return double trb = requestedTime.StampAsModifiedJulianDay; // Begin time in requester time interval double tre = requestedTime.StampAsModifiedJulianDay + requestedTime.DurationInDays; // End time in requester time interval const int nk = 1; for (int i = 0; i < m; i++) { xr[i] = new double[nk]; } for (int i = 0; i < m; i++) { for (int k = 0; k < nk; k++) { xr[i][k] = 0; } } for (int n = 0; n < _times.Count - 1; n++) { double tbn = _times[n].StampAsModifiedJulianDay; double tbnp1 = _times[n + 1].StampAsModifiedJulianDay; //--------------------------------------------------------------------------- // B: <--------------------------> // R: <-------------------------------------> // -------------------------------------------------------------------------- if (trb <= tbn && tre >= tbnp1) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) // for all values coorsponding to the same time interval { double sbin = BufferHelper.GetVal(_values[n], i, k); double sbinp1 = BufferHelper.GetVal(_values[n + 1], i, k); xr[i][k - 1] += 0.5 * (sbin + sbinp1) * (tbnp1 - tbn) / (tre - trb); } } } //--------------------------------------------------------------------------- // Times[i] Interval: t1|-----------------------|t2 // Requested Interval: rt1|--------------|rt2 // -------------------------------------------------------------------------- else if (tbn <= trb && tre <= tbnp1) //cover all { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) // for all values coorsponding to the same time interval { double sbin = BufferHelper.GetVal(_values[n], i, k); double sbinp1 = BufferHelper.GetVal(_values[n + 1], i, k); xr[i][k - 1] += sbin + ((sbinp1 - sbin) / (tbnp1 - tbn)) * ((tre + trb) / 2 - tbn); } } } //--------------------------------------------------------------------------- // Times[i] Interval: t1|-----------------|t2 // Requested Interval: rt1|--------------|rt2 // -------------------------------------------------------------------------- else if (tbn < trb && trb < tbnp1 && tre > tbnp1) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) // for all values coorsponding to the same time interval { double sbin = BufferHelper.GetVal(_values[n], i, k); double sbinp1 = BufferHelper.GetVal(_values[n + 1], i, k); xr[i][k - 1] += (sbinp1 - (sbinp1 - sbin) / (tbnp1 - tbn) * ((tbnp1 - trb) / 2)) * (tbnp1 - trb) / (tre - trb); } } } //--------------------------------------------------------------------------- // Times[i] Interval: t1|-----------------|t2 // Requested Interval: rt1|--------------|rt2 // -------------------------------------------------------------------------- else if (trb < tbn && tre > tbn && tre < tbnp1) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) // for all values coorsponding to the same time interval { double sbin = BufferHelper.GetVal(_values[n], i, k); double sbinp1 = BufferHelper.GetVal(_values[n + 1], i, k); xr[i][k - 1] += (sbin + (sbinp1 - sbin) / (tbnp1 - tbn) * ((tre - tbn) / 2)) * (tre - tbn) / (tre - trb); } } } } // In case of only one value in the buffer, regardless of its position relative to R //-------------------------------------------------------------------------- // | or | or | B // |----------------| R //--------------------------------------------------------------------------- if (_times.Count == 1) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) { double sbi0 = BufferHelper.GetVal(_values[0], i, k); xr[i][k - 1] = sbi0; } } } else { //-------------------------------------------------------------------------- // |--------|---------|--------| B // |----------------| R //--------------------------------------------------------------------------- double tb0 = _times[0].StampAsModifiedJulianDay; //double tb1 = ((ITimeStamp) times[0]).ModifiedJulianDay; double tb1 = _times[1].StampAsModifiedJulianDay; // line above was corrected to this Gregersen Sep 15 2004 double tbN_1 = _times[_times.Count - 1].StampAsModifiedJulianDay; double tbN_2 = _times[_times.Count - 2].StampAsModifiedJulianDay; if (trb < tb0 && tre > tb0) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) { double sbi0 = BufferHelper.GetVal(_values[0], i, k); double sbi1 = BufferHelper.GetVal(_values[1], i, k); xr[i][k - 1] += ((tb0 - trb) / (tre - trb)) * (sbi0 - (1 - _relaxationFactor) * 0.5 * ((tb0 - trb) * (sbi1 - sbi0) / (tb1 - tb0))); } } } //------------------------------------------------------------------------------------- // |--------|---------|--------| B // |----------------| R //------------------------------------------------------------------------------------- if (tre > tbN_1 && trb < tbN_1) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) { double sbiN_1 = BufferHelper.GetVal(_values[_times.Count - 1], i, k); double sbiN_2 = BufferHelper.GetVal(_values[_times.Count - 2], i, k); xr[i][k - 1] += ((tre - tbN_1) / (tre - trb)) * (sbiN_1 + (1 - _relaxationFactor) * 0.5 * ((tre - tbN_1) * (sbiN_1 - sbiN_2) / (tbN_1 - tbN_2))); } } } //------------------------------------------------------------------------------------- // |--------|---------|--------| B // |----------------| R //------------------------------------------------------------------------------------- if (trb >= tbN_1) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) { double sbiN_1 = BufferHelper.GetVal(_values[_times.Count - 1], i, k); double sbiN_2 = BufferHelper.GetVal(_values[_times.Count - 2], i, k); xr[i][k - 1] = sbiN_1 + (1 - _relaxationFactor) * ((sbiN_1 - sbiN_2) / (tbN_1 - tbN_2)) * (0.5 * (trb + tre) - tbN_1); } } } //------------------------------------------------------------------------------------- // |--------|---------|--------| B // |----------------| R //------------------------------------------------------------------------------------- if (tre <= tb0) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) { double sbi0 = BufferHelper.GetVal(_values[0], i, k); double sbi1 = BufferHelper.GetVal(_values[1], i, k); xr[i][k - 1] = sbi0 - (1 - _relaxationFactor) * ((sbi1 - sbi0) / (tb1 - tb0)) * (tb0 - 0.5 * (trb + tre)); } } } } //------------------------------------------------------------------------------------- List<double> xx = new List<double>(m); for (int i = 0; i < m; i++) { xx.Add(xr[i][0]); } return xx; } catch (Exception e) { throw new Exception("MapFromTimeStampsToTimeSpan Failed", e); } }
public Character( TestableGameObject parent, ITime time ) : base( parent ) { this.time = time; }
/// <summary> /// A ValueSet corresponding to a TimeSpan is calculated using interpolation or /// extrapolation in corresponding lists of ValueSets and TimeSpans. /// </summary> /// <param name="requestedTimeStamp">Time for which the ValueSet is requested</param> /// <returns>ValueSet that corresponds to requestedTime</returns> private List<double> MapFromTimeSpansToTimeStamp(ITime requestedTimeStamp) { try { int m = (_values[0]).Length; double[][] xr = new double[m][]; // Values to return double tr = requestedTimeStamp.StampAsModifiedJulianDay; // Requested TimeStamp const int nk = 1; for (int i = 0; i < m; i++) { xr[i] = new double[nk]; } if (_times.Count == 1) { //--------------------------------------------------------------------------- // Buffered TimesStamps: | >tbb0< // Requested TimeStamp: | >tr< // or Requested TimeStamp: | >tr< // or Requested TimeStamp: | >tr< // -----------------------------------------> t // -------------------------------------------------------------------------- for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) //For each Vector in buffered VectorSet [0] { xr[i][k - 1] = BufferHelper.GetVal(_values[0], i, k); } } } //--------------------------------------------------------------------------- // Buffered TimesSpans: | >tbb0< .......... >tbbN< // Requested TimeStamp: | >tr< // -----------------------------------------> t // -------------------------------------------------------------------------- else if (tr <= _times[0].StampAsModifiedJulianDay) { double tbb0 = _times[0].StampAsModifiedJulianDay; double tbb1 = _times[1].StampAsModifiedJulianDay; for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) //For each Vector in buffered VectorSet [0] { double sbi0 = BufferHelper.GetVal(_values[0], i, k); double sbi1 = BufferHelper.GetVal(_values[1], i, k); xr[i][k - 1] = ((sbi0 - sbi1) / (tbb0 - tbb1)) * (tr - tbb0) * (1 - _relaxationFactor) + sbi0; } } } //--------------------------------------------------------------------------- // Buffered TimesSpans: | >tbb0< ................. >tbbN_1< // Requested TimeStamp: | >tr< // ---------------------------------------------------> t // -------------------------------------------------------------------------- else if (tr >= _times[_times.Count - 1].StampAsModifiedJulianDay + _times[_times.Count - 1].DurationInDays) { double tbeN_2 = _times[_times.Count - 2].StampAsModifiedJulianDay + _times[_times.Count - 2].DurationInDays; double tbeN_1 = _times[_times.Count - 1].StampAsModifiedJulianDay + _times[_times.Count - 1].DurationInDays; for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) //For each Vector in buffered VectorSet [N-1] { double sbiN_2 = BufferHelper.GetVal(_values[_times.Count - 2], i, k); double sbiN_1 = BufferHelper.GetVal(_values[_times.Count - 1], i, k); xr[i][k - 1] = ((sbiN_1 - sbiN_2) / (tbeN_1 - tbeN_2)) * (tr - tbeN_1) * (1 - _relaxationFactor) + sbiN_1; } } } //--------------------------------------------------------------------------- // Availeble TimesSpans: | >tbb0< ...................... >tbbN_1< // Requested TimeStamp: | >tr< // -------------------------------------------------> t // -------------------------------------------------------------------------- else { for (int n = _times.Count - 1; n >= 0; n--) { double tbbn = _times[n].StampAsModifiedJulianDay; double tben = _times[n].StampAsModifiedJulianDay + _times[n].DurationInDays; if (tbbn <= tr && tr < tben) { for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) //For each Vector in buffered VectorSet [n] { xr[i][k - 1] = BufferHelper.GetVal(_values[n], i, k); } } break; } } } //---------------------------------------------------------------------------------------------- List<double> xx = new List<double>(m); for (int i = 0; i < m; i++) { xx.Add(xr[i][0]); } return xx; } catch (Exception e) { throw new Exception("MapFromTimeSpansToTimeStamp Failed", e); } }
private void scheduleAggressive(ITime triggerTime) { List<List<Model>> orders; lock (this) { orders = getTopologicalOrder(_queueModels); } if (orders.Count > 0) { List<Model> tier = orders[0]; foreach (Model model in tier) { if (!isModelEngineComponent(model.LinkableComponent)) continue; lock (this) { if (_runningModels.Contains(model)) continue; _runningModels.Add(model); } Event theEvent = new Event(EventType.Informative); theEvent.Description = "Triggering model: " + model.ModelID; _runListener.OnEvent(theEvent); LinkableRunEngine runEngine = (LinkableRunEngine)model.LinkableComponent; new Thread(new ThreadStart(delegate() { runEngine.RunToTime(triggerTime, -1); lock (this) { _runningModels.Remove(model); _queueModels.Remove(model); } _s.Release(); })).Start(); } } }
/// <summary> /// A ValueSet corresponding to a TimeStamp is calculated using interpolation or /// extrapolation in corresponding lists of ValueSets and TimeStamps. /// </summary> /// <param name="requestedTimeStamp">TimeStamp for which the values are requested</param> /// <returns>ValueSet that corresponds to the requested time stamp</returns> private List<double> MapFromTimeStampsToTimeStamp(ITime requestedTimeStamp) { try { int m = (_values[0]).Length; double[][] xr = new double[m][]; // Values to return double tr = requestedTimeStamp.StampAsModifiedJulianDay; // Requested TimeStamp const int nk = 1; for (int i = 0; i < m; i++) { xr[i] = new double[nk]; } if (_times.Count == 1) { //--------------------------------------------------------------------------- // Buffered TimesStamps: | >tb0< // Requested TimeStamp: | >tr< // or Requested TimeStamp: | >tr< // or Requested TimeStamp: | >tr< // -----------------------------------------> t // -------------------------------------------------------------------------- if (tr > (_times[0].StampAsModifiedJulianDay + Time.EpsilonForTimeCompare) && !_doExtrapolateAtEnd) { throw new Exception("Extrapolation not allowed"); } for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) //For each Vector in buffered VectorSet [0] { xr[i][k - 1] = BufferHelper.GetVal(_values[0], i, k); } } } else if (tr <= _times[0].StampAsModifiedJulianDay) { //--------------------------------------------------------------------------- // Buffered TimesStamps: | >tb0< >tb1< >tb2< >tbN< // Requested TimeStamp: | >tr< // -----------------------------------------> t // -------------------------------------------------------------------------- double tb0 = _times[0].StampAsModifiedJulianDay; double tb1 = _times[1].StampAsModifiedJulianDay; for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) //For each Vector in buffered VectorSet [0] { double sbi0 = BufferHelper.GetVal(_values[0], i, k); double sbi1 = BufferHelper.GetVal(_values[1], i, k); xr[i][k - 1] = ((sbi0 - sbi1) / (tb0 - tb1)) * (tr - tb0) * (1 - _relaxationFactor) + sbi0; } } } else if (tr > _times[_times.Count - 1].StampAsModifiedJulianDay) { //--------------------------------------------------------------------------- // Buffered TimesStamps: | >tb0< >tb1< >tb2< >tbN_2< >tbN_1< // Requested TimeStamp: | >tr< // ---------------------------------------------------> t // -------------------------------------------------------------------------- double tbN_2 = _times[_times.Count - 2].StampAsModifiedJulianDay; double tbN_1 = _times[_times.Count - 1].StampAsModifiedJulianDay; for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) //For each Vector in buffered VectorSet [N-1] { double sbiN_2 = BufferHelper.GetVal(_values[_times.Count - 2], i, k); double sbiN_1 = BufferHelper.GetVal(_values[_times.Count - 1], i, k); xr[i][k - 1] = ((sbiN_1 - sbiN_2) / (tbN_1 - tbN_2)) * (tr - tbN_1) * (1 - _relaxationFactor) + sbiN_1; } } } else { //--------------------------------------------------------------------------- // Availeble TimesStamps: | >tb0< >tb1< >tbna< >tnb< >tbN_1< >tbN_2< // Requested TimeStamp: | >tr< // -------------------------------------------------> t // -------------------------------------------------------------------------- for (int n = _times.Count - 2; n >= 0; n--) { double tbn1 = _times[n].StampAsModifiedJulianDay; double tbn2 = _times[n + 1].StampAsModifiedJulianDay; if (tbn1 <= tr && tr <= tbn2) { double tbn2Fraction = (tr - tbn1) / (tbn2 - tbn1); for (int k = 1; k <= nk; k++) { for (int i = 0; i < m; i++) //For each Vector in buffered VectorSet [n] { double[] valueSet_n = _values[n]; double sbin1 = BufferHelper.GetVal(valueSet_n, i, k); double[] valueSet_nPlus1 = _values[n + 1]; double sbin2 = BufferHelper.GetVal(valueSet_nPlus1, i, k); xr[i][k - 1] = tbn2Fraction * (sbin2 - sbin1) + sbin1; } } break; } } } //---------------------------------------------------------------------------------------------- List<double> xx = new List<double>(m); for (int i = 0; i < m; i++) { xx.Add(xr[i][0]); } return xx; } catch (Exception e) { throw new Exception("MapFromTimeStampsToTimeStamp Failed", e); } }
private void runStandardParallel(ITime triggerTime) { List<Thread> threads = new List<Thread>(); List<Model> uimodels = new List<Model>(_models); List<List<Model>> orders; while ((orders = getTopologicalOrder(uimodels)).Count > 0) { List<Model> tier = orders[0]; string modelIds = ""; foreach (Model uimodel in tier) modelIds += uimodel.ModelID + ", "; Event theEvent = new Event(EventType.Informative); theEvent.Description = "Tier models: " + modelIds; _runListener.OnEvent(theEvent); foreach (Model uimodel in tier) { if (!isModelEngineComponent(uimodel.LinkableComponent)) continue; LinkableRunEngine runEngine = (LinkableRunEngine)uimodel.LinkableComponent; Thread th = new Thread(new ThreadStart(delegate() { runEngine.RunToTime(triggerTime, -1); })); th.Start(); threads.Add(th); uimodels.Remove(uimodel); } foreach (Thread th in threads) { th.Join(); } threads.Clear(); } }
private void runAggressiveParallel(ITime triggerTime) { _s = new Semaphore(0, _models.Count); _queueModels = new List<Model>(_models); _runningModels = new List<Model>(); while (_queueModels.Count > 0 && _s.WaitOne()) { scheduleAggressive(triggerTime); } }
public IValueSet GetValues(ITime time, string linkID) { // TODO: Add Trigger.GetValues implementation return null; }
/// <summary> /// Returns the ValueSet that corresponds to requestTime. The ValueSet may be found by /// interpolation, extrapolation and/or aggregation. /// </summary> /// <param name="requestedTime">time for which the value is requested</param> /// <returns>valueSet that corresponds to requestTime</returns> public List<double> GetValues(ITime requestedTime) { if (_doExtendedDataVerification) { CheckBuffer(); } if (!_doExtrapolateAtEnd) { if (requestedTime.StampAsModifiedJulianDay + requestedTime.DurationInDays > _times[_times.Count - 1].StampAsModifiedJulianDay + _times[_times.Count - 1].DurationInDays) { throw new Exception("Extrapolation after last time step not allowed for this buffer"); } } List<double> returnValues = new List<double>(); ; if (_values.Values2DArray.Count != 0) { if (_times[0].DurationInDays > 0 && requestedTime.DurationInDays > 0) { returnValues = MapFromTimeSpansToTimeSpan(requestedTime); } else if (_times[0].DurationInDays > 0 && requestedTime.DurationInDays == 0) { returnValues = MapFromTimeSpansToTimeStamp(requestedTime); } else if (_times[0].DurationInDays == 0 && requestedTime.DurationInDays > 0) { returnValues = MapFromTimeStampsToTimeSpan(requestedTime); } else // time stamps { returnValues = MapFromTimeStampsToTimeStamp(requestedTime); } } // Console.WriteLine(((requestedTime.DurationInDays > 0) ? "Span" : "Stamp") + " from " + // ((times[0].DurationInDays > 0) ? "Span" : "Stamp") + " in Buffer: " + requestedTime + ": " // + returnValueSet[0]); return returnValues; }
/** * Returns the ValueSet that corresponds to requestTime. */ public IValueSet GetValues(ITime requestedTime, IQuantity quantity, IElementSet elementSet, PrefetchManager prefetchManager, ILink link) { try { // generate the key of the buffer entry we're looking for var key = ValueSetEntry.CreateKey(webServiceManager.FindServiceIdForQuantity(quantity.ID), quantity.ID, elementSet.ID, requestedTime, scenarioId); traceFile.Append("GetValues: " + key); var mapValueSet = client.getMap<string, ValueSetEntry>("valueSet"); var mapElementSet = client.getMap<string, ElementSetEntry>("elementSet"); var queueValueSetRequest = client.getQueue<ValueSetRequestEntry>("valueSetRequest"); // record this request statistics.Add("GetValuesCount", 1); // measure our wait time var waitStopwatch = Stopwatch.StartNew(); // see if the requested values are in the cache var valueSetEntry = mapValueSet.get(key); // if the value set does not exist then request it if (valueSetEntry == null) { traceFile.Append("Requesting Value Set: " + key); // insert the element set if necessary if (elementSetsPut.Contains(elementSet.ID) == false) { elementSetsPut.Add(elementSet.ID); mapElementSet.put(elementSet.ID, new ElementSetEntry(elementSet)); } while (valueSetEntry == null) { // if we're prefetching, we may have already requested this // value set in a previous prefetch that hasn't been fulfilled // yet in which case we do not want to issue the request again. if (prefetchManager.timeIsFetched(link, (TimeStamp)requestedTime) == false) { // insert the request into the queue var insertRequestStopwatch = Stopwatch.StartNew(); // create the request entry var valueSetRequestEntry = new ValueSetRequestEntry(webServiceManager.FindServiceIdForQuantity(quantity.ID), quantity.ID, elementSet.ID, Utils.ITimeToDateTime(requestedTime), scenarioId); // BLOCKING queueValueSetRequest.put(valueSetRequestEntry); statistics.Add("RequestInsertTimeMS", insertRequestStopwatch.ElapsedMilliseconds); traceFile.Append("RequestInsertTime:" + string.Format("{0:0.0}", insertRequestStopwatch.ElapsedMilliseconds) + "ms"); } // PERFORMANCE STUDY: start delay at 100 and double each time // we check and it's not available // poll for the value set var delay = 1000; while (true) { // we know that the value set is not in the cache since // we just checked that above, so wait immediately after // making the request Thread.Sleep(delay); valueSetEntry = mapValueSet.get(key); if (valueSetEntry != null) { break; } //delay *= 2; traceFile.Append(string.Format("Waiting ({0}) For Value Set: ({1})", delay, key)); if (delay > 20000) { statistics.Add("RequestRetry", 1); break; } } } } statistics.Add("CacheWaitTimeMS", waitStopwatch.ElapsedMilliseconds); traceFile.Append("WaitTime:" + string.Format("{0:0.0}", waitStopwatch.ElapsedMilliseconds) + "ms"); return new ScalarSet(valueSetEntry.Values()); } catch (Exception e) { traceFile.Exception(e); return null; } }
public HasSingletonTime(TestableGameObject obj, ITime time) : base(obj) { injectedTime = time; }
/// <summary> /// /// </summary> /// <param name="length"></param> /// <param name="perSquareTime"></param> protected AccelerationBase(ILength length, ITime perSquareTime) : base(length, perSquareTime) { VerifyDimensions(); }
public static DateTime ITimeToDateTime(ITime iTime) { if (iTime is TimeStamp) { var ts = (TimeStamp)iTime; var d = ts.ModifiedJulianDay; var dt = CalendarConverter.ModifiedJulian2Gregorian(d); return dt; } throw new Exception("Unable to convert ITime to DateTime"); }
public void Run(ITime[] GetValuesTimes) { for (int i = 0; i < GetValuesTimes.Length; i++) { _resultsBuffer.AddValues(GetValuesTimes[i], (IScalarSet)_link.SourceComponent.GetValues(GetValuesTimes[i], _link.ID)); _earliestInputTime.ModifiedJulianDay = ((ITimeStamp)GetValuesTimes[i]).ModifiedJulianDay; } }