コード例 #1
0
 /// <summary>
 /// copy constructor
 /// </summary>
 /// <param name="template">template</param>
 /// <param name="index">index of sensor</param>
 public sensor_config(sensor_config template, int index)
 {
     this.index = index;
     this._apply_real_sensor = template.apply_real_sensor;
     this.T_fil       = template.T_fil;
     this.noise_level = template.noise_level;
     this.y_min       = template.y_min;
     this.y_max       = template.y_max;
     this.drift       = template.drift;
     this.dT_calib    = template.dT_calib;
     this.t_calib     = template.t_calib;
 }
コード例 #2
0
        /// <summary>
        /// Creates a sensor with an id, an id_suffix and a name
        /// </summary>
        /// <param name="id">
        /// identical identifier (id) of the sensor
        /// e.g.: HRT, Snh3, Snh4, ...
        /// </param>
        /// <param name="name">arbitrary descriptive name of the sensor</param>
        /// <param name="id_suffix">
        /// id_suffix of the sensor, usually the id of the digester
        /// where the sensor is located, additionally in and out if necessary
        /// could also be: substratemix or storagetank
        /// </param>
        /// <param name="dimension">dimension of the sensor, default= 1</param>
        public sensor(string id, string name, string id_suffix, int dimension)
        {
            _id        = id;
            _name      = name;
            _id_suffix = id_suffix;
            _dimension = dimension;

            // create configs
            myConfigs = new sensor_config[_dimension];

            for (int iel = 0; iel < myConfigs.Length; iel++)
            {
                myConfigs[iel] = new sensor_config(iel);
            }
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="t">current simulation time in days</param>
        /// <param name="last_t">time of last recorded measurement [days]</param>
        /// <param name="value"></param>
        /// <param name="last_signals"></param>
        /// <param name="myConfigs">real sensor configurations for measurements in sensor</param>
        /// <returns></returns>
        public static physValue[] getNoisyMeasurement(double t, double last_t,
                                                      physValue[] value, physValue[] last_signals, sensor_config[] myConfigs)
        {
            if (value.Length != myConfigs.Length)
            {
                // ist der Fall für den fitness_sensor, dort dimension variabel
                //throw new exception(String.Format("value.Length != myConfigs.Length: {0} != {1}",
                //  value.Length, myConfigs.Length));

                return(value);
            }

            physValue[] value_noisy = new physValue[value.Length];

            // add noise and drift to each value in the array
            for (int isignal = 0; isignal < value.Length; isignal++)
            {
                sensor_config myConfig = myConfigs[isignal];

                // besetze mit nicht verauschten Werten
                value_noisy[isignal] = new physValue(value[isignal]); // default Werte

                if (t <= 1)                                           // set integrals to 0
                {
                    // setzt int_drift= 0, int_memory= 0 und is_in_calib= false
                    myConfig.reset();
                }

                if (myConfig.apply_real_sensor && t >= 1) // add noise and drift
                {
                    double signal = value[isignal].Value;

                    double last_signal = signal;

                    if (last_signals.Length > 0)
                    {
                        last_signal = last_signals[isignal].Value;
                    }

                    // add noise and drift to value
                    double sensor_signal = myConfig.generate_sensor_signal(signal, last_signal, t, last_t);

                    value_noisy[isignal].Value = sensor_signal;
                }
            }

            return(value_noisy);
        }
コード例 #4
0
        // -------------------------------------------------------------------------------------
        //                            !!! PUBLIC METHODS !!!
        // -------------------------------------------------------------------------------------

        // -------------------------------------------------------------------------------------
        //                              !!! GET METHODS !!!
        // -------------------------------------------------------------------------------------

        /// <summary>
        /// Read params using the given XML reader, which is reading a xml file.
        /// Reads one sensor, stops at end element of sensor.
        /// </summary>
        /// <param name="reader"></param>
        public virtual void getParamsFromXMLReader(ref XmlTextReader reader)
        {
            string xml_tag      = "";
            int    sensor_index = 0;

            bool do_while = true;

            while (reader.Read() && do_while)
            {
                switch (reader.NodeType)
                {
                case System.Xml.XmlNodeType.Element: // this knot is an element
                    xml_tag = reader.Name;

                    while (reader.MoveToNextAttribute())
                    { // read the attributes, here only the attribute of digester
                      // is of interest, all other attributes are ignored,
                      // actually there usally are no other attributes
                        if (xml_tag == "sensor_config" && reader.Name == "index")
                        {
                            // found a new sensor_config
                            sensor_index = System.Xml.XmlConvert.ToInt32(reader.Value);

                            if (sensor_index != -1)
                            {
                                myConfigs[sensor_index] = new sensor_config(sensor_index);

                                myConfigs[sensor_index].getParamsFromXMLReader(ref reader, sensor_index);
                            }
                            else // zeichen dafür, dass alle Configs identisch sind, und es nur
                            // eine config für alle dimensionen gibt, gut für hochdimensionalen
                            // sensor wie ADMparams sensor
                            {
                                myConfigs[0] = new sensor_config(0);

                                myConfigs[0].getParamsFromXMLReader(ref reader, 0);

                                for (int iindex = 1; iindex < dimension; iindex++)
                                {
                                    myConfigs[iindex] = new sensor_config(myConfigs[0], iindex);
                                }
                            }
                        }
                    }

                    break;

                case System.Xml.XmlNodeType.Text: // text, thus value, of each element

                    switch (xml_tag)
                    {
                    case "id_suffix":
                        _id_suffix = reader.Value;
                        break;

                    case "name":
                        _name = reader.Value;
                        break;

                    case "dimension":
                        _dimension = System.Xml.XmlConvert.ToInt32(reader.Value);

                        myConfigs = new sensor_config[dimension];

                        break;
                    }

                    break;

                case System.Xml.XmlNodeType.EndElement:
                    if (reader.Name == "sensor")
                    {
                        do_while = false;
                    }

                    break;
                }
            }
        }