예제 #1
0
        public static void init_station(fang g)
        {
            string station_path = g.station_path;

            Console.WriteLine("station_path !" + station_path);
            FileStream station_fs = new FileStream(station_path, FileMode.Open, FileAccess.Read);

            g.init_station();
            csv_log.csv2dt(station_fs, 0, g.dt_station);

            config.station       = Convert.ToInt32(g.dt_station.Rows[0]["Station"]);
            config.channel       = Convert.ToInt32(g.dt_station.Rows[0]["Channel"]);
            config.auto_start    = Convert.ToInt32(g.dt_station.Rows[0]["auto_start"]);
            config.single_module = Convert.ToInt32(g.dt_station.Rows[0]["single_module"]);
            config.test_only     = Convert.ToInt32(g.dt_station.Rows[0]["test_only"]);
            config.comport       = g.dt_station.Rows[0]["comport"].ToString();
            config.c_check       = Convert.ToInt32(g.dt_station.Rows[0]["c_check"]);
            config.v_check       = Convert.ToInt32(g.dt_station.Rows[0]["v_check"]);
            config.locked        = Convert.ToInt32(g.dt_station.Rows[0]["locked"]);
            config.working_port  = g.dt_station.Rows[0]["working_port"].ToString();
            if (config.comm_type == 0)
            {
                config.working_port = null;
            }
            station_fs.Close();
            station_fs.Dispose();
            Console.WriteLine("station loaded !");
        }
예제 #2
0
        public static void init(fang g)
        {
            string ref_path = g.ref_path + @"files\";

            width  = config.sensor_width;
            height = config.sensor_height;
            //init bmp template

            ref_path += def.template_hearder + config.sensor_width.ToString() + def.template_tail;

            Console.WriteLine("bmp template path " + ref_path);

            g.bkg_img = new byte[config.sensor_width * config.sensor_height];

            template = null;
            template = new byte[header_len + width * height];
            try
            {
                FileStream fs = new FileStream(ref_path, FileMode.Open);
                fs.Read(template, 0, header_len + width * height);
                fs.Close();
                fs.Dispose();
            }
            catch (Exception e)
            {
                Console.WriteLine("bmp_init error " + e.Message);
            }
        }
예제 #3
0
        void Data_Init()
        {
            g     = new fang(Application.StartupPath, this);
            g.BIN = new err();
            int i = config.init_projects(g);

            config.load_config(g, i);
            config.init_station(g);
        }
예제 #4
0
        public static int init_projects(fang g)
        {
            string configs_path = g.configs_path;

            Console.WriteLine("configs_path !" + configs_path);
            g.init_config();
            FileStream configs_fs = new FileStream(configs_path, FileMode.Open, FileAccess.Read);
            int        selected   = 0;

            csv_log.csv2dt(configs_fs, 0, g.dt_configs);
            for (int i = 0; i < g.dt_configs.Rows.Count; i++)
            {
                if (Convert.ToInt32(g.dt_configs.Rows[i]["Default"]) == 1)
                {
                    selected = i;
                }
            }
            configs_fs.Close();
            Console.WriteLine("configs loaded !");
            return(selected);
        }
예제 #5
0
        public static void open_create_log(fang g)
        {
            FileStream log_fs;

            g.dt = new DataTable();
            //if csv not exsits, creat. if exsit, load it
            g.log_path = g.ref_path + @"log\" + config.project_name + "-" + config.product_code + "-" + config.station.ToString() + ".csv";
            Console.WriteLine("log_path! " + g.log_path);
            try
            {
                log_fs = new FileStream(g.log_path, FileMode.Open, FileAccess.Read);
                csv_log.csv2dt(log_fs, 0, g.dt);
                Console.WriteLine("Log loaded ");
            }
            catch (Exception err)
            {
                log_fs = new FileStream(g.log_path, FileMode.OpenOrCreate, FileAccess.Write);
                csv_log.gen_table(g.log_path, g.dt);
                csv_log.dt2csv(log_fs, g.dt);
                Console.WriteLine("Log created ");
            }
            log_fs.Close();
        }
예제 #6
0
 public static void load_config(fang g, int i)
 {
     config.project_name  = g.dt_configs.Rows[i]["Project"].ToString();
     config.product_code  = g.dt_configs.Rows[i]["Product"].ToString();
     config.sensor_width  = Convert.ToInt32(g.dt_configs.Rows[i]["sensor_width"]);
     config.sensor_height = Convert.ToInt32(g.dt_configs.Rows[i]["sensor_height"]);
     config.avg_th        = Convert.ToInt32(g.dt_configs.Rows[i]["avg_th"]);
     config.rv_th         = Convert.ToInt32(g.dt_configs.Rows[i]["rv_th"]);
     config.c_th_high     = Convert.ToInt32(g.dt_configs.Rows[i]["c_th_high"]);
     config.c_th_low      = Convert.ToInt32(g.dt_configs.Rows[i]["c_th_low"]);
     config.v_th          = Convert.ToInt32(g.dt_configs.Rows[i]["v_th"]);
     config.version       = g.dt_configs.Rows[i]["Version"].ToString();
     config.comm_type     = Convert.ToInt32(g.dt_configs.Rows[i]["comm_type"]);
     config.keycode       = g.dt_configs.Rows[i]["Keycode"].ToString();
     config.firmware_type = Convert.ToInt32(g.dt_configs.Rows[i]["COSTYPE"]);
     config.dev_type      = Convert.ToInt32(g.dt_configs.Rows[i]["DEVTYPE"]);
     config.btn_check     = Convert.ToInt32(g.dt_configs.Rows[i]["btn_check"]);
     config.long_wait     = Convert.ToInt32(g.dt_configs.Rows[i]["long_wait"]);
     config.simple_test   = Convert.ToInt32(g.dt_configs.Rows[i]["simple_test"]);
     config.counter       = Convert.ToInt32(g.dt_configs.Rows[i]["counter"]);
     config.led           = Convert.ToInt32(g.dt_configs.Rows[i]["led"]);
     g.firmware_path      = g.ref_path + @"data\" + config.keycode + def.firmware_file;
     Console.WriteLine("firmware path = " + g.firmware_path);
 }