Example #1
0
 public TCPImplement(MainForm mainForm, TextBox textBox, DynoParameter dynoParam, EmissionInfo emiInfoSim, ModelOracle dbOracle, Logger log)
 {
     this.m_mainForm   = mainForm;
     this.m_textBox    = textBox;
     this.m_log        = log;
     this.m_dynoParam  = dynoParam;
     this.m_emiInfoSim = emiInfoSim;
     this.m_dbOracle   = dbOracle;
     this.m_listener   = new TcpListener(IPAddress.Any, this.m_dynoParam.TCPPort);
     Task.Factory.StartNew(ListenForClients);
 }
Example #2
0
        public MainForm()
        {
            InitializeComponent();
            this.Text = "ISUZU_Dyno_Upload Ver: " + MainFileVersion.AssemblyVersion;
            m_log     = new Logger("Upload", ".\\log", EnumLogLevel.LogLevelAll, true, 100);
            m_log.TraceInfo("==================================================================");
            m_log.TraceInfo("==================== START Ver: " + MainFileVersion.AssemblyVersion + " ====================");
            m_cfg             = new Config(m_log);
            m_db              = new Model(m_cfg.DB.Data.SqlServer, m_log);
            m_dbOracle        = new ModelOracle(m_cfg.DB.Data.Oracle, m_cfg.DB.Data.Dyno, m_log);
            m_iCNLenb         = 3;
            m_VehicleRetryDic = new Dictionary <string, int>();
            Task.Factory.StartNew(new Action(() => {
                try {
                    m_iCNLenb = m_dbOracle.GetCNLenb();
                } catch (Exception ex) {
                    m_log.TraceError("Can't connect with MES: " + ex.Message);
                    MessageBox.Show("无法与MES通讯,请检查设置\n" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }));
            Task.Factory.StartNew(new Action(() => {
                try {
                    m_db.TestConnect();
                    m_db.AddSkipField();
                } catch (Exception ex) {
                    m_log.TraceError("Can't connect with dyno database: " + ex.Message);
                    MessageBox.Show("无法与测功机数据库通讯,请检查设置\n" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }));
#if DEBUG
            m_timer           = new System.Timers.Timer(m_cfg.DB.Data.Interval * 1000);
            m_timer.Elapsed  += new System.Timers.ElapsedEventHandler(OnTimeUpload);
            m_timer.AutoReset = false;
            m_timer.Enabled   = true;
#else
            m_timer           = new System.Timers.Timer(m_cfg.DB.Data.Interval * 60 * 1000);
            m_timer.Elapsed  += new System.Timers.ElapsedEventHandler(OnTimeUpload);
            m_timer.AutoReset = true;
            m_timer.Enabled   = true;
#endif
            if (m_cfg.DynoParam.Data.Enable)
            {
                StartDynoServer();
            }
        }