From: <and...@us...> - 2009-06-20 15:42:10
|
Revision: 810 http://ggc.svn.sourceforge.net/ggc/?rev=810&view=rev Author: andyrozman Date: 2009-06-20 15:41:13 +0000 (Sat, 20 Jun 2009) Log Message: ----------- Modified Paths: -------------- trunk/ggc-meter/build/GGCMeterToolVersion.properties trunk/ggc-meter/docs/Changelog trunk/ggc-meter/src/GGCMeterTool_en.properties trunk/ggc-meter/src/ggc/meter/data/MeterDataHandler.java trunk/ggc-meter/src/ggc/meter/data/MeterDataReader.java trunk/ggc-meter/src/ggc/meter/data/MeterValuesEntry.java trunk/ggc-meter/src/ggc/meter/data/db/GGCMeterDb.java trunk/ggc-meter/src/ggc/meter/plugin/MeterPlugInServer.java trunk/ggc-meter/src/ggc/meter/util/DataAccessMeter.java Modified: trunk/ggc-meter/build/GGCMeterToolVersion.properties =================================================================== --- trunk/ggc-meter/build/GGCMeterToolVersion.properties 2009-06-20 15:39:47 UTC (rev 809) +++ trunk/ggc-meter/build/GGCMeterToolVersion.properties 2009-06-20 15:41:13 UTC (rev 810) @@ -6,5 +6,5 @@ # # GGC Meter Tool Version # -ggc-meter-tool.version=1.0.9 +ggc-meter-tool.version=1.1.0 Modified: trunk/ggc-meter/docs/Changelog =================================================================== --- trunk/ggc-meter/docs/Changelog 2009-06-20 15:39:47 UTC (rev 809) +++ trunk/ggc-meter/docs/Changelog 2009-06-20 15:41:13 UTC (rev 810) @@ -2,8 +2,16 @@ Changes file for GGC Meter Tool =============================== +1.1.1 [current] + +1.1.0 + * Reading of all data changed (changes to PlugInBase too) + * added classes for handling old data: MeterDataReader + * Added GGCMeterDb class + * Requires PluginBase 0.4.0 + 1.0.9 -Optium + * Optium implementation started 1.0.8 * Changes which resulted from ggc-core beeing separate entity Modified: trunk/ggc-meter/src/GGCMeterTool_en.properties =================================================================== --- trunk/ggc-meter/src/GGCMeterTool_en.properties 2009-06-20 15:39:47 UTC (rev 809) +++ trunk/ggc-meter/src/GGCMeterTool_en.properties 2009-06-20 15:41:13 UTC (rev 810) @@ -134,7 +134,7 @@ LOG=Log DEVICE_INFO=%s Info ACTION=Action - +READING_OLD_DATA=Reading old data (from Db) STATUS_NONE=Unknown Status STATUS_READY=Ready STATUS_DOWNLOADING=Downloading Modified: trunk/ggc-meter/src/ggc/meter/data/MeterDataHandler.java =================================================================== --- trunk/ggc-meter/src/ggc/meter/data/MeterDataHandler.java 2009-06-20 15:39:47 UTC (rev 809) +++ trunk/ggc-meter/src/ggc/meter/data/MeterDataHandler.java 2009-06-20 15:41:13 UTC (rev 810) @@ -1,5 +1,6 @@ package ggc.meter.data; +import ggc.core.db.hibernate.DayValueH; import ggc.plugin.data.DeviceDataHandler; import ggc.plugin.util.DataAccessPlugInBase; @@ -8,7 +9,7 @@ /** * Application: GGC - GNU Gluco Control - * Plug-in: CGMS Tool (support for CGMS devices) + * Plug-in: Meter Tool (support for Meter devices) * * See AUTHORS for copyright information. * @@ -91,9 +92,20 @@ @Override public void setDeviceData(Hashtable<String, ?> data) { - old_data = (Hashtable<String,MeterValuesEntry>)data; -// System.out.println("Old data: " + old_data); + if ((data==null) || (data.size()==0)) + { + //System.out.println("NO Old data: " + old_data); + old_data = new Hashtable<String,DayValueH>(); + } + else + { + old_data = (Hashtable<String,DayValueH>)data; + //System.out.println("Old data: " + old_data); + } } + + + } \ No newline at end of file Modified: trunk/ggc-meter/src/ggc/meter/data/MeterDataReader.java =================================================================== --- trunk/ggc-meter/src/ggc/meter/data/MeterDataReader.java 2009-06-20 15:39:47 UTC (rev 809) +++ trunk/ggc-meter/src/ggc/meter/data/MeterDataReader.java 2009-06-20 15:41:13 UTC (rev 810) @@ -1,13 +1,14 @@ package ggc.meter.data; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import ggc.meter.data.db.GGCMeterDb; import ggc.meter.util.DataAccessMeter; import ggc.plugin.gui.OldDataReaderAbstract; -import ggc.plugin.util.DataAccessPlugInBase; +import java.util.Hashtable; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** * Application: GGC - GNU Gluco Control * Plug-in: Pump Tool (support for Pump devices) @@ -39,17 +40,20 @@ private static Log log = LogFactory.getLog(MeterDataReader.class); GGCMeterDb db = null; - DataAccessMeter m_da = DataAccessMeter.getInstance(); + DataAccessMeter m_da = null; /** * Constructor * * @param da */ - public MeterDataReader(DataAccessPlugInBase da) + public MeterDataReader(DataAccessMeter da) { super(da); - db = m_da.getDb(); + m_da = da; + //db = m_da.getDb(); + + //System.out.println("db: " ) } /** @@ -58,16 +62,17 @@ @Override public void getMaxEntries() { - db.getAllElementsCount(); + db = m_da.getDb(); + this.all_entries = db.getAllElementsCount(); } /** * Read Old entries */ @Override - public void readOldEntries() + public Hashtable<String, Object> readOldEntries() { - db.getMeterValues(this); + return db.getMeterValues(this); // TODO Auto-generated method stub } @@ -96,15 +101,24 @@ { this.m_drr.setOldDataReadingProgress(40); log.debug("Old Data reading progress [" + m_da.getApplicationName() + "]: 40% read from database"); + log.debug("Old Data reading progress [" + m_da.getApplicationName() + "]: Started to sort through data (progress will not be displayed)"); } else { int proc = this.getElementProcent(current_entry); - float proc_total = ((proc + 40.0f) * 1.0f) / 140.0f; + float proc_total = ((((proc* 1.0f) + 40.0f) ) / 140.0f) * 100.0f; + int proc_total_i = (int)proc_total; + +// log.debug("Old Data reading progress [" + m_da.getApplicationName() + "]: " + proc_total_i + " %" ); + this.m_drr.setOldDataReadingProgress(proc_total_i); - int proc_total_i = (int)proc_total; - log.debug("Old Data reading progress [" + m_da.getApplicationName() + "]: " + proc_total_i + " %" ); + try + { + Thread.sleep(1); + } + catch(InterruptedException ex) {} + } } Modified: trunk/ggc-meter/src/ggc/meter/data/MeterValuesEntry.java =================================================================== --- trunk/ggc-meter/src/ggc/meter/data/MeterValuesEntry.java 2009-06-20 15:39:47 UTC (rev 809) +++ trunk/ggc-meter/src/ggc/meter/data/MeterValuesEntry.java 2009-06-20 15:41:13 UTC (rev 810) @@ -77,8 +77,24 @@ { super(); } + /** + * Constructor + * @param dv + */ + public MeterValuesEntry(DayValueH dv) + { + super(); + this.datetime = new ATechDate(this.getDateTimeFormat(), dv.getDt_info()); + this.bg_original = "" + dv.getBg(); + this.bg_unit = DataAccessMeter.BG_MGDL; + this.entry_object = dv; + this.object_status = MeterValuesEntry.OBJECT_STATUS_OLD; + } + + + /** * Set DateTime Object (ATechDate) * * @param dt ATechDate instance Modified: trunk/ggc-meter/src/ggc/meter/data/db/GGCMeterDb.java =================================================================== --- trunk/ggc-meter/src/ggc/meter/data/db/GGCMeterDb.java 2009-06-20 15:39:47 UTC (rev 809) +++ trunk/ggc-meter/src/ggc/meter/data/db/GGCMeterDb.java 2009-06-20 15:41:13 UTC (rev 810) @@ -12,6 +12,7 @@ import org.apache.commons.logging.LogFactory; import org.hibernate.Criteria; import org.hibernate.Query; +import org.hibernate.criterion.Expression; import org.hibernate.criterion.Projections; import com.atech.db.hibernate.HibernateDb; @@ -57,7 +58,7 @@ { super(db); - getAllElementsCount(); + //getAllElementsCount(); } @@ -69,17 +70,29 @@ */ public int getAllElementsCount() { - Integer in = null; - int sum_all = 0; - - Criteria criteria = this.getSession().createCriteria(DayValueH.class); - criteria.setProjection(Projections.rowCount()); - in = (Integer) criteria.list().get(0); - sum_all = in.intValue(); - - log.debug("Old Meter Data in Db: " + in.intValue()); - - return sum_all; + try + { + Integer in = null; + int sum_all = 0; + + Criteria criteria = this.getSession().createCriteria(DayValueH.class); + criteria.add(Expression.eq("person_id", (int)m_da.getCurrentUserId())); + criteria.add(Expression.gt("bg", 0)); + //criteria.createCriteria("person_id", (int)m_da.getCurrentUserId()); + criteria.setProjection(Projections.rowCount()); + in = (Integer) criteria.list().get(0); + sum_all = in.intValue(); + + log.debug("Old Meter Data in Db: " + in.intValue()); + + return sum_all; + } + catch(Exception ex) + { + log.error("getAllElementsCount: " + ex, ex); + ex.printStackTrace(); + return 0; + } } @@ -90,11 +103,11 @@ * * @return */ - public Hashtable<String,DayValueH> getMeterValues(MeterDataReader mdr) + public Hashtable<String,Object> getMeterValues(MeterDataReader mdr) { + //Hashtable<String,DayValueH> + Hashtable<String,Object> ht = new Hashtable<String,Object>(); - Hashtable<String,DayValueH> ht = new Hashtable<String,DayValueH>(); - log.info("getMeterValues()"); //mdr.se Modified: trunk/ggc-meter/src/ggc/meter/plugin/MeterPlugInServer.java =================================================================== --- trunk/ggc-meter/src/ggc/meter/plugin/MeterPlugInServer.java 2009-06-20 15:39:47 UTC (rev 809) +++ trunk/ggc-meter/src/ggc/meter/plugin/MeterPlugInServer.java 2009-06-20 15:41:13 UTC (rev 810) @@ -6,7 +6,6 @@ import ggc.plugin.DevicePlugInServer; import ggc.plugin.cfg.DeviceConfigEntry; import ggc.plugin.cfg.DeviceConfigurationDialog; -import ggc.plugin.data.DeviceDataHandler; import ggc.plugin.gui.AboutBaseDialog; import ggc.plugin.gui.DeviceInstructionsDialog; import ggc.plugin.list.BaseListDialog; @@ -16,7 +15,6 @@ import javax.swing.JFrame; import javax.swing.JMenu; -import com.atech.db.DbDataReaderAbstract; import com.atech.db.hibernate.transfer.BackupRestoreCollection; import com.atech.utils.ATDataAccessAbstract; @@ -128,9 +126,10 @@ { case MeterPlugInServer.COMMAND_READ_METER_DATA: { - DbDataReaderAbstract reader = (DbDataReaderAbstract)obj_data; - DeviceDataHandler ddh = m_da_local.getDeviceDataHandler(); - ddh.setDbDataReader(reader); + // TODO: Remove this + //DbDataReaderAbstract reader = (DbDataReaderAbstract)obj_data; + //DeviceDataHandler ddh = m_da_local.getDeviceDataHandler(); + //ddh.setDbDataReader(reader); //new MeterInstructionsDialog(reader, this); new DeviceInstructionsDialog(m_da_local, /*reader,*/ this); Modified: trunk/ggc-meter/src/ggc/meter/util/DataAccessMeter.java =================================================================== --- trunk/ggc-meter/src/ggc/meter/util/DataAccessMeter.java 2009-06-20 15:39:47 UTC (rev 809) +++ trunk/ggc-meter/src/ggc/meter/util/DataAccessMeter.java 2009-06-20 15:41:13 UTC (rev 810) @@ -1,6 +1,7 @@ package ggc.meter.util; import ggc.meter.data.MeterDataHandler; +import ggc.meter.data.MeterDataReader; import ggc.meter.data.cfg.MeterConfigurationDefinition; import ggc.meter.data.db.GGCMeterDb; import ggc.meter.manager.MeterManager; @@ -52,7 +53,7 @@ /** * PlugIn Version */ - public static final String PLUGIN_VERSION = "1.0.7"; + public static final String PLUGIN_VERSION = "1.1.0"; private static DataAccessMeter s_da = null; // This is handle to unique @@ -102,6 +103,7 @@ loadReadingStatuses(); createPlugInDataRetrievalContext(); loadWebLister(); + createOldDataReader(); } @@ -458,4 +460,14 @@ } + /** + * Create Old Data Reader + */ + public void createOldDataReader() + { + this.m_old_data_reader = new MeterDataReader(this); + } + + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |