Example #1
0
 public void addKey(StateVarKey<Matrix<double>> keyIn) {
     if (Mkeys == null) //Only construct what you need
     {
         Mkeys = new List<StateVarKey<Matrix<double>>>();
     }
     Mkeys.Add(keyIn);
 }
Example #2
0
 public void addKey(StateVarKey<Quat> keyIn) {
     if (Qkeys == null) //Only construct what you need
     {
         Qkeys = new List<StateVarKey<Quat>>();
     }
     Qkeys.Add(keyIn);
 }
Example #3
0
 /// <summary>
 /// Constraint to check a single value of the state of a group or single subsystem
 /// </summary>
 /// <param name="constraintXmlNode"></param>
 /// <param name="sub"></param>
 public SingleConstraint(XmlNode constraintXmlNode, Subsystem sub)
 {
     Subsystems = new List <Subsystem>()
     {
         sub
     };
     if (constraintXmlNode.ChildNodes[0] == null)
     {
         throw new MissingMemberException("Missing StateVarKey for Constraint!");
     }
     _key = new StateVarKey <T>(constraintXmlNode.ChildNodes[0], constraintXmlNode.ParentNode.Attributes["assetName"].Value.ToString());
     if (constraintXmlNode.Attributes["value"] == null)
     {
         throw new MissingFieldException("Missing Value Field for Constraint!");
     }
     _value = (T)Convert.ChangeType(constraintXmlNode.Attributes["value"].Value, typeof(T));
     if (constraintXmlNode.Attributes["type"] == null)
     {
         throw new MissingFieldException("Missing Type Field for Constraint!");
     }
     Type = (ConstraintType)Enum.Parse(typeof(ConstraintType), constraintXmlNode.Attributes["type"].Value);
     if (constraintXmlNode.Attributes["subsystemName"] == null)
     {
         throw new MissingMemberException("Missing Constraint Name");
     }
     Name = constraintXmlNode.Attributes["subsystemName"].Value.ToLower();
 }
Example #4
0
 /// <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));
 }
Example #5
0
        public void TemplatedGetProfileUnitTest()
        {
            SystemState state = new SystemState();
            HSFProfile<int> intProf = new HSFProfile<int>(0, 1);
            intProf.Add(1, 2);
            intProf.Add(2, -1);

            StateVarKey<int> intKey = new StateVarKey<int>("testIntVar");
            state.SetProfile(intKey, intProf);

            HSFProfile<double> doubleProf = new HSFProfile<double>(0, 1);
            doubleProf.Add(1, 2);
            doubleProf.Add(2, -1);

            StateVarKey<double> doubleKey = new StateVarKey<double>("testDoubleVar");
            state.SetProfile(doubleKey, doubleProf);

            HSFProfile<Matrix<double>> matrixProf = new HSFProfile<Matrix<double>>(0, new Matrix<double>(1, 2, 1));
            matrixProf.Add(1, new Matrix<double>(1, 2, 2));
            matrixProf.Add(2, new Matrix<double>(1, 2, -1));

            var matrixKey = new StateVarKey<Matrix<double>>("testMatrixVar");
            state.SetProfile(matrixKey, matrixProf);

            HSFProfile<int> newIntProf = state.GetProfile(intKey);
            HSFProfile<double> newDoubleProf = state.GetProfile(doubleKey);
            HSFProfile<Matrix<double>> newMatrixProf = state.GetProfile(matrixKey);

            Console.WriteLine();
        }
Example #6
0
 /// <summary>
 /// Constructor for scripted subsystems
 /// </summary>
 /// <param name="ADCSNode"></param>
 /// <param name="asset"></param>
 public ADCS(XmlNode ADCSNode, Asset asset)
 {
     Asset = asset;
     GetSubNameFromXmlNode(ADCSNode);
     POINTVEC_KEY = new StateVarKey<Matrix<double>>(Asset.Name + "." + "eci_pointing_vector(xyz)");
     addKey(POINTVEC_KEY);
 }
Example #7
0
 public void addKey(StateVarKey<double> keyIn) {
     if (Dkeys == null) //Only construct what you need
     {
         Dkeys = new List<StateVarKey<double>>();
     }
     Dkeys.Add(keyIn);
 }
Example #8
0
 public void addKey(StateVarKey<bool> keyIn) {
     if (Bkeys == null) //Only construct what you need
     {
         Bkeys = new List<StateVarKey<bool>>();
     }
     Bkeys.Add(keyIn);
 }
Example #9
0
 /// <summary>
 /// Constructor for scripted subsystems
 /// </summary>
 /// <param name="ADCSNode"></param>
 /// <param name="asset"></param>
 public ADCS(XmlNode ADCSNode, Asset asset)
 {
     Asset = asset;
     GetSubNameFromXmlNode(ADCSNode);
     POINTVEC_KEY = new StateVarKey <Matrix <double> >(Asset.Name + "." + "eci_pointing_vector(xyz)");
     addKey(POINTVEC_KEY);
 }
Example #10
0
 /// <summary>
 /// Constructor for scripted subsystem
 /// </summary>
 /// <param name="CommXmlNode"></param>
 /// <param name="asset"></param>
 public Comm(XmlNode CommXmlNode, Asset asset)
 {
     DefaultSubName = "Comm";
     Asset          = asset;
     GetSubNameFromXmlNode(CommXmlNode);
     DATARATE_KEY = new StateVarKey <double>(Asset.Name + "." + "datarate(mb/s)");
     addKey(DATARATE_KEY);
 }
Example #11
0
 /// <summary>
 /// Constructor for scripted subsystem
 /// </summary>
 /// <param name="CommXmlNode"></param>
 /// <param name="asset"></param>
 public Comm(XmlNode CommXmlNode, Asset asset)
 {
     DefaultSubName = "Comm";
     Asset = asset;
     GetSubNameFromXmlNode(CommXmlNode);
     DATARATE_KEY = new StateVarKey<double>(Asset.Name + "." + "datarate(mb/s)");
     addKey(DATARATE_KEY);
 }
Example #12
0
 /// <summary>
 /// Constructor for use by scripted subsystem
 /// </summary>
 /// <param name="SSDRXmlNode"></param>
 /// <param name="asset"></param>
 public SSDR(XmlNode SSDRXmlNode, 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);
 }
Example #13
0
        //maybe add this functionality to subsystem? but then we would need to pass the state to the constructor
        public static SystemState setInitialSystemState(List <XmlNode> ICNodes, Asset asset)
        {
            // Set up Subsystem Nodes, first loop through the assets in the XML model input file
            //int n = modelInputXMLNode.ChildNode("ASSET");
            SystemState state = new SystemState();

            foreach (XmlNode ICNode in ICNodes)
            {
                string type = ICNode.Attributes["type"].Value;
                string key  = asset.Name + "." + ICNode.Attributes["key"].Value.ToLower();
                if (type.Equals("Int"))
                {
                    int val;
                    Int32.TryParse(ICNode.Attributes["value"].Value, out val);
                    StateVarKey <int> svk = new StateVarKey <int>(key);
                    state.AddValue(svk, new KeyValuePair <double, int>(SimParameters.SimStartSeconds, val));
                }
                //else if (type.Equals("Float"))
                //{
                //    float val;
                //    float.TryParse(ICNode.Attributes["value"].Value.ToString(), out val);
                //    StateVarKey<double> svk = new StateVarKey<double>(key);
                //    state.addValue(svk, new KeyValuePair<double, double>(SimParameters.SimStartSeconds, val));
                //}
                else if (type.Equals("Double"))
                {
                    double val;
                    Double.TryParse(ICNode.Attributes["value"].Value, out val);
                    StateVarKey <double> svk = new StateVarKey <double>(key);
                    state.AddValue(svk, new KeyValuePair <double, double>(SimParameters.SimStartSeconds, val));
                }
                else if (type.Equals("Bool"))
                {
                    string val  = ICNode.Attributes["value"].Value;
                    bool   val_ = false;
                    if (val.Equals("True") || val.Equals("1"))
                    {
                        val_ = true;
                    }
                    StateVarKey <bool> svk = new StateVarKey <bool>(key);
                    state.AddValue(svk, new KeyValuePair <double, bool>(SimParameters.SimStartSeconds, val_));
                }
                else if (type.Equals("Matrix"))
                {
                    Matrix <double> val = new Matrix <double>(ICNode.Attributes["value"].Value);
                    StateVarKey <Matrix <double> > svk = new StateVarKey <Matrix <double> >(key);
                    state.AddValue(svk, new KeyValuePair <double, Matrix <double> >(SimParameters.SimStartSeconds, val));
                }
                else if (type.Equals("Quat"))
                {
                    // Quaternions still need an initializer from a string, like Matrices
                }
            }
            return(state);
        }
Example #14
0
 /// <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));
 }
Example #15
0
 public ADCS(XmlNode ADCSNode, Dependencies dependencies, Asset asset)
 {
     DefaultSubName = "Adcs";
     Asset          = asset;
     getSubNameFromXmlNode(ADCSNode);
     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", new Func <Event, HSFProfile <double> >(POWERSUB_PowerProfile_ADCSSUB));
 }
Example #16
0
 /// <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));
 }
Example #17
0
 /// <summary>
 /// Constructor for use by scripted subsystem
 /// </summary>
 /// <param name="SSDRXmlNode"></param>
 /// <param name="asset"></param>
 public SSDR(XmlNode SSDRXmlNode, 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);
 }
Example #18
0
        /**
         * Gets the Matrix value of the state at a certain time. If the exact time is not found, the data is
         * assumed to be on a zero-order hold, and the last value set is found.
         * @param key The Matrix state variable key that is being looked up.
         * @param time The time the value is looked up at.
         * @return A pair containing the last time the variable was set, and the matrix value.
         */
        public KeyValuePair <double, Matrix <double> > getValueAtTime(StateVarKey <Matrix <double> > key, double time)
        {
            HSFProfile <Matrix <double> > valueOut;

            if (Mdata.Count != 0)
            {                                             // Are there any Profiles in there?
                if (Mdata.TryGetValue(key, out valueOut)) //see if our key is in there
                {
                    return(valueOut.DataAtTime(time));
                }
            }
            return(Previous.getValueAtTime(key, time)); //either no profiles or none that match our keys, try finding it in the previous one
        }
Example #19
0
        /// <summary>
        ///  Gets the integer value of the state at a certain time.
        ///  If the exact time is not found, the data is assumed to be on a zero-order hold, and the last value set is found.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public KeyValuePair <double, bool> GetValueAtTime(StateVarKey <bool> key, double time)
        {
            HSFProfile <bool> valueOut;

            if (Bdata.Count != 0)
            {                                                                              // Are there any Profiles in there?
                if (Bdata.TryGetValue(key, out valueOut) && Bdata[key].LastTime() <= time) //see if our key is in there
                {
                    return(valueOut.DataAtTime(time));
                }
            }
            return(Previous.GetValueAtTime(key, time)); //either no profiles or none that match our keys, try finding it in the previous one
        }
Example #20
0
        /**
         * Gets the last Matrix value set for the given state variable key in the state. If no value is found
         * it checks the previous state, continuing all the way to the initial state.
         * @param key The Matrix state variable key that is being looked up.
         * @return A pair containing the last time the variable was set, and the Matrix value.
         */
        public KeyValuePair <double, Matrix <double> > getLastValue(StateVarKey <Matrix <double> > key)
        {
            HSFProfile <Matrix <double> > valueOut;

            if (Mdata.Count != 0)
            {                                             // Are there any Profiles in there?
                if (Mdata.TryGetValue(key, out valueOut)) //see if our key is in there
                {
                    return(valueOut.Last());              //found it, return it TODO: return last value or pair?
                }
            }
            return(Previous.getLastValue(key)); //either no profiles or none that match our keys, try finding it in the previous one
        }
Example #21
0
        /**
         * Adds a boolean Profile to the state with the given key. If no Profile exists, a new Profile is created
         * with the corresponding key. If a Profile exists with that key, the Profile is appended onto the end of the Profile.
         * @param key The key corresponding to the state variable.
         * @param profIn The Profile to be added to the boolean Profile.
         */
        public void addValue(StateVarKey <Matrix <double> > key, HSFProfile <Matrix <double> > profIn)
        {
            HSFProfile <Matrix <double> > valueOut;

            if (!Mdata.TryGetValue(key, out valueOut)) // If there's no Profile matching that key, insert a new one.
            {
                Mdata.Add(key, profIn);
            }
            else // Otherwise, add this data point to the existing Profile.
            {
                valueOut.Add(profIn);
            }
        }
Example #22
0
        /**
         * Returns the Mastrix Profile matching the key given. If no Profile is found, it goes back one Event
         * and checks again until it gets to the initial state.
         * @param key The Matrix state variable key that is being looked up.
         * @return The Profile saved in the state.
         */
        public HSFProfile <Matrix <double> > getProfile(StateVarKey <Matrix <double> > key)
        {
            HSFProfile <Matrix <double> > valueOut;

            if (Mdata.Count != 0)
            {                                             // Are there any Profiles in there?
                if (Mdata.TryGetValue(key, out valueOut)) //see if our key is in there
                {
                    return(valueOut);
                }
            }
            return(Previous.getProfile(key)); // This isn't the right profile, go back one and try it out!
        }
Example #23
0
        /**
         * Adds a Matrix Profile value pair to the state with the given key. If no Profile exists, a new Profile is created
         * with the corresponding key. If a Profile exists with that key, the pair is appended onto the end of the Profile.
         * Ensure that the Profile is still time ordered if this is the case.
         * @param key The key corresponding to the state variable.
         * @param pairIn The pair to be added to the matrix Profile.
         */
        public void addValue(StateVarKey <Matrix <double> > key, KeyValuePair <double, Matrix <double> > pairIn)
        {
            HSFProfile <Matrix <double> > valueIn = new HSFProfile <Matrix <double> >(pairIn);
            HSFProfile <Matrix <double> > valueOut;

            if (!Mdata.TryGetValue(key, out valueOut)) // If there's no Profile matching that key, insert a new one.
            {
                Mdata.Add(key, valueIn);
            }
            else // Otherwise, add this data point to the existing Profile.
            {
                valueOut.Add(pairIn); //TODO: make sure this is ok. was formally iterator.second.data
            }
        }
Example #24
0
        /**
         * Sets the Matrix Profile in the state with its matching key. If a Profile is found already under
         * that key, this will overwrite the old Profile.
         * @param key The Matrix state variable key that is being set.\
         * @param profIn The Matrix Profile being saved.
         */
        public void setProfile(StateVarKey <Matrix <double> > key, HSFProfile <Matrix <double> > profIn)
        {
            HSFProfile <Matrix <double> > valueOut;

            if (!Mdata.TryGetValue(key, out valueOut)) // If there's no Profile matching that key, insert a new one.
            {
                Mdata.Add(key, profIn);
            }
            else   // Otherwise, erase whatever is there, and insert a new one.
            {
                Mdata.Remove(key);
                Mdata.Add(key, profIn);
            }
        }
Example #25
0
        /// <summary>
        /// Sets the integer Profile in the state with its matching key. If a Profile is found already under
        /// that key, this will overwrite the old Profile.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="profIn"></param>
        public void SetProfile(StateVarKey <bool> key, HSFProfile <bool> profIn)
        {
            HSFProfile <bool> valueOut;

            if (!Bdata.TryGetValue(key, out valueOut)) // If there's no Profile matching that key, insert a new one.
            {
                Bdata.Add(key, profIn);
            }
            else   // Otherwise, erase whatever is there, and insert a new one.
            {
                Bdata.Remove(key);
                Bdata.Add(key, profIn);
            }
        }
Example #26
0
 /// <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));
 }
Example #27
0
 /// <summary>
 /// Constructor for built in subsystem
 /// </summary>
 /// <param name="PowerNode"></param>
 /// <param name="asset"></param>
 public Power(XmlNode PowerNode, 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);
     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));
 }
Example #28
0
 /// <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));
 }
Example #29
0
 public SSDR(XmlNode SSDRXmlNode, Dependencies 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", new Func <Event, HSFProfile <double> >(POWERSUB_PowerProfile_SSDRSUB));
     dependencies.Add("CommfromSSDR", new Func <Event, HSFProfile <double> >(COMMSUB_DataRateProfile_SSDRSUB));
     dependencies.Add("EvalfromSSDR", new Func <Event, double>(EVAL_DataRateProfile_SSDRSUB));
 }
Example #30
0
 /// <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));
 }
Example #31
0
        /// <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));
        }
Example #32
0
        /// <summary>
        /// Constructor for scripted subsystem
        /// </summary>
        /// <param name="EOSensorXmlNode"></param>
        /// <param name="asset"></param>
        public Antenna(XmlNode AntennaNode, Asset asset)
        {
            DefaultSubName = "Antenna";
            Asset          = asset;
            GetSubNameFromXmlNode(AntennaNode);

            /*double slewTime;
             * if (AntennaNode.Attributes["timetoslew"].Value != null)
             * {
             *  Double.TryParse(AntennaNode.Attributes["slewTime"].Value, out slewTime);
             *  _timetoslew = slewTime;
             * }*/
            ANTDATA_KEY      = new StateVarKey <Matrix <double> >(Asset.Name + "." + "antenna_data");
            ANTINCIDENCE_KEY = new StateVarKey <Matrix <double> >(Asset.Name + "." + "antenna_incidence");
            ANTSTRESS_KEY    = new StateVarKey <Matrix <double> >(Asset.Name + "." + "antenna_stress");
            addKey(ANTSTRESS_KEY);
            addKey(ANTINCIDENCE_KEY);
            addKey(ANTDATA_KEY);
        }
Example #33
0
 /// <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)
     {
         //Console.WriteLine("inside loop");
         _lowQualityPixels = (double)Convert.ChangeType(EOSensorXmlNode.Attributes["lowQualityPixels"].Value.ToString(), typeof(double));
     }
     if (EOSensorXmlNode.Attributes["lowQualityTime"] != 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));
 }
Example #34
0
        /*
         * Returns the Matrix Profile for this state and all previous states merged into one Profile
         * @param key The Matrix state variable key that is being looked up.
         * @return The full Profile
         */
        public HSFProfile <Matrix <double> > getFullProfile(StateVarKey <Matrix <double> > key)
        {
            HSFProfile <Matrix <double> > valueOut = new HSFProfile <Matrix <double> >();

            if (Mdata.Count != 0)
            {                             // Are there any Profiles in there?
                if (Mdata.TryGetValue(key, out valueOut))
                {                         //see if our key is in there
                    if (Previous != null) // Check whether we are at the first state
                    {
                        return(HSFProfile <Matrix <double> > .MergeProfiles(valueOut, Previous.getFullProfile(key)));
                    }
                    return(valueOut);
                }
            }
            if (Previous != null)
            {
                return(Previous.getFullProfile(key)); // If no data, return profile from previous states
            }
            return(valueOut);                         //return empty profile
        }
Example #35
0
 /// <summary>
 /// Constructor for built in subsystem
 /// </summary>
 /// <param name="PowerNode"></param>
 /// <param name="asset"></param>
 public Power(XmlNode PowerNode, 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);
     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));
     }
 }
Example #36
0
        /// <summary>
        /// Constructor for built in subsystems
        /// Defaults: Slew time: 10s
        /// </summary>
        /// <param name="AntennaNode"></param>
        /// <param name="dependencies"></param>
        /// <param name="asset"></param>
        public Antenna(XmlNode AntennaNode, Dependency dependencies, Asset asset)
        {
            DefaultSubName = "Antenna";
            Asset          = asset;
            GetSubNameFromXmlNode(AntennaNode);

            /*double slewTime;
             * if (AntennaNode.Attributes["timetoslew"].Value != null)
             * {
             *  Double.TryParse(AntennaNode.Attributes["slewTime"].Value, out slewTime);
             *  _timetoslew = slewTime;
             * }*/
            ANTDATA_KEY      = new StateVarKey <Matrix <double> >(Asset.Name + "." + "antenna_data");
            ANTINCIDENCE_KEY = new StateVarKey <Matrix <double> >(Asset.Name + "." + "antenna_incidence");
            ANTSTRESS_KEY    = new StateVarKey <Matrix <double> >(Asset.Name + "." + "antenna_stress");
            addKey(ANTSTRESS_KEY);
            addKey(ANTINCIDENCE_KEY);
            addKey(ANTDATA_KEY);
            DependentSubsystems          = new List <Subsystem>();
            SubsystemDependencyFunctions = new Dictionary <string, Delegate>();
            dependencies.Add("PowerfromAntenna" + "." + Asset.Name, new Func <Event, HSFProfile <double> >(POWERSUB_PowerProfile_ANTENNASUB));
            dependencies.Add("SSDRfromAntenna" + "." + Asset.Name, new Func <Event, HSFProfile <double> >(SSDRSUB_NewDataProfile_ANTENNASUB));
        }
Example #37
0
 /// <summary>
 /// Constructor for scripted subsystem
 /// </summary>
 /// <param name="EOSensorXmlNode"></param>
 /// <param name="asset"></param>
 public EOSensor(XmlNode EOSensorXmlNode, 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);
     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));
     }
 }
Example #38
0
 /// <summary>
 /// Constructor for scripted subsystem
 /// </summary>
 /// <param name="EOSensorXmlNode"></param>
 /// <param name="asset"></param>
 public EOSensor(XmlNode EOSensorXmlNode, 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);
     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));
 }
        public void TemplatedGetProfileUnitTest()
        {
            SystemState      state   = new SystemState();
            HSFProfile <int> intProf = new HSFProfile <int>(0, 1);

            intProf.Add(1, 2);
            intProf.Add(2, -1);

            StateVarKey <int> intKey = new StateVarKey <int>("testIntVar");

            state.setProfile(intKey, intProf);

            HSFProfile <double> doubleProf = new HSFProfile <double>(0, 1);

            doubleProf.Add(1, 2);
            doubleProf.Add(2, -1);

            StateVarKey <double> doubleKey = new StateVarKey <double>("testDoubleVar");

            state.setProfile(doubleKey, doubleProf);

            HSFProfile <Matrix <double> > matrixProf = new HSFProfile <Matrix <double> >(0, new Matrix <double>(1, 2, 1));

            matrixProf.Add(1, new Matrix <double>(1, 2, 2));
            matrixProf.Add(2, new Matrix <double>(1, 2, -1));

            var matrixKey = new StateVarKey <Matrix <double> >("testMatrixVar");

            state.setProfile(matrixKey, matrixProf);

            HSFProfile <int>              newIntProf    = state.GetProfile(intKey);
            HSFProfile <double>           newDoubleProf = state.GetProfile(doubleKey);
            HSFProfile <Matrix <double> > newMatrixProf = state.GetProfile(matrixKey);

            Console.WriteLine();
        }
Example #40
0
 /// <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));
     }
 }
Example #41
0
        public static bool setInitialSystemState(XmlNode modelInputXMLNode, List <SystemState> initialStateList)
        {
            Console.WriteLine("Setting initial state... ");
            // Set up Subsystem Nodes, first loop through the assets in the XML model input file
            //int n = modelInputXMLNode.ChildNode("ASSET");
            foreach (XmlNode assetNode in modelInputXMLNode["ASSET"].ChildNodes)
            {
                // Get the current Asset XML Node, create a new State corresponding to this Asset
                SystemState state = new SystemState();
                // Loop through all the of the Subsystems for this Asset
                foreach (XmlNode subNode in assetNode["SUBSYSTEM"].ChildNodes)
                {
                    // Loop through all the IC's in the current Subsystem XML Node, determine their type
                    // create the StateVarKey for it, and add the IC to the initial state
                    foreach (XmlNode ICNode in subNode["IC"].ChildNodes)
                    {
                        string type = ICNode.Attributes["type"].ToString();
                        string key  = ICNode.Attributes["key"].ToString();
                        if (type.Equals("Int"))
                        {
                            int val;
                            Int32.TryParse(ICNode.Attributes["value"].ToString(), out val);
                            StateVarKey <int> svk = new StateVarKey <int>(key);
                            state.addValue(svk, new KeyValuePair <double, int>(SimParameters.SimStartSeconds, val));
                        }
                        else if (type.Equals("Float"))
                        {
                            float val;
                            float.TryParse(ICNode.Attributes["value"].ToString(), out val);
                            StateVarKey <double> svk = new StateVarKey <double>(key);
                            state.addValue(svk, new KeyValuePair <double, double>(SimParameters.SimStartSeconds, val));
                        }
                        //else if (type.Equals("Double"))
                        //{
                        //    double val;
                        //    Double.TryParse(ICNode.Attributes["value"].ToString(), out val);
                        //    StateVarKey<float> svk = new StateVarKey<float>(key);
                        //    state.addValue(svk, new KeyValuePair<double, float>(SimParameters.SimStartSeconds, val));
                        //}
                        else if (type.Equals("Bool"))
                        {
                            string val  = ICNode.Attributes["value"].ToString();
                            bool   val_ = false;
                            if (val.Equals("True") || val.Equals("1"))
                            {
                                val_ = true;
                            }
                            StateVarKey <bool> svk = new StateVarKey <bool>(key);
                            state.addValue(svk, new KeyValuePair <double, bool>(SimParameters.SimStartSeconds, val_));
                        }
                        else if (type.Equals("Matrix"))
                        {
                            Matrix <double> val = new Matrix <double>(ICNode.Attributes["value"]);
                            StateVarKey <Matrix <double> > svk = new StateVarKey <Matrix <double> >(key);
                            state.addValue(svk, new KeyValuePair <double, Matrix <double> >(SimParameters.SimStartSeconds, val));
                        }
                        else if (type.Equals("Quat"))
                        {
                            // Quaternions still need an initializer from a string, like Matrices
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                initialStateList.Add(state);
            }

            return(true);
        }