コード例 #1
0
        // Generate the feature vector of the given image.
        public double[] GenerateFeature(short[,] pixelData)
        {
            // Initialize the parameters of feature (data).
            MWStructArray fea_first = new MWStructArray(1, 1, new string[] { "pixels", "maxsize" });
            fea_first.SetField("pixels", new MWNumericArray(pixelData));
            fea_first.SetField("maxsize", 75);

            // Initialize the parameters of dictionary.
            MWStructArray dic_first = new MWStructArray(1, 1, new string[] { "dicsize", "patchsize", "samplenum", "dic" });
            dic_first.SetField("dicsize", 200);
            dic_first.SetField("patchsize", 16);
            dic_first.SetField("samplenum", 100);
            MWArray array = new MWNumericArray(this.dict_dimension[0], this.dict_dimension[1], MatrixUtil.FlattenMatrix(this.dic, this.dict_dimension[0], this.dict_dimension[1]));
            dic_first.SetField("dic", array);

            // Orthogonal matching pursuit encoder
            Stopwatch ompTimer = Stopwatch.StartNew();

            MWArray rgbdfea = ompNormal.extract_feature_normal(fea_first, dic_first);

            ompTimer.Stop();

            Array feature = rgbdfea.ToArray();
            Console.WriteLine("Feature Extraction Time: {0} ms", ompTimer.ElapsedMilliseconds);

            double[] feature_vector = new double[feature.Length];
            for (int i = 0; i < feature.Length; i++)
                feature_vector[i] = System.Convert.ToDouble(feature.GetValue(i, 0));

            return feature_vector;
        }
コード例 #2
0
        static void Main(string[] args)
        {
            CropAnalyzer  crop_analyzer = new CropAnalyzer();
            MWStructArray result        = new MWStructArray();

            // LOAD CROP DATA
            String        path         = "C:\\Program Files\\NareTrends\\BandiCropAnalyzer\\application\\bandicrop_data.ini";
            MWCharArray   crop_inifile = path;
            MWStructArray crops_db     = (MWStructArray)crop_analyzer.load_crop_data(crop_inifile);

            string crop_name = "STRAWBERRY";

            // DO CROP ENVIRONMENT CHECK
            double temp = 4;
            double hum  = 80;

            result = (MWStructArray)crop_env_checker(crops_db, temp, hum, crop_name);

            // PARSE RESULTS FOR DISPLAY
            int    print_level = 2; // 0->1->2 : INCREASING VERBOSITY
            string result_out  = parse_results(result, print_level);

            // PERFORM STATUS CHECK + CONTROL ACTION
            double temp_in  = 4;
            double hum_in   = 80;
            double temp_out = -3;
            double hum_out  = 40;

            result = (MWStructArray)crop_env_controller(crops_db, crop_name, temp_in, hum_in, temp_out, hum_out);

            Console.WriteLine("\nPress any key to exit.");
            Console.ReadKey();
        }
コード例 #3
0
    static void Main()
    {
        BandiCropModule BCM = new BandiCropModule();

        //ConnectEyesen ce = new ConnectEyesen();
        //DevInfo dev = new DevInfo();

        // TEST CONNECTION
        //ce.ConnectToServer("192.168.1.222", 7777);
        //Console.WriteLine(ce.RecieveMassage());

        // RUN TEST
        //BCM.run_module_test();

        // LOAD CROP DATA
        MWStructArray crops_db = BCM.load_crop_db();

        // TEST DONG OBJECT TO APPLY CONTROLS
        DongConfig nare_testbed = new DongConfig(1);

        nare_testbed.name            = "NARE_TESTBED";
        nare_testbed.fan_total       = 5;
        nare_testbed.ch_exhaust_fans = new int[4] {
            1, 2, 3, 4
        };
        nare_testbed.ch_ceiling_vents_L1 = new int[1] {
            1
        };
        nare_testbed.ch_side_vents_L1 = new int[1] {
            2
        };
        nare_testbed.ch_heater = new int[1] {
            3
        };


        // SPECIFY DONG STATE AND CROP
        string    crop_name  = "TOMATO";
        DongState dong_state = new DongState();

        dong_state.temp_in    = 4;
        dong_state.temp_out   = -3;
        dong_state.hum_in     = 50;
        dong_state.hum_out    = 40;
        dong_state.hum_bed    = 30;
        dong_state.co2_supply = true;
        dong_state.rain       = true;

        // CHECK CROP STATUS
        MWStructArray env_status = BCM.crop_env_checker(crops_db, crop_name, dong_state);

        // CHECK FOR REQUIRED CONTROL ACTIONS
        MWStructArray control_actions = BCM.crop_env_controller(crops_db, crop_name, dong_state);

        // APPLY CONTROL TO NARE_TESTBED
        BCM.autoswitch_control(control_actions, nare_testbed);

        Console.WriteLine("\nPress any key to exit.");
        Console.ReadKey();
    }
コード例 #4
0
        // METHOD TO DO CONTROL ACTION BASED ON STATUS OUTPUT
        public static MWStructArray crop_env_controller(MWStructArray crops_db, string crop, double temp_in, double hum_in, double temp_out, double hum_out)
        {
            Console.WriteLine("\n======================= CROP CONTROLLER OUTPUT =======================");
            CropAnalyzer crop_controller = new CropAnalyzer();

            // Initialize checkers
            String[]      checker_names = { "vpd_check", "dewpoint_check", "crop_temp_check" };
            MWStructArray checker_list  = new MWStructArray(1, 1, checker_names);

            // Initialize required input: temp_c_in, rh_in, temp_c_out, rh_out
            MWNumericArray temp_c_in  = null;
            MWNumericArray rh_in      = null;
            MWNumericArray temp_c_out = null;
            MWNumericArray rh_out     = null;

            // Initialize optional inputs (by pair): verbose, TRUE/FALSE, vpd_min, vpd_min_val, vpd_max, vpd_max_val, dewtemp_offset, dewtemp_offset_val
            //MWCharArray vpd = "vpd", dewpoint = "dewpoint";
            MWCharArray    checkers = "checkers", verbose = "verbose", crop_name = "crop_name", crop_name_select = "";
            MWCharArray    vpd_min = "vpd_min", vpd_max = "vpd_max", dewtemp_offset = "dewtemp_offset";
            MWLogicalArray TRUE = new MWLogicalArray(true), FALSE = new MWLogicalArray(false);
            MWNumericArray vpd_min_val = 0.5, vpd_max_val = 1.2, dewtemp_offset_val = 1.0;

            // initialize output struct fields - FOR REFERENCE
            String[] vpd_check_fields       = { "type", "code", "state", "vpd", "vpd_min", "vpd_max", "hum_adj", "adjust_unit" };
            String[] dewpoint_check_fields  = { "type", "code", "state", "temp", "temp_dew", "dewtemp_offset", "adjust", "adjust_unit" };
            String[] crop_temp_check_fields = { "type", "code", "state", "temp", "temp_min", "temp_max", "adjust", "adjust_unit" };

            // Set checker options
            checker_list.SetField("vpd_check", TRUE);
            checker_list.SetField("dewpoint_check", TRUE);
            checker_list.SetField("crop_temp_check", TRUE);

            // Create struct for output
            MWStructArray control_action = new MWStructArray();

            try
            {
                // Full usage: crop.env_check(crops, temp_c_in, rh_in, crop_name, crop_name_select, checkers, checker_list, vpd_min, vpd_min_val, vpd_max, vpd_max_val, verbose, FALSE);
                crop_name_select = crop;
                temp_c_in        = temp_in;  // deg Celsius
                rh_in            = hum_in;   // %
                temp_c_out       = temp_out; // deg Celsius
                rh_out           = hum_out;  // %

                control_action = (MWStructArray)crop_controller.env_controller(crops_db, crop_name_select, temp_c_in, rh_in, temp_c_out, rh_out);

                Console.WriteLine("CONTROL ACTION: \n" + control_action);

                //Console.WriteLine("Press any key to exit.");
                //Console.ReadKey();

                return(control_action);
            }
            catch
            {
                throw;
            }
        }
コード例 #5
0
 private double ParseIndex(MWStructArray array)
 {
     if (array.IsField(fieldName: "index"))
     {
         var tmpIndex = (double[, ])array.GetField(fieldName: "index");
         return(tmpIndex[0, 0]);
     }
     return(double.NaN);
 }
コード例 #6
0
 private double ParseAmplitudeThreshold(MWStructArray array)
 {
     if (array.IsField(fieldName: "amp_thr"))
     {
         var tmpAmpThr = (double[, ])array.GetField(fieldName: "amp_thr");
         return(tmpAmpThr[0, 0]);
     }
     return(double.NaN);
 }
コード例 #7
0
 private double ParseVarianceThreshold(MWStructArray array)
 {
     if (array.IsField(fieldName: "var_thr"))
     {
         var tmpVarThr = (double[, ])array.GetField(fieldName: "var_thr");
         return(tmpVarThr[0, 0]);
     }
     return(double.NaN);
 }
コード例 #8
0
        static void Main(string[] args)
        {
            CropAnalyzer crop_analyzer = new CropAnalyzer();

            // Initialize checkers
            String[]      checker_names = { "vpd_check", "dewpoint_check", "crop_temp_check" };
            MWStructArray checker_list  = new MWStructArray(1, 1, checker_names);

            // Initialize required input: temp_c_in, rh_in
            MWNumericArray temp_c_in = null;
            MWNumericArray rh_in     = null;

            // Initialize optional inputs (by pair): verbose, TRUE/FALSE, vpd_min, vpd_min_val, vpd_max, vpd_max_val, dewtemp_offset, dewtemp_offset_val
            //MWCharArray vpd = "vpd", dewpoint = "dewpoint";
            MWCharArray    checkers = "checkers", verbose = "verbose", crop_name = "crop_name", crop_name_select = "";
            MWCharArray    vpd_min = "vpd_min", vpd_max = "vpd_max", dewtemp_offset = "dewtemp_offset";
            MWLogicalArray TRUE = new MWLogicalArray(true), FALSE = new MWLogicalArray(false);
            MWNumericArray vpd_min_val = 0.5, vpd_max_val = 1.2, dewtemp_offset_val = 1.0;

            // initialize output struct fields - FOR REFERENCE
            String[] vpd_check_fields       = { "type", "code", "state", "vpd", "vpd_min", "vpd_max", "hum_adj", "adjust_unit" };
            String[] dewpoint_check_fields  = { "type", "code", "state", "temp", "temp_dew", "dewtemp_offset", "adjust", "adjust_unit" };
            String[] crop_temp_check_fields = { "type", "code", "state", "temp", "temp_min", "temp_max", "adjust", "adjust_unit" };

            // Set checker options
            checker_list.SetField("vpd_check", TRUE);
            checker_list.SetField("dewpoint_check", TRUE);
            checker_list.SetField("crop_temp_check", TRUE);

            // Load crop data
            String        path         = "C:\\Program Files\\NareTrends\\BandiCropAnalyzer\\application\\bandicrop_data.ini";
            MWCharArray   crop_inifile = path;
            MWStructArray crops        = (MWStructArray)crop_analyzer.load_crop_data(crop_inifile);

            // Create struct for output
            MWStructArray  result      = new MWStructArray();
            MWNumericArray result_code = null;

            try
            {
                // Full usage: crop.env_check(crops, temp_c_in, rh_in, crop_name, crop_name_select, checkers, checker_list, vpd_min, vpd_min_val, vpd_max, vpd_max_val, verbose, FALSE);
                crop_name_select = "STRAWBERRY";
                temp_c_in        = 3;  // deg Celsius
                rh_in            = 40; // %

                result      = (MWStructArray)crop_analyzer.env_check(crops, temp_c_in, rh_in, crop_name, crop_name_select, checkers, checker_list);
                result_code = (MWNumericArray)result.GetField("code");

                Console.WriteLine("RESULT CODE: " + result_code);
                Console.Write("\nPress any key to exit.");
                Console.ReadKey();
            }
            catch
            {
                throw;
            }
        }
        public void MWArray_GetField_InvalidOperationException_NonExists_Field_Test()
        {
            var f  = "arrayfield";
            var sa = new MWStructArray(new int[] { 1 }, new string[] { f });

            sa[f] = new MWNumericArray();

            Assert.That(() => MWArrayExtensions.GetField(sa, "nonexists"), Throws.InvalidOperationException);
        }
コード例 #10
0
        // METHOD IMPLEMENTING THE ENVIRONMENT CHECK ROUTINES
        public static MWStructArray crop_env_checker(MWStructArray crops_db, double temp, double hum, string crop)
        {
            Console.WriteLine("\n======================= ENVIRONMENT ANALYSIS =======================");

            CropAnalyzer crop_analyzer = new CropAnalyzer();

            // Initialize checkers
            String[]      checker_names = { "vpd_check", "dewpoint_check", "crop_temp_check" };
            MWStructArray checker_list  = new MWStructArray(1, 1, checker_names);

            // Initialize required input: temp_c_in, rh_in
            MWNumericArray temp_c_in = null;
            MWNumericArray rh_in     = null;

            // Initialize optional inputs (by pair): verbose, TRUE/FALSE, vpd_min, vpd_min_val, vpd_max, vpd_max_val, dewtemp_offset, dewtemp_offset_val
            //MWCharArray vpd = "vpd", dewpoint = "dewpoint";
            MWCharArray    checkers = "checkers", verbose = "verbose", crop_name = "crop_name", crop_name_select = "";
            MWCharArray    vpd_min = "vpd_min", vpd_max = "vpd_max", dewtemp_offset = "dewtemp_offset";
            MWLogicalArray TRUE = new MWLogicalArray(true), FALSE = new MWLogicalArray(false);
            MWNumericArray vpd_min_val = 0.5, vpd_max_val = 1.2, dewtemp_offset_val = 1.0;

            // initialize output struct fields - FOR REFERENCE
            String[] vpd_check_fields       = { "type", "code", "state", "vpd", "vpd_min", "vpd_max", "hum_adj", "adjust_unit" };
            String[] dewpoint_check_fields  = { "type", "code", "state", "temp", "temp_dew", "dewtemp_offset", "adjust", "adjust_unit" };
            String[] crop_temp_check_fields = { "type", "code", "state", "temp", "temp_min", "temp_max", "adjust", "adjust_unit" };

            // Set checker options
            checker_list.SetField("vpd_check", TRUE);
            checker_list.SetField("dewpoint_check", TRUE);
            checker_list.SetField("crop_temp_check", TRUE);

            // Create struct for output
            MWStructArray  result      = new MWStructArray();
            MWNumericArray result_code = null;

            try
            {
                // Full usage: crop.env_check(crops, temp_c_in, rh_in, crop_name, crop_name_select, checkers, checker_list, vpd_min, vpd_min_val, vpd_max, vpd_max_val, verbose, FALSE);
                crop_name_select = crop;
                temp_c_in        = temp; // deg Celsius
                rh_in            = hum;  // %

                result      = (MWStructArray)crop_analyzer.env_check(crops_db, temp_c_in, rh_in, crop_name, crop_name_select, checkers, checker_list);
                result_code = (MWNumericArray)result.GetField("code");

                Console.WriteLine("RESULT CODE: " + result_code);
                //Console.WriteLine("Press any key to exit.");
                //Console.ReadKey();

                return(result);
            }
            catch
            {
                throw;
            }
        }
コード例 #11
0
        public void MWArray_GetFieldAsArray_Numeric_Single_Input()
        {
            var f     = "arrayfield";
            int value = 42;
            var sa    = new MWStructArray(new int[] { 1 }, new string[] { f });
            var na    = new MWNumericArray(value);

            sa[f] = na;

            Assert.That(MWArrayExtensions.GetFieldAsArray <double>(sa, f), Is.EquivalentTo(new int[] { value }));
        }
コード例 #12
0
        public void MWArray_GetFieldAsArray_Bool_Single_Input()
        {
            var  f     = "arrayfield";
            bool value = true;
            var  sa    = new MWStructArray(new int[] { 1 }, new string[] { f });
            var  na    = new MWLogicalArray(value);

            sa[f] = na;

            Assert.That(MWArrayExtensions.GetFieldAsArray <bool>(sa, f), Is.EquivalentTo(new bool[] { value }));
        }
コード例 #13
0
        public void MWArray_GetField_Bool_Input()
        {
            var  f      = "arrayfield";
            bool value  = true;
            var  sa     = new MWStructArray(new int[] { 1 }, new string[] { f });
            var  result = new MWLogicalArray(value);

            sa[f] = result;

            Assert.That(MWArrayExtensions.GetField(sa, f).Equals(result));
        }
コード例 #14
0
        public void MWArray_GetField_Char_Input()
        {
            var  f      = "arrayfield";
            char value  = 'c';
            var  sa     = new MWStructArray(new int[] { 1 }, new string[] { f });
            var  result = new MWCharArray(value);

            sa[f] = result;

            Assert.That(MWArrayExtensions.GetField(sa, f).Equals(result));
        }
コード例 #15
0
        public void MWArray_GetField_Array_String_Input()
        {
            var   f      = "arrayfield";
            Array value  = Enumerable.Range(0, 42).Select(i => i.ToString()).ToArray();
            var   sa     = new MWStructArray(new int[] { 1 }, new string[] { f });
            var   result = new MWCharArray(value);

            sa[f] = result;

            Assert.That(MWArrayExtensions.GetField(sa, f).Equals(result));
        }
コード例 #16
0
        public void MWArray_GetFieldAsSingleItem_Bool_Input()
        {
            var f     = "arrayfield";
            var value = false;
            var sa    = new MWStructArray(new int[] { 1 }, new string[] { f });
            var na    = new MWLogicalArray(value);

            sa[f] = na;

            Assert.That(MWArrayExtensions.GetFieldAsSingleItem <bool>(sa, f), Is.EqualTo(value));
        }
コード例 #17
0
        public void MWArray_GetFieldAsSingleItem_Numeric_Input()
        {
            var f     = "arrayfield";
            var value = 42.42f;
            var sa    = new MWStructArray(new int[] { 1 }, new string[] { f });
            var na    = new MWNumericArray(value);

            sa[f] = na;

            Assert.That(MWArrayExtensions.GetFieldAsSingleItem <double>(sa, f), Is.EqualTo(value));
        }
コード例 #18
0
    public MWStructArray load_crop_db()
    {
        CropAnalyzer crop_analyzer = new CropAnalyzer();

        // LOAD CROP DATA
        String        path         = "C:\\Program Files\\NareTrends\\BandiCropAnalyzer\\application\\bandicrop_data.ini";
        MWCharArray   crop_inifile = path;
        MWStructArray crops_db     = (MWStructArray)crop_analyzer.load_crop_data(crop_inifile);

        return(crops_db);
    }
コード例 #19
0
    // DO CONTROL ACTION BASED ON ENVIRONMENT CHECKING OUTPUT
    public MWStructArray crop_env_controller(MWStructArray crops_db, string crop, DongState sensors)

    {
        Console.WriteLine("\n======================= CROP CONTROLLER OUTPUT =======================");
        BandiCropAnalyzer.CropAnalyzer crop_controller = new BandiCropAnalyzer.CropAnalyzer();

        // Initialize checkers
        String[]      checker_names = { "vpd_check", "dewpoint_check", "crop_temp_check" };
        MWStructArray checker_list  = new MWStructArray(1, 1, checker_names);

        // Initialize optional inputs (by pair): verbose, TRUE/FALSE, vpd_min, vpd_min_val, vpd_max, vpd_max_val, dewtemp_offset, dewtemp_offset_val
        //MWCharArray vpd = "vpd", dewpoint = "dewpoint";
        MWCharArray    checkers = "checkers", verbose = "verbose", crop_name = "crop_name", crop_name_select = "";
        MWCharArray    rh_bed = "rh_bed", co2_supply = "co2_supply", rain = "rain";
        MWCharArray    vpd_min = "vpd_min", vpd_max = "vpd_max", dewtemp_offset = "dewtemp_offset";
        MWLogicalArray TRUE = new MWLogicalArray(true), FALSE = new MWLogicalArray(false);
        MWNumericArray vpd_min_val = 0.5, vpd_max_val = 1.2, dewtemp_offset_val = 1.0;

        // initialize output struct fields - FOR REFERENCE
        String[] vpd_check_fields       = { "type", "code", "state", "vpd", "vpd_min", "vpd_max", "hum_adj", "adjust_unit" };
        String[] dewpoint_check_fields  = { "type", "code", "state", "temp", "temp_dew", "dewtemp_offset", "adjust", "adjust_unit" };
        String[] crop_temp_check_fields = { "type", "code", "state", "temp", "temp_min", "temp_max", "adjust", "adjust_unit" };

        // Set checker options
        checker_list.SetField("vpd_check", TRUE);
        checker_list.SetField("dewpoint_check", TRUE);
        checker_list.SetField("crop_temp_check", TRUE);

        // Create struct for output
        MWStructArray control_action = new MWStructArray();

        try
        {
            // Full usage: crop.env_check(crops, temp_c_in, rh_in, crop_name, crop_name_select, checkers, checker_list, vpd_min, vpd_min_val, vpd_max, vpd_max_val, verbose, FALSE);
            crop_name_select = crop;
            MWNumericArray temp_c_in  = sensors.temp_in;    // deg Celsius
            MWNumericArray rh_in      = sensors.hum_in;     // %
            MWNumericArray temp_c_out = sensors.temp_out;   // deg Celsius
            MWNumericArray rh_out     = sensors.hum_out;    // %
            MWNumericArray hum_bed    = sensors.hum_bed;    // %
            MWLogicalArray co2_state  = sensors.co2_supply; // %
            MWLogicalArray rain_state = sensors.rain;       // %

            return(control_action = (MWStructArray)crop_controller.env_controller(crops_db, crop_name_select,
                                                                                  temp_c_in, rh_in, temp_c_out, rh_out,
                                                                                  rh_bed, hum_bed,
                                                                                  co2_supply, co2_state,
                                                                                  rain, rain_state));
        }
        catch
        {
            throw;
        }
    }
コード例 #20
0
        public void MWArray_GetFieldAsArray_Bool_Input()
        {
            var   f     = "arrayfield";
            Array value = Enumerable.Range(0, 42).Select(i => i % 2 == 0).ToArray();
            var   sa    = new MWStructArray(new int[] { 1 }, new string[] { f });
            var   na    = new MWLogicalArray(value);

            sa[f] = na;

            Assert.That(MWArrayExtensions.GetFieldAsArray <bool>(sa, f), Is.EquivalentTo(value));
        }
コード例 #21
0
        public void MWArray_GetField_Scalar_Short_Input()
        {
            var   f     = "shortfield";
            short value = 42;
            var   sa    = new MWStructArray(new int[] { 1 }, new string[] { f });

            sa[f] = value;

            var ra = new MWNumericArray(value);

            Assert.That(MWArrayExtensions.GetField(sa, f).Equals(ra));
        }
コード例 #22
0
        public void MWArray_GetFieldAsSingleItem_Numeric_Multiple_Input()
        {
            var   f     = "arrayfield";
            int   first = 0;
            Array value = Enumerable.Range(first, 42).ToArray();
            var   sa    = new MWStructArray(new int[] { 1 }, new string[] { f });
            var   na    = new MWNumericArray(value);

            sa[f] = na;

            Assert.That(MWArrayExtensions.GetFieldAsSingleItem <double>(sa, f), Is.EqualTo(first));
        }
コード例 #23
0
        public void MWArray_GetFieldAsSingleItem_Bool_Multiple_Input()
        {
            var   f     = "arrayfield";
            bool  first = 0 % 2 == 0;
            Array value = Enumerable.Range(0, 42).Select(i => i % 2 == 0).ToArray();
            var   sa    = new MWStructArray(new int[] { 1 }, new string[] { f });
            var   na    = new MWLogicalArray(value);

            sa[f] = na;

            Assert.That(MWArrayExtensions.GetFieldAsSingleItem <bool>(sa, f), Is.EqualTo(first));
        }
コード例 #24
0
 private int[] ParseMerged(MWStructArray array)
 {
     if (array.IsField(fieldName: "merged"))
     {
         var tmpMerged = (double[, ])array.GetField(fieldName: "merged");
         var merged    = new int[tmpMerged.Length];
         for (var i = 0; i < tmpMerged.Length; ++i)
         {
             merged[i] = (int)tmpMerged[0, i];
         }
         return(merged);
     }
     return(null);
 }
コード例 #25
0
 private bool[] ParseVarianceFilter(MWStructArray array)
 {
     if (array.IsField(fieldName: "var_filter"))
     {
         var tmpVarFilter = (bool[, ])array.GetField(fieldName: "var_filter");
         var varFilter    = new bool[tmpVarFilter.Length];
         for (var i = 0; i < tmpVarFilter.Length; ++i)
         {
             varFilter[i] = tmpVarFilter[i, 0];
         }
         return(varFilter);
     }
     return(null);
 }
コード例 #26
0
 private bool[] ParseAmplitudeFilter(MWStructArray array)
 {
     if (array.IsField(fieldName: "amp_filter"))
     {
         var tmpAmpFilter = (bool[, ])array.GetField(fieldName: "amp_filter");
         var ampFilter    = new bool[tmpAmpFilter.Length];
         for (var i = 0; i < tmpAmpFilter.Length; ++i)
         {
             ampFilter[i] = tmpAmpFilter[i, 0];
         }
         return(ampFilter);
     }
     return(null);
 }
コード例 #27
0
 private int[] ParsePartition(MWStructArray array)
 {
     if (array.IsField(fieldName: "partition"))
     {
         var tmpPartition = (double[, ])array.GetField(fieldName: "partition");
         var partition    = new int[tmpPartition.Length];
         for (var i = 0; i < tmpPartition.Length; ++i)
         {
             // -1 for indexing purposes (label should allow to check centroid)
             partition[i] = (int)tmpPartition[0, i] - 1;
         }
         return(partition);
     }
     return(null);
 }
コード例 #28
0
        /// <summary>
        /// Gets information about the image file
        /// </summary>
        public string GetImageInfo()
        {
            string info = "";

            try
            {
                MWArray res = new MWStructArray();
                res  = FEC.getImageInfo(this.imagePath.ToString());
                info = res.ToString();
                return(info);
            }
            catch (Exception ex)
            {
                return(info);
            }
        }
コード例 #29
0
 private DivikResult[] ParseSubregions(MWStructArray array)
 {
     if (array.IsField(fieldName: "subregions"))
     {
         var tmpSubregions = (MWCellArray)array.GetField(fieldName: "subregions");
         var subregions    = new DivikResult[tmpSubregions.NumberOfElements];
         for (var i = 0; i < tmpSubregions.NumberOfElements; ++i)
         {
             if (tmpSubregions[i + 1] is MWStructArray)
             {
                 subregions[i] = new DivikResult(matlabResult: tmpSubregions[i + 1]);
             }
         }
         return(subregions);
     }
     return(null);
 }
コード例 #30
0
 private double[,] ParseCentroids(MWStructArray array)
 {
     if (array.IsField(fieldName: "centroids"))
     {
         var transposed = (double[, ])array.GetField(fieldName: "centroids");
         var straight   = new double[transposed.GetLength(dimension: 1), transposed.GetLength(dimension: 0)];
         for (var i = 0; i < transposed.GetLength(dimension: 1); ++i)
         {
             for (var j = 0; j < transposed.GetLength(dimension: 0); ++j)
             {
                 straight[i, j] = transposed[j, i];
             }
         }
         return(straight);
     }
     return(null);
 }
コード例 #31
0
        public void MWArray_GetField_Composite_Field_Name_Input()
        {
            var f1 = "composite";
            var f2 = "field";

            var   f      = $"{f1}.{f2}";
            Array value  = Enumerable.Range(0, 42).ToArray();
            var   result = new MWNumericArray(value);

            var sa1 = new MWStructArray(new int[] { 1 }, new string[] { f1 });
            var sa2 = new MWStructArray(new int[] { 1 }, new string[] { f2 });

            sa1[f1] = sa2;
            sa2[f2] = result;

            Assert.That(MWArrayExtensions.GetField(sa1, f).Equals(result));
            Assert.That(MWArrayExtensions.GetField(sa2, f2).Equals(result));
            Assert.That(MWArrayExtensions.GetField(sa1, f1).Equals(sa2));
        }
コード例 #32
0
        //封装储热数据
        public MWStructArray[] saveH_pack()
        {
            //输入变量,结构数组
            string[] variableIn = new string[3];
            variableIn[0] = "charge";
            variableIn[1] = "H";
            variableIn[2] = "savedH";
            MWStructArray variableInStruct = new MWStructArray(1, 1, variableIn);
            variableInStruct.SetField(variableIn[0], simulatedData.Charge_HA);
            variableInStruct.SetField(variableIn[1], simulatedData.H_HA);
            variableInStruct.SetField(variableIn[2], simulatedData.SavedH_HA);

            //封装后的saveH输入变量
            string[] variableIn_pack = new string[1];
            variableIn_pack[0] = "saveh";
            MWStructArray simulatedData_saveH = new MWStructArray(1, 1, variableIn_pack);
            simulatedData_saveH.SetField(variableIn_pack[0], variableInStruct);

            //设备参数,结构数组
            string[] equipmentParameterIn = new string[3];
            equipmentParameterIn[0] = "maxH";
            equipmentParameterIn[1] = "etaIn";
            equipmentParameterIn[2] = "etaOut";
            MWStructArray equipmentParameterInStruct = new MWStructArray(1, 1, equipmentParameterIn);
            equipmentParameterInStruct.SetField(equipmentParameterIn[0], equipmentParameter.MaxH_HA);
            equipmentParameterInStruct.SetField(equipmentParameterIn[1], equipmentParameter.EtaInH_HA);
            equipmentParameterInStruct.SetField(equipmentParameterIn[2], equipmentParameter.EtaOutH_HA);

            //封装后的saveH设备参数
            string[] equipmentParameterIn_pack = new string[1];
            equipmentParameterIn_pack[0] = "saveh";
            MWStructArray equipmentParameter_saveH = new MWStructArray(1, 1, equipmentParameterIn_pack);
            equipmentParameter_saveH.SetField(equipmentParameterIn_pack[0], equipmentParameterInStruct);

            //返回数据
            MWStructArray[] structArray_Return = new MWStructArray[2];
            structArray_Return[0] = simulatedData_saveH;
            structArray_Return[1] = equipmentParameter_saveH;

            return structArray_Return;
        }
コード例 #33
0
        //封装储电数据
        public MWStructArray[] saveE_pack()
        {
            //输入变量,结构数组
            string[] variableIn = new string[4];
            variableIn[0] = "charge";
            variableIn[1] = "duration";
            variableIn[2] = "speed";
            variableIn[3] = "savedE";
            MWStructArray variableInStruct_saveE = new MWStructArray(1, 1, variableIn);
            variableInStruct_saveE.SetField(variableIn[0], simulatedData.Charge_EA);
            variableInStruct_saveE.SetField(variableIn[1], simulatedData.Duration_EA);
            variableInStruct_saveE.SetField(variableIn[2], simulatedData.Speed_EA);
            variableInStruct_saveE.SetField(variableIn[3], simulatedData.SavedE_EA);

            //封装后的saveE输入变量
            string[] variableIn_pack = new string[1];
            variableIn_pack[0] = "savee";
            MWStructArray simulatedData_saveE = new MWStructArray(1, 1, variableIn_pack);
            simulatedData_saveE.SetField(variableIn_pack[0], variableInStruct_saveE);

            //设备参数,结构数组
            string[] equipmentParameterIn = new string[5];
            equipmentParameterIn[0] = "maxE";
            equipmentParameterIn[1] = "maxInE";
            equipmentParameterIn[2] = "maxOutE";
            equipmentParameterIn[3] = "etaIn";
            equipmentParameterIn[4] = "etaOut";
            MWStructArray equipmentParameterInStruct_saveE = new MWStructArray(1, 1, equipmentParameterIn);
            equipmentParameterInStruct_saveE.SetField(equipmentParameterIn[0], equipmentParameter.MaxE_EA);
            equipmentParameterInStruct_saveE.SetField(equipmentParameterIn[1], equipmentParameter.MaxInE_EA);
            equipmentParameterInStruct_saveE.SetField(equipmentParameterIn[2], equipmentParameter.MaxOutE_EA);
            equipmentParameterInStruct_saveE.SetField(equipmentParameterIn[3], equipmentParameter.EtaInE_EA);
            equipmentParameterInStruct_saveE.SetField(equipmentParameterIn[4], equipmentParameter.EtaOutE_EA);

            //封装后的saveE设备参数
            string[] equipmentParameterIn_pack = new string[1];
            equipmentParameterIn_pack[0] = "savee";
            MWStructArray equipmentParameter_saveE = new MWStructArray(1, 1, equipmentParameterIn_pack);
            equipmentParameter_saveE.SetField(equipmentParameterIn_pack[0], equipmentParameterInStruct_saveE);

            //返回数据
            MWStructArray[] structArray_Return = new MWStructArray[2];
            structArray_Return[0] = simulatedData_saveE;
            structArray_Return[1] = equipmentParameter_saveE;

            return structArray_Return;
        }
コード例 #34
0
        //泛能机
        public double[] ueMachine(MWStructArray product)
        {
            //MWStructArray product = ctrlopt_Struct();

            MWStructArray[] data_ueMachine_pack = ueMachine_pack();
            MWStructArray variableInStruct = (MWStructArray)data_ueMachine_pack[0].GetField("uemachine");
            MWStructArray equipmentParameterInStruct = (MWStructArray)data_ueMachine_pack[1].GetField("uemachine");

            MWStructArray gear_uemachine_product = (MWStructArray)product.GetField("uemachine");
            string[] gear_uemachine_product_fieldNames = gear_uemachine_product.FieldNames;
            variableInStruct.SetField(gear_uemachine_product_fieldNames[0], (MWNumericArray)gear_uemachine_product.GetField(gear_uemachine_product_fieldNames[0]));

            //uemachine函数调用
            object[] dataOut = uec.uemachine(1, variableInStruct, equipmentParameterInStruct);
            MWStructArray dataOutStruct = (MWStructArray)dataOut[0];
            //consume数组
            MWStructArray consume = (MWStructArray)dataOutStruct.GetField("consume");
            string[] fieldName_Consume = consume.FieldNames;
            MWNumericArray consumeG = (MWNumericArray)consume.GetField("G");
            double[,] consumeG_Output = (double[,])consumeG.ToArray(MWArrayComponent.Real);
            //prdct数组
            MWStructArray prdct = (MWStructArray)dataOutStruct.GetField("prdct");
            string[] fieldName_prdct = prdct.FieldNames;
            MWNumericArray prdctE = (MWNumericArray)prdct.GetField("E");
            MWNumericArray prdctH = (MWNumericArray)prdct.GetField("H");
            double[,] prdctE_Output = (double[,])prdctE.ToArray(MWArrayComponent.Real);
            double[,] prdctH_Output = (double[,])prdctH.ToArray(MWArrayComponent.Real);

            //返回数据
            double[] ueMachine_Output = new double[3];
            ueMachine_Output[0] = consumeG_Output[0, 0];
            ueMachine_Output[1] = prdctE_Output[0, 0];
            ueMachine_Output[2] = prdctH_Output[0, 0];

            return ueMachine_Output;
        }
コード例 #35
0
        //封装光热数据
        public MWStructArray[] pt_pack()
        {
            //输入变量,结构数组
            string[] envrmtdata = new string[1];
            envrmtdata[0] = "lout";
            MWStructArray envrmtdataStruct = new MWStructArray(1, 1, envrmtdata);
            envrmtdataStruct.SetField(envrmtdata[0], simulatedData.Envrmtdata_lout_Heat);

            string[] variableIn = new string[2];
            variableIn[0] = "envrmtdata";
            variableIn[1] = "duration";
            MWStructArray variableInStruct = new MWStructArray(1, 1, variableIn);
            variableInStruct.SetField(variableIn[0], envrmtdataStruct);
            variableInStruct.SetField(variableIn[1], simulatedData.Duration_Heat);

            //封装后的pt输入变量
            string[] variableIn_pack = new string[1];
            variableIn_pack[0] = "pt";
            MWStructArray simulatedData_pt = new MWStructArray(1, 1, variableIn_pack);
            simulatedData_pt.SetField(variableIn_pack[0], variableInStruct);

            //设备参数,结构数组
            string[] equipmentParameterIn = new string[1];
            equipmentParameterIn[0] = "power";
            MWStructArray equipmentParameterInStruct = new MWStructArray(1, 1, equipmentParameterIn);
            equipmentParameterInStruct.SetField(equipmentParameterIn[0], equipmentParameter.Power_Heat);

            //封装后的pt设备参数
            string[] equipmentParameterIn_pack = new string[1];
            equipmentParameterIn_pack[0] = "pt";
            MWStructArray equipmentParameter_pt = new MWStructArray(1, 1, equipmentParameterIn_pack);
            equipmentParameter_pt.SetField(equipmentParameterIn_pack[0], equipmentParameterInStruct);

            //返回数据
            MWStructArray[] structArray_Return = new MWStructArray[2];
            structArray_Return[0] = simulatedData_pt;
            structArray_Return[1] = equipmentParameter_pt;

            return structArray_Return;
        }
コード例 #36
0
        //优化函数
        public ArrayList ctrlopt_Array(MWStructArray dataOutStruct)
        {
            //MWStructArray dataOutStruct = ctrlopt_Struct();

            //输出结构体的内层结构体
            MWStructArray savee = (MWStructArray)dataOutStruct.GetField("savee");
            MWStructArray saveh = (MWStructArray)dataOutStruct.GetField("saveh");
            MWStructArray pv = (MWStructArray)dataOutStruct.GetField("pv");
            MWStructArray pt = (MWStructArray)dataOutStruct.GetField("pt");
            //输出结构体的其他非嵌套成员
            MWNumericArray outsideE_dataOut = (MWNumericArray)dataOutStruct.GetField("outsideE");
            MWNumericArray outsideH_dataOut = (MWNumericArray)dataOutStruct.GetField("outsideH");

            MWStructArray uemachine_gear_dataOut = (MWStructArray)dataOutStruct.GetField("uemachine");
            MWStructArray gasboiler_gear_dataOut = (MWStructArray)dataOutStruct.GetField("gasboiler");

            string[] fieldName_savee = savee.FieldNames;
            string[] fieldName_saveh = saveh.FieldNames;
            string[] fieldName_pv = pv.FieldNames;
            string[] fieldName_pt = pt.FieldNames;

            //内层结构体Savee
            MWNumericArray charge_Savee = (MWNumericArray)savee.GetField("charge");
            MWNumericArray savedE_Savee = (MWNumericArray)savee.GetField("savedE");
            MWNumericArray deltaE_Savee = (MWNumericArray)savee.GetField("IOE");
            //内层结构体Saveh
            MWNumericArray charge_Saveh = (MWNumericArray)saveh.GetField("charge");
            MWNumericArray savedH_Saveh = (MWNumericArray)saveh.GetField("savedH");
            MWNumericArray deltaH_Saveh = (MWNumericArray)saveh.GetField("IOH");
            //内层结构体Pv
            MWNumericArray consume_Pv = (MWNumericArray)pv.GetField("consume");
            MWNumericArray save_Pv = (MWNumericArray)pv.GetField("save");
            //内层结构体Pt
            MWNumericArray consume_Pt = (MWNumericArray)pt.GetField("consume");
            MWNumericArray save_Pt = (MWNumericArray)pt.GetField("save");
            //非嵌套部分
            MWNumericArray uemachine_gear = (MWNumericArray)uemachine_gear_dataOut.GetField("gear");
            MWNumericArray gasboiler_gear = (MWNumericArray)gasboiler_gear_dataOut.GetField("gear");

            //数据类型转换
            double[,] charge_Savee_Output = (double[,])charge_Savee.ToArray(MWArrayComponent.Real);
            double[,] savedE_Savee_Output = (double[,])savedE_Savee.ToArray(MWArrayComponent.Real);
            double[,] deltaE_Savee_Output = (double[,])deltaE_Savee.ToArray(MWArrayComponent.Real);

            double[,] charge_Saveh_Output = (double[,])charge_Saveh.ToArray(MWArrayComponent.Real);
            double[,] savedH_Saveh_Output = (double[,])savedH_Saveh.ToArray(MWArrayComponent.Real);
            double[,] deltaH_Saveh_Output = (double[,])deltaH_Saveh.ToArray(MWArrayComponent.Real);

            double[,] consume_Pv_Output = (double[,])consume_Pv.ToArray(MWArrayComponent.Real);
            double[,] save_Pv_Output = (double[,])save_Pv.ToArray(MWArrayComponent.Real);

            double[,] consume_Pt_Output = (double[,])consume_Pt.ToArray(MWArrayComponent.Real);
            double[,] save_Pt_Output = (double[,])save_Pt.ToArray(MWArrayComponent.Real);

            double[,] outsideE_Output = (double[,])outsideE_dataOut.ToArray(MWArrayComponent.Real);
            double[,] outsideH_Output = (double[,])outsideH_dataOut.ToArray(MWArrayComponent.Real);
            double[,] uemachine_gear_Output = (double[,])uemachine_gear.ToArray(MWArrayComponent.Real);
            double[,] gasboiler_gear_Output = (double[,])gasboiler_gear.ToArray(MWArrayComponent.Real);

            //返回数据
            ArrayList ctrlopt_Output = new ArrayList();

            ctrlopt_Output.Add(charge_Savee_Output[0, 0]);
            ctrlopt_Output.Add(savedE_Savee_Output[0, 0]);
            ctrlopt_Output.Add(deltaE_Savee_Output[0, 0]);

            ctrlopt_Output.Add(charge_Saveh_Output[0, 0]);
            ctrlopt_Output.Add(savedH_Saveh_Output[0, 0]);
            ctrlopt_Output.Add(deltaH_Saveh_Output[0, 0]);

            ctrlopt_Output.Add(consume_Pv_Output[0, 0]);
            ctrlopt_Output.Add(save_Pv_Output[0, 0]);

            ctrlopt_Output.Add(consume_Pt_Output[0, 0]);
            ctrlopt_Output.Add(save_Pt_Output[0, 0]);

            ctrlopt_Output.Add(outsideE_Output[0, 0]);
            ctrlopt_Output.Add(outsideH_Output[0, 0]);
            ctrlopt_Output.Add(uemachine_gear_Output[0, 0]);
            ctrlopt_Output.Add(gasboiler_gear_Output[0, 0]);

            return ctrlopt_Output;
        }
コード例 #37
0
        //优化函数
        public MWStructArray ctrlopt_Struct()
        {
            //能源需求参数
            string[] need = new string[3];
            need[0] = "E";
            need[1] = "H";
            need[2] = "mode";
            MWStructArray needStruct = new MWStructArray(1, 1, need);
            needStruct.SetField(need[0], energyNeed.Electricity_Need);
            needStruct.SetField(need[1], energyNeed.Heat_Need);
            needStruct.SetField(need[2], energyNeed.Mode);

            //能源价格参数
            double price_E = 0.55;
            double price_H = 0.16;
            double price_G = 0.24;

            double mode = energyNeed.Mode;

            if (mode == 1)
            {
                price_E = simulatedData.Price_E;
                price_H = simulatedData.Price_H;
                price_G = simulatedData.Price_G;
            }
            else if (mode == 2)
            {
                price_E = 1;
                price_H = 0.28;
                price_G = 9.78;
            }
            else if (mode == 4)
            {
                price_E = 0.1384;
                price_H = 0.0398;
                price_G = 0.8218;
            }

            string[] price = new string[3];
            price[0] = "E";
            price[1] = "H";
            price[2] = "G";
            MWStructArray priceStruct = new MWStructArray(1, 1, price);
            priceStruct.SetField(price[0], price_E);
            priceStruct.SetField(price[1], price_H);
            priceStruct.SetField(price[2], price_G);

            //参数封装格式定义
            MWStructArray[] data_pv_pack = pv_pack();
            MWStructArray[] data_pt_pack = pt_pack();
            MWStructArray[] data_saveE_pack = saveE_pack();
            MWStructArray[] data_saveH_pack = saveH_pack();
            MWStructArray[] data_ueMachine = ueMachine_pack();
            MWStructArray[] data_gasBoiler = gasBoiler_pack();

            string[] variable = new string[7];
            variable[0] = "pv";
            variable[1] = "pt";
            variable[2] = "savee";
            variable[3] = "saveh";
            variable[4] = "uemachine";
            variable[5] = "gasboiler";
            variable[6] = "price";

            //输入变量提取            
            MWStructArray variableInStruct = new MWStructArray(1, 1, variable);
            variableInStruct.SetField(variable[0], data_pv_pack[0].GetField(variable[0]));
            variableInStruct.SetField(variable[1], data_pt_pack[0].GetField(variable[1]));
            variableInStruct.SetField(variable[2], data_saveE_pack[0].GetField(variable[2]));
            variableInStruct.SetField(variable[3], data_saveH_pack[0].GetField(variable[3]));
            variableInStruct.SetField(variable[4], data_ueMachine[0].GetField(variable[4]));
            variableInStruct.SetField(variable[5], data_gasBoiler[0].GetField(variable[5]));
            variableInStruct.SetField(variable[6], priceStruct);

            //设备参数提取
            MWStructArray equipmentParameterInStruct = new MWStructArray(1, 1, variable);
            equipmentParameterInStruct.SetField(variable[0], data_pv_pack[1].GetField(variable[0]));
            equipmentParameterInStruct.SetField(variable[1], data_pt_pack[1].GetField(variable[1]));
            equipmentParameterInStruct.SetField(variable[2], data_saveE_pack[1].GetField(variable[2]));
            equipmentParameterInStruct.SetField(variable[3], data_saveH_pack[1].GetField(variable[3]));
            equipmentParameterInStruct.SetField(variable[4], data_ueMachine[1].GetField(variable[4]));
            equipmentParameterInStruct.SetField(variable[5], data_gasBoiler[1].GetField(variable[5]));

            //函数调用
            object[] dataOut = uec.newctrlopt(1, needStruct, variableInStruct, equipmentParameterInStruct);
            //输出结果为嵌套结构数组,类型转换
            MWStructArray dataOutStruct = (MWStructArray)dataOut[0];
            string[] fieldName = dataOutStruct.FieldNames;

            return dataOutStruct;
        }
コード例 #38
0
        //补燃锅炉
        public double[] gasBoiler(MWStructArray product)
        {
            //MWStructArray product = ctrlopt_Struct();

            MWStructArray[] data_gasBoiler_pack = gasBoiler_pack();
            MWStructArray variableInStruct = (MWStructArray)data_gasBoiler_pack[0].GetField("gasboiler");
            MWStructArray equipmentParameterInStruct = (MWStructArray)data_gasBoiler_pack[1].GetField("gasboiler");

            //档位赋值
            MWStructArray gear_gasboiler_product = (MWStructArray)product.GetField("gasboiler");
            string[] gear_gasboiler_product_fieldNames = gear_gasboiler_product.FieldNames;
            variableInStruct.SetField(gear_gasboiler_product_fieldNames[0], (MWNumericArray)gear_gasboiler_product.GetField(gear_gasboiler_product_fieldNames[0]));

            //函数调用
            object[] dataOut = uec.gasboiler(1, variableInStruct, equipmentParameterInStruct);
            MWStructArray dataOutStruct = (MWStructArray)dataOut[0];
            string[] fieldName = dataOutStruct.FieldNames;
            //将输出由MWStructArray类型转化为MWNumericArray类型
            MWStructArray prdct = (MWStructArray)dataOutStruct.GetField("prdct");
            MWStructArray consume = (MWStructArray)dataOutStruct.GetField("consume");
            string[] prdctFieldName = prdct.FieldNames;
            string[] consumeFieldName = consume.FieldNames;

            //将输出由MWNumericArray类型转化为double类型(中间需要转化为Array类型)
            MWNumericArray prdctH = (MWNumericArray)prdct.GetField("H");
            MWNumericArray consumeG = (MWNumericArray)consume.GetField("G");

            double[,] prdctH_Output = (double[,])prdctH.ToArray(MWArrayComponent.Real);
            double[,] consumeG_Output = (double[,])consumeG.ToArray(MWArrayComponent.Real);

            //返回数据
            double[] gasBoiler_Output = new double[2];
            gasBoiler_Output[0] = prdctH_Output[0, 0];
            gasBoiler_Output[1] = consumeG_Output[0, 0];

            return gasBoiler_Output;
        }
コード例 #39
0
        //设备效率
        public double[] etacal(MWStructArray product)
        {
            //MWStructArray product = ctrlopt_Struct();

            //能源需求参数
            string[] need = new string[3];
            need[0] = "E";
            need[1] = "H";
            need[2] = "mode";
            MWStructArray needStruct = new MWStructArray(1, 1, need);
            needStruct.SetField(need[0], energyNeed.Electricity_Need);
            needStruct.SetField(need[1], energyNeed.Heat_Need);
            needStruct.SetField(need[2], energyNeed.Mode);

            //参数封装格式定义
            MWStructArray[] data_pv_pack = pv_pack();
            MWStructArray[] data_pt_pack = pt_pack();
            MWStructArray[] data_saveE_pack = saveE_pack();
            MWStructArray[] data_saveH_pack = saveH_pack();
            MWStructArray[] data_ueMachine = ueMachine_pack();
            MWStructArray[] data_gasBoiler = gasBoiler_pack();

            string[] variable = new string[7];
            variable[0] = "pv";
            variable[1] = "pt";
            variable[2] = "savee";
            variable[3] = "saveh";
            variable[4] = "uemachine";
            variable[5] = "gasboiler";
            variable[6] = "price";

            //输入变量提取
            MWStructArray variable_uemachine = (MWStructArray)data_ueMachine[0].GetField(variable[4]);
            MWStructArray variable_gasboiler = (MWStructArray)data_gasBoiler[0].GetField(variable[5]);

            //档位重新赋值
            MWStructArray gear_uemachine_product = (MWStructArray)product.GetField("uemachine");
            string[] gear_uemachine_product_fieldNames = gear_uemachine_product.FieldNames;
            variable_uemachine.SetField(gear_uemachine_product_fieldNames[0], (MWNumericArray)gear_uemachine_product.GetField(gear_uemachine_product_fieldNames[0]));

            MWStructArray gear_gasboiler_product = (MWStructArray)product.GetField("gasboiler");
            string[] gear_gasboiler_product_fieldNames = gear_gasboiler_product.FieldNames;
            variable_gasboiler.SetField(gear_gasboiler_product_fieldNames[0], (MWNumericArray)gear_gasboiler_product.GetField(gear_gasboiler_product_fieldNames[0]));

            //内层结构数组gas定义 与档位对应的数组
            double[] gas_gear_Boiler = new double[3];
            gas_gear_Boiler[0] = equipmentParameter.Gas_gear_Boiler_1;
            gas_gear_Boiler[1] = equipmentParameter.Gas_gear_Boiler_2;
            gas_gear_Boiler[2] = equipmentParameter.Gas_gear_Boiler_3;

            string[] equipmentParameter_Gas = new string[1];
            equipmentParameter_Gas[0] = "gear";
            MWStructArray gas = new MWStructArray(1, 1, equipmentParameter_Gas);
            gas.SetField(equipmentParameter_Gas[0], (MWNumericArray)gas_gear_Boiler);

            //设备参数提取
            MWStructArray equipmentParameterInStruct = new MWStructArray(1, 1, variable);
            equipmentParameterInStruct.SetField(variable[0], data_pv_pack[1].GetField(variable[0]));
            equipmentParameterInStruct.SetField(variable[1], data_pt_pack[1].GetField(variable[1]));
            equipmentParameterInStruct.SetField(variable[2], data_saveE_pack[1].GetField(variable[2]));
            equipmentParameterInStruct.SetField(variable[3], data_saveH_pack[1].GetField(variable[3]));
            equipmentParameterInStruct.SetField(variable[4], data_ueMachine[1].GetField(variable[4]));
            equipmentParameterInStruct.SetField(variable[5], data_gasBoiler[1].GetField(variable[5]));

            //函数调用
            MWNumericArray dataOut = (MWNumericArray)uec.etacal(product, needStruct, variable_uemachine, variable_gasboiler, equipmentParameterInStruct);
            double[,] dataOutArray = (double[,])dataOut.ToArray(MWArrayComponent.Real);

            double[] etacal_Output = new double[3];
            etacal_Output[0] = dataOutArray[0, 0];
            etacal_Output[1] = dataOutArray[1, 0];
            etacal_Output[2] = dataOutArray[2, 0];

            return etacal_Output;
        }
コード例 #40
0
        //封装补燃锅炉数据
        public MWStructArray[] gasBoiler_pack()
        {
            //输入变量,结构数组
            string[] variableIn = new string[2];
            variableIn[0] = "gear";
            variableIn[1] = "duration";
            MWStructArray variableInStruct = new MWStructArray(1, 1, variableIn);
            variableInStruct.SetField(variableIn[0], simulatedData.Gear_Boiler);
            variableInStruct.SetField(variableIn[1], simulatedData.Duration_Boiler);

            //封装后的gasBoiler输入变量
            string[] variableIn_pack = new string[1];
            variableIn_pack[0] = "gasboiler";
            MWStructArray simulatedData_gasBoiler = new MWStructArray(1, 1, variableIn_pack);
            simulatedData_gasBoiler.SetField(variableIn_pack[0], variableInStruct);

            //设备参数,嵌套结构数组
            //内层结构数组powerH定义 与档位对应的数组
            double[] powerH_gear_Boiler = new double[3];
            powerH_gear_Boiler[0] = equipmentParameter.PowerH_gear_Boiler_1;
            powerH_gear_Boiler[1] = equipmentParameter.PowerH_gear_Boiler_2;
            powerH_gear_Boiler[2] = equipmentParameter.PowerH_gear_Boiler_3;

            string[] equipmentParameter_PowerH = new string[1];
            equipmentParameter_PowerH[0] = "gear";
            MWStructArray powerH = new MWStructArray(1, 1, equipmentParameter_PowerH);
            powerH.SetField(equipmentParameter_PowerH[0], (MWNumericArray)powerH_gear_Boiler);

            //内层结构数组gas定义 与档位对应的数组
            double[] gas_gear_Boiler = new double[3];
            gas_gear_Boiler[0] = equipmentParameter.Gas_gear_Boiler_1;
            gas_gear_Boiler[1] = equipmentParameter.Gas_gear_Boiler_2;
            gas_gear_Boiler[2] = equipmentParameter.Gas_gear_Boiler_3;

            string[] equipmentParameter_Gas = new string[1];
            equipmentParameter_Gas[0] = "gear";
            MWStructArray gas = new MWStructArray(1, 1, equipmentParameter_Gas);
            gas.SetField(equipmentParameter_Gas[0], (MWNumericArray)gas_gear_Boiler);

            //设备参数,结构数组
            string[] equipmentParamaterIn = new string[2];
            equipmentParamaterIn[0] = "powerH";
            equipmentParamaterIn[1] = "gas";
            MWStructArray equipmentParameterInStruct = new MWStructArray(1, 1, equipmentParamaterIn);
            equipmentParameterInStruct.SetField(equipmentParamaterIn[0], powerH);
            equipmentParameterInStruct.SetField(equipmentParamaterIn[1], gas);

            //封装后的ueMachine设备参数
            string[] equipmentParameterIn_pack = new string[1];
            equipmentParameterIn_pack[0] = "gasboiler";
            MWStructArray equipmentParameter_gasboiler = new MWStructArray(1, 1, equipmentParameterIn_pack);
            equipmentParameter_gasboiler.SetField(equipmentParameterIn_pack[0], equipmentParameterInStruct);

            //返回数据
            MWStructArray[] structArray_Return = new MWStructArray[2];
            structArray_Return[0] = simulatedData_gasBoiler;
            structArray_Return[1] = equipmentParameter_gasboiler;

            return structArray_Return;
        }