Beispiel #1
0
        } // end of UI_slow_upd_timer()

        public int iGetBattLifePrc()
        {
            int iRetPerc = -1;

            iRetPerc = Generic12Vbattery.iGetBattLifePrc(m_stRecentBattData.dblBatVolts, m_stRecentBattData.dblBatAmperes, m_stRecentBattData.dblBattTemp);

            return(iRetPerc);
        }
Beispiel #2
0
        //        private static string szDateTimePatternISO8601Sortable = @"yyyy-MM-ddTHH:mm:ss.fff";
        public bool bLogDataToCSVFile(Generic12Vbattery.strctBattMonData stGivenBattData, int iChrgLvl)
        {
            bool bResult=false;
            string strOneLineToLog=string.Empty;

            if(true==bLoggingToFile)
            {
                if(null==m_OutCSVfile)
                {

            // open file if not currently open
                    m_OutCSVfile=new System.IO.StreamWriter(szBatMonCSVFileName, true);
                };

            // log to file, format if needed
            // datetime,volts,apmps,t°C,{D|I|C},milliCoulombsIn, milliCoulombsOut,report reason
            #if ISO8601OUT
            // ISO 8601 sortable format
            //				strOneLineToLog="\"" + dtNowDateTime.ToString(szDateTimePatternISO8601Sortable)+
                        "."+ dtNowDateTime.Millisecond;
            #else
            // format date-time per Excel custom date-time format specification, supplied as argument
                strOneLineToLog="\"" + stGivenBattData.dtBattDateTime.ToString(szDateTimePatternExcelCstm);
            #endif
                strOneLineToLog+="\",\"";
                strOneLineToLog+=stGivenBattData.dblBatVolts.ToString() + "\",\"";
                strOneLineToLog+=stGivenBattData.dblBatAmperes.ToString("+#.#;-#.#;0") + "\",\"";
                strOneLineToLog+=stGivenBattData.dblBattTemp.ToString("+#.#;-#.#;0") + "\",\"";
                strOneLineToLog+=stGivenBattData.chBattState+"\",\"";
                strOneLineToLog+=iChrgLvl + "\",\"";
                strOneLineToLog+=stGivenBattData.liQIn + "\",\"";
                strOneLineToLog+=stGivenBattData.liQOut + "\"";
            // print entire line to the log file
            // will be like his : "19-12-2013 17:36:01.34.nnn","12.4","-0.3","13.6","D","99","67868","78979"
                m_OutCSVfile.WriteLine(strOneLineToLog);
            // close file every 25 write to avoid data loss if reset
                if(m_slMeasIterCnt>0 && m_slMeasIterCnt%25==0)
                {
                    m_OutCSVfile.Flush();
                    m_OutCSVfile.Close();
                    m_OutCSVfile.Dispose();
                    m_OutCSVfile=null;
                };
            };
            return bResult;
        }
Beispiel #3
0
        // updates combined voltage and current chart series1 is Volts, series2 is Amperes
        // uses microcontroller supplied date-time
        // X axis fo chart must be DateTime data type
        private bool bAddDataTo_V_A_Chart(Chart chrtOneChart, Series sCurrent, Series sVoltage, Generic12Vbattery.strctBattMonData stBattDataPckt)
        {
            bool bRes=true;
            //			Debug.WriteLine("++Form1::bAddDataTo_V_A_Chart()");

            // obtain a reference to given data series
            if(null==sVoltage || null==sCurrent)
            {
                Debug.WriteLine("Form1::bAddDataTo_V_A_Chart() error - null series!");
                bRes=false;
            }
            else
            {
            // now add {date-time, U,I and t°} as new data point, separately to current and voltage graphs
                sCurrent.Points.AddXY(stBattDataPckt.dtBattDateTime, stBattDataPckt.dblBatAmperes);
                sVoltage.Points.AddXY(stBattDataPckt.dtBattDateTime, stBattDataPckt.dblBatVolts);
            };
            return bRes;
        }