Beispiel #1
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;
            }
        }
        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;
            }
        }
Beispiel #3
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;
            }
        }
        public void MWArray_GetField_Array_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   result = new MWLogicalArray(value);

            sa[f] = result;

            Assert.That(MWArrayExtensions.GetField(sa, f).Equals(result));
        }
        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));
        }
        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));
        }
        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));
        }
    // 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;
        }
    }
        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 }));
        }
Beispiel #10
0
 public Image addNoise(string type, Image src, double a, double b)
 {
     MWLogicalArray mw_print = new MWLogicalArray(Form1.print);
     MWArray Result = noise(type, new MWNumericArray(src.Array.Array), a, b, mw_print);
     Image res = new Image((double[,])((MWNumericArray)Result).ToArray(MWArrayComponent.Real));
     MWNumericArray tmp = new MWNumericArray(res.Array.Array);
     res.image = (MWArray)tmp;
     Result = null;
     tmp = null;
     GC.Collect();
     return res;
 }
        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));
        }
Beispiel #12
0
 public double[,] Adjust_BCS(double[,] matrix, bool isShowFig)
 {
     try
     {
         var arr = new MWNumericArray(matrix);
         var flag = new MWLogicalArray(isShowFig);
         var result = _lib.adjust_BCS(arr, flag).ToArray();
         return (double[,])result;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "TERS-MatlabApi");
         return null;
     }
 }
Beispiel #13
0
        public static void Analyze(System.ComponentModel.BackgroundWorker worker)
        {
            int i = 0;
            foreach (string file in Directory.GetFiles("C:\\Users\\Forpatril\\Documents\\Visual Studio 2010\\Projects\\Diploma_cs\\Images", "*.jpg"))
            {
                Image img = new Image(file);
                for (int w = 2; w < 35; w++)
                    for (int sig = 1; sig < w / 2; sig++)
                    {
                        filterclass fc = new filterclass();
                        Noise n = new Noise();
                        Image img_n = n.addNoise("gaussian", img, 0, 0.055);
                        double[] p = new double[] {w, sig, 0.2};
                        MWNumericArray parameters = new MWNumericArray(p);
                        MWLogicalArray mw_print = new MWLogicalArray(Form1.print);
                        MWArray[] Result = fc.filter2(2, img_n.image, "bilateral", parameters, mw_print);
                        MWNumericArray descriptor = null;
                        descriptor = (MWNumericArray)Result[0];
                        double[,] result = null;
                        result = (double[,])descriptor.ToArray(MWArrayComponent.Real);
                        Image ret = new Image(result);
                        MWNumericArray e_descriptor = null;
                        e_descriptor = (MWNumericArray)Result[1];
                        ret.Time = (double)e_descriptor.ToScalarDouble();

                        filterDataContext db = new filterDataContext();
                        psnrClass ps = new psnrClass();
                        double psnr = (double)((MWNumericArray)ps.psnr(ret.image, img.image)).ToScalarDouble();
                        db.add_line("bilateral", "gaussian", img.Height, img.Width, ret.Time, psnr, p[0], p[1], p[2]);


                        Result = null;
                        e_descriptor = null;
                        result = null;
                        parameters = null;
                        img_n = null;
                        n = null;
                        descriptor = null;
                        ret = null;
                        ps = null;
                        fc = null;
                        GC.Collect();
                    }
                worker.ReportProgress(i++);
                img = null;
                GC.Collect();
            }
        }
Beispiel #14
0
        public double[,] Criminisi(double[,] matrix, bool isShowFigure)
        {
            var arr = new MWNumericArray(matrix);
            var i = new MWLogicalArray(isShowFigure);
            try
            {
                return (double[,])_lib.Criminisi(4, arr, i)[0].ToArray();
            }
            catch (Exception ex)
            {
#if DEBUG
                MessageBox.Show(ex.Message, "TERS-MatlabApi");
#endif
                return null;
            }   
        }
Beispiel #15
0
 public double[,] Bwt_Notchfilt(double[,] matrix, int c, int d, bool showFig)
 {
     try
     {
         var arr = new MWNumericArray(matrix);
         var cc = new MWNumericArray(c);
         var dd = new MWNumericArray(d);
         var s = new MWLogicalArray(showFig);
         return (double[,])_lib.bwt_Notchfilt(3, arr, cc, dd, s)[2].ToArray();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "TERS-MatlabLib");
         return null;
     }
 }
Beispiel #16
0
 public double[,] DeconvR(double[,] matrix, int ds, int st, int tt, int np, bool bcsflag)
 {
     try
     {
         var arr = new MWNumericArray(matrix);
         var d = new MWNumericArray(ds);
         var s = new MWNumericArray(st);
         var t = new MWNumericArray(tt);
         var n = new MWNumericArray(np);
         var b = new MWLogicalArray(bcsflag);
         return (double[,])_lib.tip_deconvR(arr, d, s, t, n, b).ToArray();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "TERS-MatlabApi");
         return null;
     }
 }
        static void Main(string[] args)
        {
            CropAnalyzer crop = new CropAnalyzer();

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

            // Initialize optional input (by pair): verbose, TRUE/FALSE, vpd_min, vpd_min_val, vpd_max, vpd_max_val
            MWCharArray    verbose = "verbose", vpd_min = "vpd_min", vpd_max = "vpd_max";
            MWLogicalArray TRUE = new MWLogicalArray(true), FALSE = new MWLogicalArray(false);
            MWNumericArray vpd_min_val = 0.5, vpd_max_val = 1.2;

            // initialize output struct fields
            String[]      result_fields = { "type", "code", "state", "vpd", "vpd_min", "vpd_max", "hum_adj", "adjust_unit" };
            MWStructArray result        = new MWStructArray(1, result_fields.Count(), result_fields);

            //MWStructArray result = new MWStructArray();
            //MWNumericArray result_code = null;


            try
            {
                // Full usage: moisture.vpd_check(temp_c_in, rh_in, verbose, FALSE, vpd_min, vpd_min_val, vpd_max, vpd_max_val);
                temp_c_in   = 25;  // deg Celsius
                rh_in       = 70;  // %
                vpd_min_val = 0.5; // kPa
                vpd_max_val = 1.2; // kPa

                result      = (MWStructArray)crop.vpd_check(temp_c_in, rh_in, verbose, TRUE, vpd_min, vpd_min_val, vpd_max, vpd_max_val);
                result_code = (MWNumericArray)result.GetField("code");

                Console.WriteLine("RESULT CODE: " + result_code);
                Console.Write("\nPress any key to exit.");
                Console.ReadKey();
            }
            catch
            {
                throw;
            }
        }
Beispiel #18
0
 public Image RunFilter(Image src, int id)
 {
     filterDataContext db = new filterDataContext();
     double[] p = new double[Form1.pars.par[id].Length];
     p = Form1.pars.par[id];
     MWNumericArray parameters = new MWNumericArray(p);
     MWLogicalArray mw_print = new MWLogicalArray(Form1.print);
     MWArray[] Result = filter2(2, src.image, type[id], parameters, mw_print);
     MWNumericArray descriptor = null;
     descriptor = (MWNumericArray)Result[0];
     double[,] result = null;
     result = (double[,])descriptor.ToArray(MWArrayComponent.Real);
     Image res = new Image(result);
     MWNumericArray e_descriptor = null;
     e_descriptor = (MWNumericArray)Result[1];
     res.Time = WorkTime = (double)e_descriptor.ToScalarDouble();
     //db.add_b_res(src.Height, src.Height / src.Width, WorkTime, w, sigma[0], sigma[1]);
     Result = null;
     e_descriptor = null;
     result = null;
     parameters = null;
     GC.Collect();
     return res;
 }
        public void IdentifyComputation()
        {
            //set generic simulator behavior - strategy
            //GenericSimulator.SimulatorBehavior = new MySincSimulatorBehavior2(); //useless - matlab DLL have different static instance
            try
            {
                BroadcastIdentifyStateMessage("Starting calculation ..." + DateTime.Now);
                logger.Log(NLog.LogLevel.Info, "starting calculation ");
                //invoke matlab Identification algorithm - does it use the GenericSimulator instance configured before???
                Class1 class1 = new Class1();
                logger.Log(NLog.LogLevel.Debug, "class1 init");
                //set experiment variables and values
                MWArray v_names = new MWCellArray(new MWCharArray(Enumerable.ToArray(variable_names)));
                MWArray experiment = new MWNumericArray(variable_values);
                //set identification parameters
                MWArray p_names = new MWCellArray(new MWCharArray(Enumerable.ToArray(parameters.Keys)));
                //set worker nodes urls
                //var host = AppHostBase.Instance.Config.ServiceEndpointsMetadataConfig.DefaultMetadataUri;
                //var myrepository = ((AppHostBase) EndpointHost.AppHost).Container.Resolve<WorkersRepository>();
                //MWArray worker_urls = new MWCellArray(new MWCharArray(myrepository.GetByModelName(modelname).Select(x => x.RestUrl).ToArray()));

                MWArray p_val = new MWNumericArray(parameters.Values.Select(parameter => parameter.Value).ToArray());
                MWArray p_min = new MWNumericArray(parameters.Values.Select(parameter => parameter.Min).ToArray());
                MWArray p_max = new MWNumericArray(parameters.Values.Select(parameter => parameter.Max).ToArray());
                MWArray p_is_fixed =
                    new MWLogicalArray(parameters.Values.Select(parameter => !parameter.IsActive).ToArray());
                //calculate identification
                Stopwatch sw = Stopwatch.StartNew();
                if (IAgenerations > 0) //set gaoptions
                {
                    MWArray generations = new MWNumericArray(IAgenerations);
                    MWArray populationsize = new MWNumericArray(IApopulationsize);
                    MWArray tolfun = new MWNumericArray(IAtolfun);
                    class1.identify_gaoptimset(generations, populationsize, tolfun);
                } //otherwise the matlab algorithm has it's own default values
                logger.Log(NLog.LogLevel.Debug, "mwarray init");
                var result = class1.identify_main(experiment, p_names, p_val, p_min, p_max, p_is_fixed, v_names, modelname, masterserviceurl);
                logger.Log(NLog.LogLevel.Debug, "identify_main done");
                sw.Stop();

                /*var fitted_params = result[1];
                var fitted_param_L2Enorm = result[2];
                var fitted_variablevalues = result[3];
                 * */
                //string fittedparams = "";
                //for (int i=1;i < fitted_params.
                //BroadcastIdentifyStateMessage("Elapsed time " + sw.Elapsed.ToString() + " Results: " + result);//fitted_params+" "+fitted_param_L2Enorm+" " + fitted_variablevalues);
                //var myresult = result.ToArray();

                BroadcastIdentifyResult(result.ToArray(),sw.Elapsed,class1.identify_getssq(),class1.identify_getcomputationcycles(),class1.identify_getsimulationtime());

            }
            catch (Exception e)
            {
                //TODO handle matlab exception
                BroadcastIdentifyStateMessage(e.Message+e.StackTrace);
                logger.Log(NLog.LogLevel.Error,"exception during identification "+e.Message+" stacktrace:"+e.StackTrace,e);
                var f = e;//.InnerException;
                while (f.InnerException != null)
                {
                    f = f.InnerException;
                    logger.Log(NLog.LogLevel.Error, "innerexception:" + f.Message + " stacktrace:" + f.StackTrace, f);
                }
            }
            //            StopIdentify();
            FinalizeIdentify();
        }
Beispiel #20
-1
 public Image RunFilter(Image src)
 {
     filterDataContext db = new filterDataContext();
     double[] sigma = new double[] { 3.0, 3.0 };
     MWNumericArray mw_sigma = new MWNumericArray(sigma);
     MWLogicalArray mw_print = new MWLogicalArray(Form1.print);
     MWArray[] Result = filter2(2, src.image, type[2], mw_print);//spfilt(2, src.image, "median");
     MWNumericArray descriptor = null;
     descriptor = (MWNumericArray)Result[0];
     double[,] result = null;
     result = (double[,])descriptor.ToArray(MWArrayComponent.Real);
     Image res = new Image(result);
     MWNumericArray e_descriptor = null;
     e_descriptor = (MWNumericArray)Result[1];
     WorkTime = (double)e_descriptor.ToScalarDouble();
     //db.add_b_res(src.Height, src.Height / src.Width, WorkTime, w, sigma[0], sigma[1]);
     Result = null;
     e_descriptor = null;
     result = null;
     mw_sigma = null;
     GC.Collect();
     return res;
 }