Exemple #1
0
 private void LivenessCheck(object sender, System.Timers.ElapsedEventArgs e)
 {
     Lots.CheckLiveness();
 }
Exemple #2
0
 private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     this._elapsed++;
 }
Exemple #3
0
 private void initializeModelPanel(object o, System.Timers.ElapsedEventArgs target)
 {
     LoadFile(_delayedPath);
 }
Exemple #4
0
 void tmrReceiveTimeout_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     this.ConnectionState = ConnectionStatus.ReceiveFail_Timeout;
     DisconnectByHost();
 }
Exemple #5
0
 private void heatBeat(object sender, System.Timers.ElapsedEventArgs e)
 {
     this.send("{'event':'ping'}");
 }
Exemple #6
0
 void SetEveryDay(object sender, System.Timers.ElapsedEventArgs e)
 {
 }
Exemple #7
0
 private void TimerAction(object sender, System.Timers.ElapsedEventArgs args)
 {
     UpdateSettings();
     settings.SaveSettings();
 }
        void timer_CheckNoteValidator(object sender, ElapsedEventArgs e)
        {
            if (!_noteImpl.IsRunning) return;

            var value = BoLib.getBankCreditsReservePtr();//BoLib.getCredit() + BoLib.getBank() + (int)BoLib.getReserveCredits();
            if (value <= 0) return;

            BoLib.clearBankCreditReserve();
            Label3.Dispatcher.Invoke((DelegateNoteVal)timer_updateNoteVal, Label3, (int)value);
        }
 private void TmrPingServer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     // Generate a ping
     GeneratePing();
 }
Exemple #10
0
 private void RecordingTimerAction(object sender, System.Timers.ElapsedEventArgs args)
 {
     OnSnap(null, null);
 }
Exemple #11
0
        void m_MonitorECUTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (_stallReading)
            {
                return;
            }

            m_MonitorECUTimer.Stop();

            if (_opened && !_prohibitRead && !m_RunInEmulationMode)
            {
                if (_tcan != null)
                {
                    try
                    {
                        foreach (SymbolHelper sh in m_SymbolsToMonitor)
                        {
                            if (_prohibitRead || _stallReading)
                            {
                                break;
                            }
                            //if (_sramDumpFile == string.Empty)
                            //{
                            if (sh.Varname.StartsWith("Knock_count_cyl"))
                            {
                                sh.Length = 2;
                            }
                            byte[] result = _tcan.readRAM((ushort)sh.Start_address, (uint)sh.Length);
                            // convert resultvalue to a usable format (doubles)
                            HandleResult(result, sh.Varname, sh.UserCorrectionFactor, sh.UserCorrectionOffset, sh.UseUserCorrection);

                            /*}
                             * else
                             * {
                             *  if (sh.Varname.StartsWith("Knock_count_cyl")) sh.Length = 2;
                             *  byte[] result = ReadData((uint)sh.Start_address, (uint)sh.Length);
                             *  HandleResult(result, sh.Varname);
                             * }*/
                        }
                        if (_canusbDevice == "Multiadapter" || _canusbDevice == "CombiAdapter")
                        {
                            if (m_appSettings.Useadc1)
                            {
                                //_tcan.geta
                                float adc = _usbcandevice.GetADCValue(0);
                                //Console.WriteLine("ADC1: " + adc.ToString());
                                double convertedADvalue = ConvertADCValue(0, adc);
                                //Console.WriteLine("ADC1 converted: " + convertedADvalue.ToString());
                                string channelName = m_appSettings.Adc1channelname;
                                if (onSymbolDataReceived != null)
                                {
                                    onSymbolDataReceived(this, new RealtimeDataEventArgs(channelName, convertedADvalue));
                                }
                            }
                            if (m_appSettings.Useadc2)
                            {
                                float  adc = _usbcandevice.GetADCValue(1);
                                double convertedADvalue = ConvertADCValue(1, adc);
                                string channelName      = m_appSettings.Adc2channelname;
                                if (onSymbolDataReceived != null)
                                {
                                    onSymbolDataReceived(this, new RealtimeDataEventArgs(channelName, convertedADvalue));
                                }
                            }
                            if (m_appSettings.Useadc3)
                            {
                                float  adc = _usbcandevice.GetADCValue(2);
                                double convertedADvalue = ConvertADCValue(2, adc);
                                string channelName      = m_appSettings.Adc3channelname;
                                if (onSymbolDataReceived != null)
                                {
                                    onSymbolDataReceived(this, new RealtimeDataEventArgs(channelName, convertedADvalue));
                                }
                            }
                            if (m_appSettings.Useadc4)
                            {
                                float  adc = _usbcandevice.GetADCValue(3);
                                double convertedADvalue = ConvertADCValue(3, adc);
                                string channelName      = m_appSettings.Adc4channelname;
                                if (onSymbolDataReceived != null)
                                {
                                    onSymbolDataReceived(this, new RealtimeDataEventArgs(channelName, convertedADvalue));
                                }
                            }
                            if (m_appSettings.Useadc5)
                            {
                                float  adc = _usbcandevice.GetADCValue(4);
                                double convertedADvalue = ConvertADCValue(4, adc);
                                string channelName      = m_appSettings.Adc5channelname;
                                if (onSymbolDataReceived != null)
                                {
                                    onSymbolDataReceived(this, new RealtimeDataEventArgs(channelName, convertedADvalue));
                                }
                            }
                            if (m_appSettings.Usethermo)
                            {
                                float  temperature = _usbcandevice.GetThermoValue();
                                string channelName = m_appSettings.Thermochannelname;
                                Console.WriteLine(channelName + " = " + temperature.ToString());
                                if (onSymbolDataReceived != null)
                                {
                                    onSymbolDataReceived(this, new RealtimeDataEventArgs(channelName, temperature));
                                }
                            }
                        }
                        // cast cycle completed event
                        if (onCycleCompleted != null)
                        {
                            onCycleCompleted(this, EventArgs.Empty);
                        }
                    }
                    catch (Exception E)
                    {
                        Console.WriteLine("m_MonitorECUTimer_Elapsed: " + E.Message);
                    }
                }
            }
            m_MonitorECUTimer.Start();
        }
Exemple #12
0
 private void FilterTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     UpdateGrid(false);
 }
Exemple #13
0
 /// <summary>
 /// Timer elapse event handler, raised only when the client has timed out
 /// </summary>
 /// <param name="source">The timer that elapsed.</param>
 /// <param name="e">Event arguments.</param>
 private void TimeoutEventHandler(object source, ElapsedEventArgs e)
 {
     Limits.TimeoutTimer timer = (Limits.TimeoutTimer) source;
     timer.Stop();
     Connection connection = (Connection) timer.Tag;
     if(OnTimeout != null) OnTimeout(connection, timer.Interval);
 }
 private static void Time_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     ResetConfig();
 }
Exemple #15
0
 void tim_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     //do pic
     //this.Close();
     btnCancel_Click(sender, e);
 }
Exemple #16
0
 private void timer_Elapsed(object sender,ElapsedEventArgs args)
 {
     if(Elapsed != null) {
         Elapsed(sender,args);
     }
 }
Exemple #17
0
        public void OnTimer(object sender, System.Timers.ElapsedEventArgs args)
        {
            int eventId = 0;

            eventLog1.WriteEntry("Monitoring the System", EventLogEntryType.Information, eventId++);
        }
 // Used to eliminate multiple settings file open and close to save multiple values.  Settings will be saved SAVETIME milliseconds after the last setvalue is called
 private void OnSaveTimer(object source, System.Timers.ElapsedEventArgs e)
 {
     System.Timers.Timer t = (System.Timers.Timer)source;
     t.Stop();
     Save();
 }
Exemple #19
0
 public void OnTimer(object sender, System.Timers.ElapsedEventArgs args)
 {
     // TODO: Insert monitoring activities here.
     eventLog1.WriteEntry("Monitoring the System", EventLogEntryType.Information, eventId++);
 }
 public void myTimer_Elapsed(object source, System.Timers.ElapsedEventArgs e)
 {
     DoSomeEmailSendStuff();
 }
Exemple #21
0
        private void timerPro(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (bol_running && !bol_alarming)
            {
                bol_alarming = true;
                string loc_file     = "";
                int    Dcount       = 0;
                Random rand         = new Random(DateTime.Now.Second);
                string loc_fileName = string.Format(fileName, DateTime.Now.ToString("yyyy-MM-dd") + DateTime.Now.Second + rand.Next());

                using (ksoaContext db = new ksoaContext())
                {
                    //var query = (from q in db.alarm_MailAddr where q.IsDeleted==false&& DbFunctions.DiffMinutes(q.lastSendDate, DateTime.Now ) >= q.sendTimeSpan select q).ToList();
                    var          query    = addr_List.AsEnumerable().Where(q => q.IsDeleted == false && DateTime.Now.AddMinutes(-q.sendTimeSpan) > q.lastSendDate).ToList();
                    sendMailAddr loc_addr = new sendMailAddr();
                    tag_terminal loc_point;
                    if (query.Count > 0)
                    {
                        List <stock_alarm_GSA> list_goods;

                        Subject = string.Format(Subject, DateTime.Now.ToString("yyyy-MM-dd"));
                        Body    = string.Format(Body, Dcount.ToString());

                        var loc_item = query.First(q => !string.IsNullOrEmpty(q.SMTPPuser) &&
                                                   !string.IsNullOrEmpty(q.mailBody) &&
                                                   !string.IsNullOrEmpty(q.senderAddr) &&
                                                   !string.IsNullOrEmpty(q.senderName) &&
                                                   !string.IsNullOrEmpty(q.SMTPHost) &&
                                                   !string.IsNullOrEmpty(q.SMTPPass) &&
                                                   !string.IsNullOrEmpty(q.subject)
                                                   );
                        checkTimes(DateTime.Now, loc_item.fileBasePath, loc_fileName, out Dcount, out list_goods);
                        loc_file = file = loc_item.fileBasePath + loc_fileName;

                        loc_addr.mailBody      = string.Format(loc_item.mailBody, Dcount.ToString());
                        loc_addr.SMTPHost      = loc_item.SMTPHost;
                        loc_addr.SMTPPass      = loc_item.SMTPPass;
                        loc_addr.SMTPPuser     = loc_item.SMTPPuser;
                        loc_addr.subject       = string.Format(loc_item.subject, DateTime.Now.ToString("yyyy-MM-dd"));
                        loc_addr.from.addr     = loc_item.senderAddr;
                        loc_addr.from.showName = loc_item.senderName;
                        loc_addr.list_Toer     = new List <tag_terminal>();
                        loc_addr.list_files    = new List <string>();
                        loc_addr.list_files.Add(loc_file);
                        foreach (var item in query)
                        {
                            loc_point          = new tag_terminal();
                            loc_point.addr     = item.mailAddress;
                            loc_point.showName = item.toer;
                            loc_addr.list_Toer.Add(loc_point);
                        }
                        if (sendMail(loc_addr))
                        {
                            alarm_mailaddr loc_ma;

                            foreach (var item in query)
                            {
                                loc_ma = db.alarm_MailAddr.Find(item.ID);
                                loc_ma.lastSendDate = DateTime.Now;
                            }
                            foreach (var item in list_goods)
                            {
                                db.stock_alarm_GSA.Find(item.ID).last_alarmDate = (DateTime.Now);
                            }
                            db.SaveChanges();
                            dataRefresh();
                            StringBuilder sb = new StringBuilder();
                            sb.Append(DateTime.Now).Append("|商品库存预警邮件发送成功!共(").Append(Dcount).Append(")个商品.");
                            log_operate.writeLog(string.Format(logFile, DateTime.Now.ToString("yyyy-MM-dd")), sb.ToString());
                        }
                        else
                        {
                            dataRefresh();
                            StringBuilder sb = new StringBuilder();
                            sb.Append(DateTime.Now).Append("|商品库存预警邮件发送失败!共(").Append(Dcount).Append(")个商品.");
                            log_operate.writeLog(string.Format(logFile, DateTime.Now.ToString("yyyy-MM-dd")), sb.ToString());
                        }
                    }
                }
                bol_alarming = false;
            }
        }
Exemple #22
0
        private async void M_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                {
                }
                if (m_dyn.Ready())
                {
                    if (m_cur_date.ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd"))
                    {
                        load_events();
                    }

                    foreach (var eve in m_event_list)
                    {
                        if (m_event_status[eve] == 0)
                        {
                            var au_now = MainApp.AuNow();
                            if (eve.StartTime < au_now)
                            {
                                m_event_status[eve] = 2; // ended
                                continue;
                            }

                            m_event_status[eve] = 1; // busy
                            new Thread(async() =>
                            {
                                var odd_view = await m_dyn.get_runner_odds(eve.ID);
                                // Check delta and raise the alert
                                if (eve.OddView != null && odd_view != null)
                                {
                                    MainApp.log_info($"Odds for {eve.State} - {eve.Venue} - {eve.EventNo} updated.");
                                    foreach (var runner in odd_view.RName)
                                    {
                                        foreach (var bookie in m_monitor_bookies)
                                        {
                                            decimal pre_price = eve.OddView.get_odd_for_bookie(bookie, runner);
                                            decimal cur_price = odd_view.get_odd_for_bookie(bookie, runner);

                                            if (pre_price < 2M || cur_price == 0)
                                            {
                                                continue;
                                            }

                                            int pre_point = PriceTable.get_point(pre_price);
                                            int cur_point = PriceTable.get_point(cur_price);
                                            int delta     = cur_point - pre_point;
                                            if (delta <= -MainApp.g_setting.alert_level && -delta <= 13)
                                            {
                                                play_sound();
                                                MainApp.log_info("Notification triggered.");

                                                int idx = odd_view.RName.IndexOf(runner);
                                                // get top prices
                                                List <KeyValuePair <string, decimal> > odd_dict = new List <KeyValuePair <string, decimal> >();
                                                foreach (var one_bookie in odd_view.Odds)
                                                {
                                                    odd_dict.Add(new KeyValuePair <string, decimal>(one_bookie.Bookie, one_bookie.Odds[idx]));
                                                }
                                                odd_dict.Sort((pair1, pair2) => - pair1.Value.CompareTo(pair2.Value));

                                                // new notification
                                                Notification note    = new Notification();
                                                note.event_id        = eve.ID;
                                                note.datetime        = au_now.ToString("yyyy-MM-dd hh:mm:ss");
                                                note.time_to_jump    = eve.StartTime.Subtract(au_now).ToString("h'h 'm'm 's's'");
                                                note.degree          = delta;
                                                note.state           = eve.State;
                                                note.venue           = eve.Venue;
                                                note.race_number     = int.Parse(eve.EventNo);
                                                note.horse_number    = int.Parse(odd_view.RNo[idx]);
                                                note.horse_name      = runner;
                                                note.previous_price  = pre_price;
                                                note.current_price   = cur_price;
                                                note.bookie          = bookie;
                                                note.suggested_stake = suggest_stake(pre_price, delta);
                                                note.max_profit      = note.suggested_stake * (pre_price - 1);
                                                note.top_price_1     = $"${odd_dict[0].Value} {odd_dict[0].Key}";
                                                note.top_price_2     = $"${odd_dict[1].Value} {odd_dict[1].Key}";
                                                note.top_price_3     = $"${odd_dict[2].Value} {odd_dict[2].Key}";
                                                note.top_price_4     = $"${odd_dict[3].Value} {odd_dict[3].Key}";
                                                note.status          = 0; // pending
                                                note.result          = "-";
                                                add_note_to_db(note);
                                                refresh_in_delay = true;
                                                //refresh_grid();
                                            }
                                        }
                                    }
                                }

                                eve.OddView         = odd_view;
                                m_event_status[eve] = 0; // idle
                            }).Start();
                        }
                    }

                    foreach (var pair in m_event_status)
                    {
                        if (pair.Value == 2)
                        {
                            m_event_list.Remove(pair.Key);
                        }
                    }

                    if (m_event_list.Count == 0)
                    {
                        MainApp.log_info("No active events are left today. " + m_cur_date.ToString("yyyy-MM-dd"));
                    }
                }

                if (MainApp.g_working)
                {
                    img_status.BackgroundImage = Properties.Resources.Circle_ON;
                }
                else
                {
                    img_status.BackgroundImage = Properties.Resources.Circle_OFF;
                }
            }
            catch (Exception ex)
            {
                MainApp.log_error("Exception in timer\n" + ex.Message + "\n" + ex.StackTrace);
            }
            m_timer_alert.Start();
        }
Exemple #23
0
 private void TimerExpired(object sender, System.Timers.ElapsedEventArgs e)
 {
     _cancelTest = true;
 }
 private static void Tmr_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     OnCheckInventoryEvent();
 }
        void oTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (!isExecutionCompleted)
            {
                return;
            }


            string[] lstCompanies   = companies.Split(','); //Amin
            int      totalCompanies = lstCompanies.Length;
            int      curCompany     = 0;

            foreach (string comp in lstCompanies)
            {
                curCompany++;
                try
                {
                    CSVfilePath = ConfigurationManager.AppSettings[comp + "CSVfilePath"];

                    isExecutionCompleted = false;
                    string LuckyConStr = ConfigurationManager.ConnectionStrings["Lucky10Prod"].ConnectionString;
                    //string Lucky10QualityConStr = ConfigurationManager.ConnectionStrings["Lucky10Quality"].ConnectionString;
                    //Part is separated in another program - Start

                    string P101fileName  = "ITEM_" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("hhmmss"); //"P(101) Material Master";
                    string P101procName  = "dbo.P101_MaterialMaster";                                                     //ConfigurationManager.AppSettings["P101_StoredProceudreName"];
                    string PartNumcolumn = "Calculated_PartNum";
                    int    P101rows      = oDAL.GetRows(LuckyConStr, P101procName, comp);
                    if (P101rows > 0)
                    {
                        if (!CSVFileExist(P101fileName))
                        {
                            SendDataToCSVFile(LuckyConStr, P101fileName, P101procName, PartNumcolumn, comp);
                        }
                    }

                    //string Lucky10QualityConStr = ConfigurationManager.ConnectionStrings["Lucky10Quality"].ConnectionString;
                    string P103fileName = "UOM_" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("hhmmss"); //"P(103) UOM Master";
                    string P103procName = "dbo.P103_UOMMaster";                                                         //ConfigurationManager.AppSettings["P101_StoredProceudreName"];
                    string uomColumn    = "Part_PartNum";
                    int    P103rows     = oDAL.GetRows(LuckyConStr, P103procName, comp);
                    if (P103rows > 0)
                    {
                        if (!CSVFileExist(P103fileName))
                        {
                            SendDataToCSVFile(LuckyConStr, P103fileName, P103procName, uomColumn, comp);
                        }
                    }

                    //Part is separated in another program - End

                    /*
                     * string P105fileName = "CUST_" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("hhmmss");// "P(105) Customer Master";
                     * string P105procName = "dbo.P105_CustomerMaster";//ConfigurationManager.AppSettings["P101_StoredProceudreName"];
                     * string customerColumn = "Calculated_customer_code";
                     * int P105rows = oDAL.GetRows(LuckyConStr, P105procName);
                     * if (P105rows > 0)
                     * {
                     *  if (!CSVFileExist(P105fileName))
                     *      SendDataToCSVFile(LuckyConStr, P105fileName, P105procName, customerColumn);
                     * }
                     *
                     * string P107fileName = "SUPP_" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("hhmmss");// "P(107) Supplier Master";
                     * string P107procName = "dbo.P107_SupplierMaster";//ConfigurationManager.AppSettings["P101_StoredProceudreName"];
                     * string supplierColumn = "Calculated_supplier_code";
                     * int P107rows = oDAL.GetRows(LuckyConStr, P107procName);
                     * if (P107rows > 0)
                     * {
                     *  if (!CSVFileExist(P107fileName))
                     *      SendDataToCSVFile(LuckyConStr, P107fileName, P107procName, supplierColumn);
                     * }
                     */

                    //string P201fileName = "P(201) Purchase Order";
                    //PO Done in POWMSIntegration service seperately.
                    //string P201fileName = "PO_" + DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("hhmmss");
                    //string P201procName = "dbo.P201_PurchaseOrder";//ConfigurationManager.AppSettings["P101_StoredProceudreName"];
                    //if (!CSVFileExist(P201fileName))
                    //    SendDataToCSVFile(LuckyConStr, P201fileName, P201procName);

                    /*
                     * string P109fileName = "REASON_" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("hhmmss");// "P(109) Reason Code";
                     * string P109procName = "dbo.P109_ReasonCode";//ConfigurationManager.AppSettings["P101_StoredProceudreName"];
                     * string reasonCodeColumn = "Calculated_reason_code";
                     * int P109rows = oDAL.GetRows(LuckyConStr, P109procName);
                     * if (P109rows > 0)
                     * {
                     *  if (!CSVFileExist(P109fileName))
                     *      SendDataToCSVFile(LuckyConStr, P109fileName, P109procName, reasonCodeColumn);
                     * }
                     */

                    //ready to process
                    //string P301fileName = "SO_" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("hhmmss");// "P(301) Sales Order";
                    //string P301procName = "dbo.P301_SalesOrder";//ConfigurationManager.AppSettings["P101_StoredProceudreName"];
                    //string orderNumColumn = "OrderHed_OrderNum";
                    //int P301rows = oDAL.GetRows(LuckyConStr, P301procName);
                    //if (P301rows > 0)
                    //{
                    //    if (!CSVFileExist(P301fileName))
                    //        SendDataToCSVFile(LuckyConStr, P301fileName, P301procName, orderNumColumn);
                    //}

                    //Auto print ready

                    /*
                     * string P401fileName = "RMA_" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("hhmmss");// "P(401) RMA Market Return";
                     * string P401procName = "dbo.P401_RMAMarketReturn";//ConfigurationManager.AppSettings["P101_StoredProceudreName"];
                     * string rmaNumColumn = "RMAHead_RMANum";
                     * int P401rows = oDAL.GetRows(LuckyConStr, P401procName);
                     * if (P401rows > 0)
                     * {
                     *  if (!CSVFileExist(P401fileName))
                     *      SendDataToCSVFile(LuckyConStr, P401fileName, P401procName, rmaNumColumn);
                     * }
                     */

                    //Auto print ready old one -- Export_c = true then exports
                    //string P601fileName = "TR_" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("hhmmss");// "P(601) Transfer Order";
                    //string P601procName = "dbo.P601_TransferOrder";//ConfigurationManager.AppSettings["P101_StoredProceudreName"];
                    //string tfOrdNumColumn = "TFOrdHed_TFOrdNum";
                    //int P601rows = oDAL.GetRows(LuckyConStr, P601procName);
                    //if (P601rows > 0)
                    //{
                    //    if (!CSVFileExist(P601fileName))
                    //        SendDataToCSVFile(LuckyConStr, P601fileName, P601procName,  tfOrdNumColumn);
                    //}

                    //Tick Shipped
                    //string P604fileName = "TO_" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("hhmmss");//"P(604) Transfer Shipment";
                    //string P604procName = "dbo.P604_TransferShipment";//ConfigurationManager.AppSettings["P101_StoredProceudreName"];
                    //string tfShHdPackNumColumn = "TFShipHead_PackNum";
                    //int P604rows = oDAL.GetRows(LuckyConStr, P604procName);
                    //if (P604rows > 0)
                    //{
                    //    if (!CSVFileExist(P604fileName))
                    //        SendDataToCSVFile(LuckyConStr, P604fileName, P604procName, tfShHdPackNumColumn);
                    //}
                }
                catch (Exception ex)
                {
                    sbLog = new StringBuilder();
                    sbLog.AppendLine(ex.Message.ToString());
                    WriteLogToFile(DateTime.Now.ToString());
                }
                finally
                {
                    //WriteLogToFile(DateTime.Now.ToString());
                    if (curCompany == totalCompanies)
                    {
                        isExecutionCompleted = true;
                    }
                }
            }
        }
Exemple #26
0
 void tmrConnectTimeout_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     ConnectionState = ConnectionStatus.ConnectFail_Timeout;
     DisconnectByHost();
 }
 private void InfoUpdatetimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     GlobalMemoryStatusEx(out _mEmorystatusex);
     _memoryInfo.MemLoad   = _mEmorystatusex.dwMemoryLoad;
     _memoryInfo.FillColor = "LawnGreen";
 }
 private void TReAuth_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     Authenticate();
 }
Exemple #29
0
 /// <summary>
 /// Сбрасывает цикл ожидания
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void Delayer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     stop            = true;
     Delayer.Enabled = false;
 }
        private void WatchdogElapsed(object sender, System.Timers.ElapsedEventArgs args)
        {
            try
            {
                var timeoutMillis = 0;
                var settleMillis  = 0;
                var elapsedTicks  = 0L;
                var timeoutTicks  = 0L;
                var count         = 0UL;

                lock (_watchdogLock)
                {
                    timeoutMillis = _watchdogTimeoutMillis;
                    settleMillis  = _watchdogSettleMillis;
                    elapsedTicks  = DateTimeOffset.Now.Ticks - _watchdogBeginTicks;
                    timeoutTicks  = _watchdogTimeoutMillis * TimeSpan.TicksPerMillisecond;
                    count         = ++_watchdogCount;
                }

                if (count % 60 == 0)
                {
                    Log.LogVerbose($"nameof(SpinCamera), Watchdog heartbeat (count: {count}, elapsed (ticks): {elapsedTicks}, timeout (ticks): {timeoutTicks})");
                }

                if (timeoutMillis != 0 && elapsedTicks > timeoutTicks)
                {
                    Log.LogVerbose("Ouch dog!");

                    string error = null;

                    if (timeoutMillis > 0)
                    {
//                        Log.LogPrefix(_logPrefix, $"Resetting camera (reason: {"not responding"}, timeout (ms): {timeoutMillis})");

                        error = "Not responding";
                    }
                    else
                    {
                        //                        Log.LogPrefix(_logPrefix, $"Resetting camera (reason: {"error"})");

                        error = "some error"; // _cameraLib.GetLastError();
                    }

                    OnErrorOccurred(this, null);

                    //                  _cameraLib.Kill();

                    //                  Log.LogPrefix(_logPrefix, $"Waiting to settle (duration (ms): {settleMillis})");

                    Thread.Sleep(settleMillis);

                    lock (_watchdogLock)
                    {
                        _watchdogTimeoutMillis = 0;
                    }

                    _watchdogReset.Set();
                }
            }
            catch (Exception e)
            {
                //            Log.ErrorPrefix(_logPrefix, e, e.Message);
            }
            finally
            {
                _watchdogTimer.Start();
            }
        }
Exemple #31
0
 void DisplayTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     this.BeginInvoke(new MethodInvoker(UpdateDisplay));
 }
Exemple #32
0
 static void executarTarefa(object sender, System.Timers.ElapsedEventArgs e)
 {
     _timer.Interval = valorDoTempo();
     Console.WriteLine("Função de sincronia " + _timer.Interval);
     _timer.Enabled = true;
 }
        /// <summary>
        /// Downloads a KML/KMZ file from the given URL
        /// </summary>
        private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (bUpdating)
            {
                return;
            }
            bUpdating = true;

            try
            {
                if (!m_firedStartup || (layer != null && layer.IsOn))
                {
                    string fullurl = url;
                    if (sender == viewTimer)
                    {
                        if (!bViewStopped)
                        {
                            if (DrawArgs.Camera.ViewMatrix != lastView)
                            {
                                lastView  = DrawArgs.Camera.ViewMatrix;
                                bUpdating = false;
                                return;
                            }
                            bViewStopped = true;
                        }
                        else
                        {
                            if (DrawArgs.Camera.ViewMatrix != lastView)
                            {
                                lastView     = DrawArgs.Camera.ViewMatrix;
                                bViewStopped = false;
                            }
                            bUpdating = false;
                            return;
                        }
                        fullurl += (fullurl.IndexOf('?') == -1 ? "?" : "&") + GetBBox();
                    }

                    string saveFile = Path.GetFileName(Uri.EscapeDataString(url));
                    if (saveFile == null || saveFile.Length == 0)
                    {
                        saveFile = "temp.kml";
                    }

                    saveFile = Path.Combine(KMLParser.KmlDirectory + "\\temp\\", saveFile);

                    FileInfo saveFileInfo = new FileInfo(saveFile);
                    if (!saveFileInfo.Directory.Exists)
                    {
                        saveFileInfo.Directory.Create();
                    }

                    // Offline check
                    if (World.Settings.WorkOffline)
                    {
                        throw new Exception("Offline mode active.");
                    }

                    WebDownload myClient = new WebDownload(fullurl);
                    myClient.DownloadFile(saveFile);

                    // Extract the file if it is a kmz file
                    string kmlFile = saveFile;

                    // Create a reader to read the file
                    KMLLoader loader = new KMLLoader();
                    if (Path.GetExtension(saveFile) == ".kmz")
                    {
                        bool bError = false;
                        kmlFile = loader.ExtractKMZ(saveFile, out bError);

                        if (bError)
                        {
                            return;
                        }
                    }

                    // Read all data from the reader
                    string kml = loader.LoadKML(kmlFile);

                    if (kml != null)
                    {
                        try
                        {
                            // Load the actual kml data
                            owner.ReadKML(kml, layer, kmlFile);
                        }
                        catch (Exception ex)
                        {
                            Log.Write(Log.Levels.Error, "KMLParser: " + ex.ToString());

                            MessageBox.Show(
                                String.Format(CultureInfo.InvariantCulture, "Error loading KML file '{0}':\n\n{1}", kmlFile, ex.ToString()),
                                "KMLParser error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1,
                                MessageBoxOptions.ServiceNotification);
                        }
                    }
                    m_firedStartup = true;
                }
            }
            catch (Exception ex)
            {
                Log.Write(Log.Levels.Error, "KMLParser: " + ex.ToString());
            }

            bUpdating = false;
        }
Exemple #34
0
        public void LapLogger_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (Telemetry.m.Active_Session && Telemetry.m.Sim.Modules.Time_Available )
            {
                try
                {
                    double dt = Telemetry.m.Sim.Session.Time - PreviousTime;
                    PreviousTime = Telemetry.m.Sim.Session.Time;
                    lock (Telemetry.m.Sim.Drivers.AllDrivers)
                    {
                        foreach (IDriverGeneral driver in Telemetry.m.Sim.Drivers.AllDrivers)
                        {
                            if (driver != null)
                            {
                                // Look up the lap.
                                int lap = driver.Laps;
                                int drv = driver.MemoryBlock;
                                Lap l = GetLap(driver, 0);

                                l.Distance += driver.Speed*dt;
                                // Create lap if it doesnt exist
                                if (l.LapNo == -1)
                                {
                                    l = new Lap
                                            {
                                                ApexSpeeds = new List<double>(),
                                                Checkpoints = new List<double>(),
                                                DriverNo = drv,
                                                LapNo = lap,
                                                Distance = 0,
                                                MinTime = Telemetry.m.Sim.Session.Time
                                            };
                                    int k = 0;
                                    for (k = 0; k < Sections.Lines.Count; k++)
                                        l.Checkpoints.Add(-1);
                                    for (k = 0; k < Apexes.Positions.Count; k++)
                                        l.ApexSpeeds.Add(-1);

                                    //TrackLogger.Add(l);

                                    if (drv == Telemetry.m.Sim.Drivers.Player.MemoryBlock)
                                    {
                                        if (PlayerLap != null)
                                        {
                                            PlayerLap();
                                        }
                                    }
                                    else if (DriverLap != null)
                                    {
                                        DriverLap();
                                    }

                                    Lap lastLap = GetLap(driver, 1);
                                    if (lastLap.LapNo != -1)
                                    {
                                        l.Sector1 = driver.Sector_1_Last;
                                        l.Sector2 = driver.Sector_2_Last;
                                        l.Sector3 = driver.Sector_3_Last;
                                        l.MaxTime = Telemetry.m.Sim.Session.Time;
                                        l.Total = l.Sector3 + l.Sector2 + l.Sector1;
                                    }
                                    SetLap(driver, l);
                                    continue;
                                }

                                if (Telemetry.m.Sim.Modules.DistanceOnLap)
                                {
                                    // Apex speeds
                                    int i = 0;
                                    foreach (KeyValuePair<double, string> apex in Apexes.Positions)
                                    {
                                        if (l.ApexSpeeds[i] == -1 && l.PrevMeters < apex.Key &&
                                            driver.MetersDriven >= apex.Key && apex.Key > (driver.MetersDriven - 100))
                                        {
                                            l.ApexSpeeds[i] = driver.Speed;
                                            break;
                                        }

                                        i++;
                                    }

                                    // Sections
                                    i = 0;
                                    foreach (KeyValuePair<double, string> checkpoint in Sections.Lines)
                                    {
                                        if (l.Checkpoints[i] == -1 && l.PrevMeters <= checkpoint.Key &&
                                            driver.MetersDriven >= checkpoint.Key &&
                                            checkpoint.Key > (driver.MetersDriven - 100))
                                        {
                                            l.Checkpoints[i] = Telemetry.m.Sim.Session.Time;
                                            break;
                                        }

                                        i++;
                                    }
                                    l.PrevMeters = driver.MetersDriven;
                                }

                                l.MaxTime = Telemetry.m.Sim.Session.Time;
                                /*int ind = TrackLogger.FindIndex(delegate(Lap lm) { return lm.LapNo == lap && lm.DriverNo == drv; });
                                TrackLogger[ind] = l;*/
                                SetLap(driver, l);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {

                }
            }
        }
        void timer_CheckButton(object sender, ElapsedEventArgs e)
        {
            //set _btnImpl.isrunning to true then at the end set it to false.
            if (_btnImpl.IsRunning)
            {
                // test refill key and door switch.
                if (_btnImpl._doSpecials)
                {
                    if (_counter >= 0 && _counter < 60)
                    {
                        if (_btnImpl._currentSpecial == 0)
                        {
                            if (!_btnImpl._toggled[0])
                                _counter++;

                            var comp = Label1.Dispatcher.Invoke((DelegateReturnString)timer_getLabelContent, Label1) as string;

                            if (string.IsNullOrEmpty(comp))
                                Label1.Dispatcher.Invoke((DelegateUpdate)timer_UpdateSpecials, Label1);

                            var mask = _specialMasks[0];
                            var status = BoLib.getSwitchStatus(2, mask);
                            if (status == 0)
                            {
                                if (!_btnImpl._toggled[0]) // key toggled off
                                    _btnImpl._toggled[0] = true;
                            }
                            else
                            {
                                if (_btnImpl._toggled[0] != true) return;
                                _btnImpl._currentSpecial = 1;
                                _counter = 0;
                                Label1.Dispatcher.Invoke((DelegateUpdate)timer_UpdateSpecials, Label1);
                            }
                        }
                        else if (_btnImpl._currentSpecial == 1)
                        {
                            var comp = Label2.Dispatcher.Invoke((DelegateReturnString)timer_getLabelContent, Label2) as string;

                            if (string.IsNullOrEmpty(comp))
                                Label2.Dispatcher.Invoke((DelegateUpdate)timer_UpdateSpecials, Label2);

                            if (_btnImpl._toggled[1] == false)
                                _counter++;

                            var mask = _specialMasks[1];
                            var status = BoLib.getSwitchStatus(2, mask);
                            if (status == 0)
                            {
                                if (!_btnImpl._toggled[1]) // toggle closed
                                    _btnImpl._toggled[1] = true;
                            }
                            else
                            {
                                if (_btnImpl._toggled[1] != true) return;
                                _btnImpl.DoSpecials = false;
                                _btnImpl.CurrentSpecial = 2; //!!!!
                                Label2.Dispatcher.Invoke((DelegateUpdate)timer_UpdateSpecials, Label2);
                            }
                        }
                    }
                    else
                    {
                        if (_btnImpl._currentSpecial < 1)
                        {
                            _btnImpl._currentSpecial = 1;

                            var comp = Label1.Dispatcher.Invoke((DelegateReturnString)timer_getLabelContent, Label1) as string;

                            if (comp == "Please toggle the REFILL KEY off and on.")
                                Label1.Dispatcher.Invoke((DelegateUpdate)UpdateSpecialsError, Label1);
                        }
                        else
                        {
                            if (_btnImpl.DoSpecials && _btnImpl._currentSpecial == 1)
                                Label2.Dispatcher.Invoke((DelegateUpdate)UpdateSpecialsError, Label2);

                            _btnImpl._currentSpecial = 0;
                            _btnImpl._doSpecials = false;
                            _counter = 0;
                        }
                        if (_counter >= 60)
                            _counter = 0;
                    }
                }
                else // Button deck
                {
                    uint status = 100;
                    if ((_counter >= 0 && _counter < 30) && _currentButton < 8)
                    {
                        _counter++;

                        status = BoLib.getSwitchStatus(1, _buttonMasks[_currentButton]);
                        if (_currentButton == 0 && status == 0)
                            _labels[_currentButton].Dispatcher.Invoke((DelegateUpdate)timer_ButtonShowTestMsg,
                                _labels[_currentButton]);

                        if (status > 0)
                        {
                            _buttonsPressed[_currentButton] = 1;
                            _labels[_currentButton].Dispatcher.Invoke((DelegateUpdate)timer_UpdateLabel, _labels[_currentButton]);
                        }
                    }
                    else
                    {
                        if (_currentButton < 8)
                        {
                            if ((status == 0 || status == 100) && _buttonsPressed[_currentButton] == 0)
                            {
                                _labels[_currentButton].Dispatcher.Invoke((DelegateUpdate)timer_buttonError,
                                                                          _labels[_currentButton]);
                            }
                            _currentButton++;

                            if (_currentButton < 8)
                                _labels[_currentButton].Dispatcher.Invoke((DelegateUpdate)timer_ButtonShowTestMsg,
                                                                          _labels[_currentButton]);
                        }
                        else
                        {
                            _currentButton = 0;
                            _aTestIsRunning = false;
                            _startTimer.Enabled = false;
                            BtnEndTest.Dispatcher.Invoke((DelegateEnableBtn)timer_buttonEnable, BtnEndTest);
                        }
                        _counter = 0;
                    }
                }
            }
        }