/// <summary> /// Static method to generate an evaluator from XML node /// </summary> /// <param name="evaluatorNode"></param> /// <param name="dependencies"></param> /// <returns></returns> public static Evaluator GetEvaluator(XmlNode evaluatorNode, Dependency dependencies) { Evaluator schedEvaluator = new TargetValueEvaluator(dependencies); // default if (evaluatorNode != null) schedEvaluator = new ScriptedEvaluator(evaluatorNode, dependencies); return schedEvaluator; }
/// <summary> /// Constructor for built in subsystem /// Defaults: lowQualityPixels = 5000, midQualityPixels = 10000, highQualityPixels = 15000 /// lowQualityTime = 3s, midQyalityTime = 5s, highQualityTime = 7s /// </summary> /// <param name="EOSensorXmlNode"></param> /// <param name="dependencies"></param> /// <param name="asset"></param> public EOSensor(XmlNode EOSensorXmlNode, Dependency dependencies, Asset asset) { DefaultSubName = "EOSensor"; Asset = asset; GetSubNameFromXmlNode(EOSensorXmlNode); PIXELS_KEY = new StateVarKey<double>(Asset.Name +"." + "numpixels"); INCIDENCE_KEY = new StateVarKey<double>(Asset.Name + "." + "incidenceangle"); EOON_KEY = new StateVarKey<bool>(Asset.Name + "." + "eosensoron"); addKey(PIXELS_KEY); addKey(INCIDENCE_KEY); addKey(EOON_KEY); DependentSubsystems = new List<Subsystem>(); SubsystemDependencyFunctions = new Dictionary<string, Delegate>(); if (EOSensorXmlNode.Attributes["lowQualityPixels"] != null) _lowQualityPixels = (double)Convert.ChangeType(EOSensorXmlNode.Attributes["lowQualityPixels"].Value.ToString(), typeof(double)); if (EOSensorXmlNode.Attributes["lowQualityPixels"] != null) _lowQualityTime = (double)Convert.ChangeType(EOSensorXmlNode.Attributes["lowQualityTime"].Value.ToString(), typeof(double)); if (EOSensorXmlNode.Attributes["midQualityPixels"] != null) _midQualityPixels = (double)Convert.ChangeType(EOSensorXmlNode.Attributes["midQualityPixels"].Value.ToString(), typeof(double)); if (EOSensorXmlNode.Attributes["midQualityTime"] != null) _midQualityTime = (double)Convert.ChangeType(EOSensorXmlNode.Attributes["midQualityTime"].Value.ToString(), typeof(double)); if (EOSensorXmlNode.Attributes["highQualityPixels"] != null) _highQualityPixels = (double)Convert.ChangeType(EOSensorXmlNode.Attributes["highQualityPixels"].Value.ToString(), typeof(double)); if (EOSensorXmlNode.Attributes["highQualityTime"] != null) _highQualityTime = (double)Convert.ChangeType(EOSensorXmlNode.Attributes["highQualityTime"].Value.ToString(), typeof(double)); dependencies.Add("PowerfromEOSensor"+"."+Asset.Name, new Func<Event, HSFProfile<double>>(POWERSUB_PowerProfile_EOSENSORSUB)); dependencies.Add("SSDRfromEOSensor" + "." + Asset.Name, new Func<Event, HSFProfile<double>>(SSDRSUB_NewDataProfile_EOSENSORSUB)); }
/// <summary> /// Constructor for built in subsystem /// </summary> /// <param name="CommXmlNode"></param> /// <param name="dependencies"></param> /// <param name="asset"></param> public Comm(XmlNode CommXmlNode, Dependency dependencies, Asset asset) { DefaultSubName = "Comm"; Asset = asset; GetSubNameFromXmlNode(CommXmlNode); SubsystemDependencyFunctions = new Dictionary<string, Delegate>(); DependentSubsystems = new List<Subsystem>(); DATARATE_KEY = new StateVarKey<double>(Asset.Name + "." + "datarate(mb/s)"); addKey(DATARATE_KEY); dependencies.Add("PowerfromComm" + "." + Asset.Name, new Func<Event, HSFProfile<double>>(POWERSUB_PowerProfile_COMMSUB)); }
/// <summary> /// Constructor to create the scriped evaluator and initialize the python instance /// </summary> /// <param name="scriptedNode"></param> /// <param name="deps"></param> public ScriptedEvaluator(XmlNode scriptedNode, Dependency deps) { string pythonFilePath = "", className = ""; XmlParser.ParseScriptedSrc(scriptedNode, ref pythonFilePath, ref className); var engine = Python.CreateEngine(); var scope = engine.CreateScope(); var ops = engine.Operations; engine.ExecuteFile(pythonFilePath, scope); var pythonType = scope.GetVariable(className); _pythonInstance = ops.CreateInstance(pythonType, deps); Dependencies = deps; }
/// <summary> /// Constructor for built in subsystem /// Default: BufferSize = 4098 /// </summary> /// <param name="SSDRXmlNode"></param> /// <param name="dependencies"></param> /// <param name="asset"></param> public SSDR(XmlNode SSDRXmlNode, Dependency dependencies, Asset asset) { DefaultSubName = "SSDR"; Asset = asset; GetSubNameFromXmlNode(SSDRXmlNode); if (SSDRXmlNode.Attributes["bufferSize"] != null) _bufferSize = (double)Convert.ChangeType(SSDRXmlNode.Attributes["bufferSize"].Value.ToString(), typeof(double)); DATABUFFERRATIO_KEY = new StateVarKey<double>(Asset.Name + "." +"databufferfillratio"); addKey(DATABUFFERRATIO_KEY); SubsystemDependencyFunctions = new Dictionary<string, Delegate>(); DependentSubsystems = new List<Subsystem>(); dependencies.Add("PowerfromSSDR" + "." + Asset.Name, new Func<Event, HSFProfile<double>>(POWERSUB_PowerProfile_SSDRSUB)); dependencies.Add("CommfromSSDR" + "." + Asset.Name, new Func<Event, HSFProfile<double>>(COMMSUB_DataRateProfile_SSDRSUB)); dependencies.Add("EvalfromSSDR" + "." + Asset.Name, new Func<Event, double>(EVAL_DataRateProfile_SSDRSUB)); }
/// <summary> /// A method to interpret the Xml file and create subsystems /// </summary> /// <param name="SubsystemXmlNode"></param> /// <param name="enableScripting"></param> /// <param name="dependencies"></param> /// <param name="asset"></param> /// <param name="subDic"></param> /// <returns></returns> public static string GetSubsystem(XmlNode SubsystemXmlNode, Dependency dependencies, Asset asset, Dictionary<string, Subsystem> subDic) { string type = SubsystemXmlNode.Attributes["Type"].Value.ToString().ToLower(); string name = Subsystem.parseNameFromXmlNode(SubsystemXmlNode, asset.Name); if (type.Equals("scripted")) { subDic.Add(name, new ScriptedSubsystem(SubsystemXmlNode, dependencies, asset)); } else // not scripted subsystem { if (type.Equals("access")) { subDic.Add(name, new AccessSub(SubsystemXmlNode, asset)); } else if (type.Equals("adcs")) { subDic.Add(name, new ADCS(SubsystemXmlNode, dependencies, asset)); } else if (type.Equals("power")) { subDic.Add(name, new Power(SubsystemXmlNode, dependencies, asset)); } else if (type.Equals("eosensor")) { subDic.Add(name, new EOSensor(SubsystemXmlNode, dependencies, asset)); } else if (type.Equals("ssdr")) { subDic.Add(name, new SSDR(SubsystemXmlNode, dependencies, asset)); } else if (type.Equals("comm")) { subDic.Add(name, new Comm(SubsystemXmlNode, dependencies, asset)); } else if (type.Equals("networked")) { throw new NotImplementedException("Networked Subsystem is a depreciated feature!"); } else { log.Fatal("Horizon does not recognize the subsystem: " + type); throw new MissingMemberException("Unknown Subsystem Type " + type); } } return name; }
/// <summary> /// Constructor for built in subsystems /// Defaults: Slew time: 10s /// </summary> /// <param name="ADCSNode"></param> /// <param name="dependencies"></param> /// <param name="asset"></param> public ADCS(XmlNode ADCSNode, Dependency dependencies, Asset asset) { DefaultSubName = "Adcs"; Asset = asset; GetSubNameFromXmlNode(ADCSNode); /*double slewTime; if (ADCSNode.Attributes["timetoslew"].Value != null) { Double.TryParse(ADCSNode.Attributes["slewTime"].Value, out slewTime); _timetoslew = slewTime; }*/ POINTVEC_KEY = new StateVarKey<Matrix<double>>(Asset.Name + "." + "eci_pointing_vector(xyz)"); addKey(POINTVEC_KEY); DependentSubsystems = new List<Subsystem>(); SubsystemDependencyFunctions = new Dictionary<string, Delegate>(); dependencies.Add("PowerfromADCS"+"."+Asset.Name, new Func<Event, HSFProfile<double>>(POWERSUB_PowerProfile_ADCSSUB)); }
/// <summary> /// Constructor for built in subsystem /// Defaults: batterySize = 1000000, fullSolarPanelPower =150, penumbraSolarPanelPower = 75 /// </summary> /// <param name="PowerNode"></param> /// <param name="dependencies"></param> public Power(XmlNode PowerNode, Dependency dependencies, Asset asset) { DefaultSubName = "Power"; Asset = asset; GetSubNameFromXmlNode(PowerNode); DOD_KEY = new StateVarKey<double>(Asset.Name + "." + "depthofdischarge"); POWIN_KEY = new StateVarKey<double>(Asset.Name + "." + "solarpanelpowerin"); addKey(DOD_KEY); addKey(POWIN_KEY); SubsystemDependencyFunctions = new Dictionary<string, Delegate>(); DependentSubsystems = new List<Subsystem>(); if (PowerNode.Attributes["batterySize"] != null) _batterySize = (double)Convert.ChangeType(PowerNode.Attributes["batterySize"].Value, typeof(double)); if (PowerNode.Attributes["fullSolarPower"] != null) _fullSolarPanelPower = (double)Convert.ChangeType(PowerNode.Attributes["fullSolarPower"].Value, typeof(double)); if(PowerNode.Attributes["penumbraSolarPower"] != null) _penumbraSolarPanelPower = (double)Convert.ChangeType(PowerNode.Attributes["penumbraSolarPower"].Value, typeof(double)); }
/// <summary> /// Constructor to initialize the python subsystem /// </summary> /// <param name="scriptedSubXmlNode"></param> /// <param name="dependencies"></param> /// <param name="asset"></param> public ScriptedSubsystem(XmlNode scriptedSubXmlNode, Dependency dependencies, Asset asset) { Asset = asset; GetSubNameFromXmlNode(scriptedSubXmlNode); string pythonFilePath ="", className = ""; XmlParser.ParseScriptedSrc(scriptedSubXmlNode, ref pythonFilePath, ref className); var engine = Python.CreateEngine(); var scope = engine.CreateScope(); var ops = engine.Operations; engine.ExecuteFile(pythonFilePath, scope); var pythonType = scope.GetVariable(className); _pythonInstance = ops.CreateInstance(pythonType, scriptedSubXmlNode, asset); Dictionary<string, Delegate> newDependencies = _pythonInstance.GetDependencyDictionary(); dependencies.Append(newDependencies); DependentSubsystems = new List<Subsystem>(); SubsystemDependencyFunctions = new Dictionary<string, Delegate>(); Delegate depCollector = _pythonInstance.GetDependencyCollector(); SubsystemDependencyFunctions.Add("DepCollector", depCollector); }
public Subsystem(XmlNode xmlNode, Dependency deps, Asset asset) { }
public TargetValueEvaluator(Dependency dependencies) { Dependencies = dependencies; }
public IMU(XmlNode SubNode, Dependency dependencies, Asset asset) : this(SubNode, asset) { DependentSubsystems = new List <Subsystem>(); SubsystemDependencyFunctions = new Dictionary <string, Delegate>(); }