/// <summary> /// An override of the Subsystem CanPerform method /// </summary> /// <param name="proposedEvent"></param> /// <param name="environment"></param> /// <returns></returns> public override bool CanPerform(Event proposedEvent, Domain environment) { if (!base.CanPerform(proposedEvent, environment)) { return(false); } if (_task.Type == TaskType.IMAGING) { double ts = proposedEvent.GetTaskStart(Asset); double te = proposedEvent.GetTaskEnd(Asset); double oldbufferratio = _newState.GetLastValue(Dkeys[0]).Value; Delegate DepCollector; SubsystemDependencyFunctions.TryGetValue("DepCollector", out DepCollector); HSFProfile <double> newdataratein = ((HSFProfile <double>)DepCollector.DynamicInvoke(proposedEvent) / _bufferSize); bool exceeded = false; HSFProfile <double> newdataratio = newdataratein.upperLimitIntegrateToProf(ts, te, 1, 1, ref exceeded, 0, oldbufferratio); if (!exceeded) { _newState.AddValue(DATABUFFERRATIO_KEY, newdataratio); return(true); } // TODO: Change to logger Console.WriteLine("SSDR buffer full"); return(false); } else if (_task.Type == TaskType.COMM) { double ts = proposedEvent.GetTaskStart(Asset); proposedEvent.SetTaskEnd(Asset, ts + 60.0); double te = proposedEvent.GetTaskEnd(Asset); double data = _bufferSize * _newState.GetLastValue(Dkeys.First()).Value; double dataqueout = data / 2 > 50 ? data / 2 : data; if (data - dataqueout < 0) { dataqueout = data; } if (dataqueout > 0) { _newState.AddValue(DATABUFFERRATIO_KEY, new KeyValuePair <double, double>(te, (data - dataqueout) / _bufferSize)); } return(true); } return(true); }
/// <summary> /// Override of the canExtend method for the power subsystem /// </summary> /// <param name="newState"></param> /// <param name="universe"></param> /// <param name="evalToTime"></param> /// <returns></returns> public override bool CanExtend(Event proposedEvent, Universe universe, double evalToTime) { double ee = proposedEvent.GetEventEnd(Asset); if (ee > SimParameters.SimEndSeconds) { return(false); } Sun sun = universe.Sun; double te = proposedEvent.State.GetLastValue(DOD_KEY).Key; if (proposedEvent.GetEventEnd(Asset) < evalToTime) { proposedEvent.SetEventEnd(Asset, evalToTime); } // get the dod initial conditions double olddod = proposedEvent.State.GetValueAtTime(DOD_KEY, te).Value; // collect power profile out Delegate DepCollector; SubsystemDependencyFunctions.TryGetValue("DepCollector", out DepCollector); HSFProfile <double> powerOut = (HSFProfile <double>)DepCollector.DynamicInvoke(proposedEvent); // deps->callDoubleDependency("POWERSUB_getPowerProfile"); // collect power profile in DynamicState position = Asset.AssetDynamicState; HSFProfile <double> powerIn = CalcSolarPanelPowerProfile(te, ee, proposedEvent.State, position, universe); // calculate dod rate HSFProfile <double> dodrateofchange = ((powerOut - powerIn) / _batterySize); bool exceeded_lower = false, exceeded_upper = false; double freq = 1.0; HSFProfile <double> dodProf = dodrateofchange.limitIntegrateToProf(te, ee, freq, 0.0, 1.0, ref exceeded_lower, ref exceeded_upper, 0, olddod); if (exceeded_upper) { return(false); } if (dodProf.LastTime() != ee && ee == SimParameters.SimEndSeconds) { dodProf[ee] = dodProf.LastValue(); } proposedEvent.State.AddValue(DOD_KEY, dodProf); return(true); }
/// <summary> /// Override of the canPerform method for the power subsystem /// </summary> /// <param name="oldState"></param> /// <param name="newState"></param> /// <param name="tasks"></param> /// <param name="universe"></param> /// <returns></returns> public override bool CanPerform(Event proposedEvent, Universe universe) { //Make sure all dependent subsystems have been evaluated if (!base.CanPerform(proposedEvent, universe)) { return(false); } double es = proposedEvent.GetEventStart(Asset); double te = proposedEvent.GetTaskEnd(Asset); double ee = proposedEvent.GetEventEnd(Asset); double powerSubPowerOut = 10; if (ee > SimParameters.SimEndSeconds) { Console.WriteLine("Simulation ended"); return(false); } // get the old DOD double olddod = _newState.GetLastValue(Dkeys.First()).Value; // collect power profile out Delegate DepCollector; SubsystemDependencyFunctions.TryGetValue("DepCollector", out DepCollector); HSFProfile <double> powerOut = (HSFProfile <double>)DepCollector.DynamicInvoke(proposedEvent); // deps->callDoubleDependency("POWERSUB_getPowerProfile"); powerOut = powerOut + powerSubPowerOut; // collect power profile in DynamicState position = Asset.AssetDynamicState; HSFProfile <double> powerIn = CalcSolarPanelPowerProfile(es, te, _newState, position, universe); // calculate dod rate HSFProfile <double> dodrateofchange = ((powerOut - powerIn) / _batterySize); bool exceeded = false; double freq = 1.0; HSFProfile <double> dodProf = dodrateofchange.lowerLimitIntegrateToProf(es, te, freq, 0.0, ref exceeded, 0, olddod); _newState.AddValue(DOD_KEY, dodProf); return(true); }