Ejemplo n.º 1
0
        TelnetConnection _telnet_connection; // Telnet connection to ISA3 Adapter

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ember"></param>
        public Recode(Ember ember)
        {
            _ember = ember;
        }
Ejemplo n.º 2
0
        private void Form_Main_Load(object sender, EventArgs e)
        {
            // Load the app icon
            Icon = Properties.Resources.Icon_PowerCalibration;

            // Set the title to match assembly info from About dlg
            this.Text = this.assemblyTitle;

            // Init the stop watches
            _stopwatch_running.Reset();
            _stopwatch_idel.Start();

            // Always reset this settings as they are important to forget leaving them in a different state
            Properties.Settings.Default.Ember_ReadProtect_Enabled = true;
            Properties.Settings.Default.PrePost_Test_Enabled = true;
            Properties.Settings.Default.Save();

            // Init the status text box
            runStatus_Init();

            // Make sure we have a selection for board types
            this.comboBoxBoardTypes.Items.AddRange(Enum.GetNames(typeof(PowerCalibration.BoardTypes)));
            int index = comboBoxBoardTypes.Items.IndexOf(Properties.Settings.Default.Last_Used_Board);
            if (index < 0)
                index = 0;
            if (comboBoxBoardTypes.Items.Count > 0)
                comboBoxBoardTypes.SelectedIndex = index;

            string msg = "";
            // Report COM ports found in system
            string[] ports = SerialPort.GetPortNames();
            foreach (string portname in ports)
            {
                msg += string.Format("{0}, ", portname);
            }
            if (msg != "")
            {
                msg = msg.TrimEnd(new char[] { ' ', ',' });
                msg = string.Format("System serial ports: {0}", msg);
                updateOutputStatus(msg);
            }

            // Detect whether meter is connected to one of the ports
            bool detected_meter = autoDetectMeterCOMPort();

            // Ember path
            if (!Directory.Exists(Properties.Settings.Default.Ember_BinPath))
                msg = string.Format("Unable to find Ember bin path \"{0}\"", Properties.Settings.Default.Ember_BinPath);
            else
                msg = string.Format("Ember bin path set at\"{0}\"", Properties.Settings.Default.Ember_BinPath);
            updateOutputStatus(msg);

            // Init the Ember object
            _ember = new Ember();
            _ember.Work_Path = _app_data_dir;
            _ember.BatchFilePatchPath = Path.Combine(_app_data_dir, "patchit.bat");
            _ember.Process_ISAChan_Error_Event += p_ember_isachan_ErrorDataReceived;
            _ember.Process_ISAChan_Output_Event += p_ember_isachan_OutputDataReceived;

            // Init the db connection string
            _db_connect_str = new SqlConnectionStringBuilder(Properties.Settings.Default.DBConnectionString);
            _db_Loging = Properties.Settings.Default.DB_Loging_Enabled;
            if (isDBLogingEnabled())
            {
                // Create the internal result data table
                createResultTable();
                updateOutputStatus("DB logging enabled");
            }
            else
            {
                updateOutputStatus("DB logging disabled");
            }

            //CalibrationResultsEventArgs e = new CalibrationResultsEventArgs();
            //e.Current_gain = 1;
            //e.Voltage_gain = 2;
            //e.timestamp = DateTime.Now;
            //calibrationResults_Event(this, e);

            // Enable the app
            setEnablement(true, false);
        }