Beispiel #1
0
		public void ShowTip(Point pt, BGE bge)
		{
			string s = bge.Date.ToString("MM/dd/yy ") + bge.Date.ToString("t", DateTimeFormatInfo.InvariantInfo);

			s += "\nReading: " + bge.Reading.ToString();
			s += "\nCarbs in 4 Hours: " + bge.CarbsIn4.ToString();
			int nHours = bge.MinutesSinceCarbs / 60;
			int nMinutes = bge.MinutesSinceCarbs - nHours * 60;
			s += "\nTime Since Carbs: " + nHours.ToString() + ":" + nMinutes.ToString("0#");
			if (bge.Carbs > 0)
				s += "\nCarbs: " + bge.Carbs.ToString();

			if (bge.InterpReading)
				s += "\n**** INTERPOLATED ****\n" + bge.Comment;
			else if (bge.Comment.Length > 0)
				s += "\nComment: " + bge.Comment;

			m_sTip = s;

			Graphics gr = m_pbxTip.CreateGraphics();

			SizeF szf = gr.MeasureString(s, m_hFont);
			Size sz = new Size((int)Math.Floor(szf.Width), (int)Math.Floor(szf.Height));

			this.Show();
			this.SetBounds(pt.X - sz.Width / 2, pt.Y - sz.Height, sz.Width + 4, sz.Height + 4, BoundsSpecified.All);
		}
Beispiel #2
0
		public bool FMatch(BGE bge)
		{
			if (bge.Date >= dttmCutoff && bge.Date <= dttmCutoffLast)
				return true;

			return false;
		}
Beispiel #3
0
	/* U P D A T E  C A R B  L I S T */
	/*----------------------------------------------------------------------------
		%%Function: UpdateCarbList
		%%Qualified: bg._bg.UpdateCarbList
		%%Contact: rlittle

	----------------------------------------------------------------------------*/
	private int UpdateCarbList(BGE bgeCur, ref SortedList slbge)
	{
		// retire all the items at the beginning of the list
		while (slbge.Count > 0)
			{
			BGE bgeFirst = (BGE)slbge.GetByIndex(0);

			if (bgeFirst.Date.AddHours(4.0) > bgeCur.Date)
				break; // nothing left to retire

			slbge.RemoveAt(0);
			}

		// now, if bgeCur has carbs, then add it to the list
		if (bgeCur.Carbs > 0)
			slbge.Add(bgeCur.Key, bgeCur);

		int nCarbs = 0;

		for (int i = 0, iLast = slbge.Count; i < iLast; i++)
			{
			BGE bge = (BGE) slbge.GetByIndex(i);

			if (bge.Date != bgeCur.Date)
				nCarbs += bge.Carbs;
			}

		return nCarbs;
	}
Beispiel #4
0
	public void SetTo(BGE bge)
	{
		m_type = bge.Type;
		m_dttm = bge.Date;
		m_nBg = bge.Reading;
		m_nCarbs = bge.Carbs;
		m_sComment = bge.Comment;
		m_sMeal = bge.Meal;
	}
Beispiel #5
0
	/* C O M P A R E */
	/*----------------------------------------------------------------------------
		%%Function: Compare
		%%Qualified: bg.BGE.Compare
		%%Contact: rlittle

		
	----------------------------------------------------------------------------*/
	static public int Compare(BGE bge1, BGE bge2, CompareType type)
	{
		switch (type)
			{
			case CompareType.Type:
				return (int)bge1.Type - (int)bge2.Type;
			case CompareType.Reading:
				return bge1.Reading - bge2.Reading;
			case CompareType.Date:
				return DateTime.Compare(bge1.Date, bge2.Date);
			case CompareType.Carbs:
				return bge1.Carbs - bge2.Carbs;
			case CompareType.Comment:
				return String.Compare(bge1.FullComment, bge2.FullComment);
			default:
				return 0; 
			}
	}
Beispiel #6
0
	/* P T F  F R O M  B G E  A V G */
	/*----------------------------------------------------------------------------
		%%Function: PtfFromBgeAvg
		%%Qualified: bg.SBGE.PtfFromBgeAvg
		%%Contact: rlittle

	----------------------------------------------------------------------------*/
	PointF PtfFromBgeAvg(DateTime dayFirst, BGE bge, double dxQuarter, double dyBg)
	{
		float x = XFromDate(dayFirst, bge.Date, dxQuarter);
		float y = YFromReading(bge.WgtAvg, dyBg);

		// now we've got the number of quarters.  figure out the bge
		return new PointF(x,y);
	}
Beispiel #7
0
	int NGetForDttm(SortedList slbge, BGE bgeRef, DateTime dttmNext, double dMinToleranceBack, double dMinToleranceForward)
	{
		int iFirst = 0;
		int iKey = 0;
		BGE bge = null;

		iKey = iFirst = slbge.IndexOfKey(bgeRef.Key);

		for ( ; iFirst >= 0; iFirst--)
			{
			bge = (BGE)slbge.GetByIndex(iFirst);

			if (bge.Reading <= 0
				|| bge.Type == BGE.ReadingType.Control)
				{
				continue;
				}

			if (bge.Date >= dttmNext.AddMinutes(-dMinToleranceBack)
				&& bge.Date <= dttmNext.AddMinutes(dMinToleranceForward))
				{
				return bge.Reading;
				}

			if (bge.Date < dttmNext.AddMinutes(-dMinToleranceBack))
				break;
			}

		// no luck finding it going back; now look going forward
		for (iFirst = iKey; iFirst < slbge.Count; iFirst++)
			{
			bge = (BGE)slbge.GetByIndex(iFirst);

			if (bge.Reading <= 0
				|| bge.Type == BGE.ReadingType.Control)
				{
				continue;
				}

			if (bge.Date >= dttmNext.AddMinutes(-dMinToleranceBack)
				&& bge.Date <= dttmNext.AddMinutes(dMinToleranceForward))
				{
				return bge.Reading;
				}

			if (bge.Date> dttmNext.AddMinutes(dMinToleranceForward))
				break;
			}

		return 0;
	}
Beispiel #8
0
	void AddBgeToSearch(BGE bge)
	{
		ListViewItem lvi = new ListViewItem();

		lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
		lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
		lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
		lvi.SubItems.Add(new ListViewItem.ListViewSubItem());

		m_lvMeals.Items.Add(lvi);

		lvi.SubItems[3].Text = bge.FullComment;
		if (bge.Carbs != 0)
			lvi.SubItems[2].Text = bge.Carbs.ToString();
		lvi.SubItems[1].Text = bge.Date.ToString();
		lvi.SubItems[0].Text = m_idGroupCur.ToString();
		lvi.Tag = bge;
	}
Beispiel #9
0
	/* A D D  E N T R Y  C O R E */
	/*----------------------------------------------------------------------------
		%%Function: AddEntryCore
		%%Qualified: bg._bg.AddEntryCore
		%%Contact: rlittle

	----------------------------------------------------------------------------*/
	void AddEntryCore(BGE bge, bool fFromDevice)
	{
		BGE bgeCurrent = m_bgeCurrent;

		if (fFromDevice)
			{
			int iKey = m_slbge.IndexOfKey(bge.Key);

			if (iKey >= 0)
				{
				bgeCurrent = (BGE)m_slbge.GetByIndex(iKey);

				if (bgeCurrent.Reading == bge.Reading)
					// readings match as does the date; nothing to do
					return;

				MessageBox.Show("Conflicting entry read from device!  bgeOld.Reading = " + bgeCurrent.Reading.ToString() + "("+bgeCurrent.Date.ToString("s")+"), bgeNew.Reading = " + bge.Reading.ToString());
				return;
				}
			// no match yet...look for a "close" match
			DateTime dttm = new DateTime(bge.Date.Year, bge.Date.Month, bge.Date.Day, bge.Date.Hour, bge.Date.Minute, 0);
			iKey = m_slbge.IndexOfKey(dttm.ToString("s"));
			if (iKey >= 0)
				{
				//ooh a match.  update this one if the readings match
				bgeCurrent = (BGE)m_slbge.GetByIndex(iKey);

				if (bgeCurrent.Reading != bge.Reading)
					{
					MessageBox.Show("Conflicting entry read from device!  bgeOld.Reading = " + bgeCurrent.Reading.ToString() + "("+bgeCurrent.Date.ToString("s")+"), bgeNew.Reading = " + bge.Reading.ToString());
					return;
					}
				// otherwise, fallthrough and do the update
				bge.Comment = bgeCurrent.Comment;
				bge.Meal = bgeCurrent.Meal;
				bge.Type = bgeCurrent.Type;
				}
			}

		XmlNode nodeReading = m_dom.CreateElement("", "reading", "http://www.thetasoft.com/schemas/bg");
		XmlNode nodeBg = m_dom.CreateElement("", "bg", "http://www.thetasoft.com/schemas/bg");
		XmlNode nodeDate = m_dom.CreateElement("", "date", "http://www.thetasoft.com/schemas/bg");
		XmlNode nodeTime = m_dom.CreateElement("", "time", "http://www.thetasoft.com/schemas/bg");

		XmlNode nodeComment = null;
		XmlNode nodeMeal = null;
		XmlNode nodeCarbs = null;

		if (m_ebCarbs.Text.Length > 0)
			nodeCarbs = m_dom.CreateElement("", "carbs", "http://www.thetasoft.com/schemas/bg");

		if (m_ebComment.Text.Length > 0)
			nodeComment = m_dom.CreateElement("", "comment", "http://www.thetasoft.com/schemas/bg");

		if (m_cbxMeal.Text.Length > 0)
			nodeMeal = m_dom.CreateElement("", "meal", "http://www.thetasoft.com/schemas/bg");

		nodeBg.InnerText = bge.Reading.ToString();
		nodeDate.InnerText = bge.Date.ToString("d");
		nodeTime.InnerText = bge.Date.ToString("T", DateTimeFormatInfo.InvariantInfo);
		nodeReading.AppendChild(nodeDate);
		nodeReading.AppendChild(nodeTime);
		nodeReading.AppendChild(nodeBg);
		if (nodeCarbs != null)
			{
			nodeCarbs.InnerText = bge.Carbs.ToString();
			nodeReading.AppendChild(nodeCarbs);
			}

		if (nodeComment != null)
			{
			nodeComment.InnerText = bge.Comment;
			nodeReading.AppendChild(nodeComment);
			}

		if (nodeMeal != null)
			{
			nodeMeal.InnerText = bge.Meal;
			nodeReading.AppendChild(nodeMeal);
			}

		nodeReading.Attributes.Append(m_dom.CreateAttribute("type"));
		nodeReading.Attributes["type"].Value = BGE.StringFromReadingType(bge.Type);

		if (bgeCurrent == null)
			{
			int iKey;
			if ((iKey = m_slbge.IndexOfKey(bge.Key)) >= 0)
				{
				if (!fFromDevice)
					{
					MessageBox.Show("Duplicate entry detected!");
					return;
					}

				BGE bgeOld = (BGE)m_slbge.GetByIndex(iKey);
				if (bgeOld.Reading == bge.Reading)
					{
					// readings match, so does date, do nothing
					return;
					}

				MessageBox.Show("Conflicting entry read from device!  bgeOld.Reading = " + bgeOld.Reading.ToString() + ", bgeNew.Reading = " + bge.Reading.ToString());
				return;
				}

			AddBge(bge);
			m_slbge.Add(bge.Key, bge);
			m_dom.SelectSingleNode("/b:bg", m_nsmgr).AppendChild(nodeReading);
			m_dom.Save("c:\\docs\\bg.xml");
			}
		else
			{
			XmlNode node = m_dom.SelectSingleNode("/b:bg/b:reading[b:date='"+bgeCurrent.Date.ToString("d")+"' and b:time='"+bgeCurrent.Date.ToString("T", DateTimeFormatInfo.InvariantInfo)+"']", m_nsmgr);
			XmlNode nodeRoot = m_dom.SelectSingleNode("/b:bg", m_nsmgr);

			nodeRoot.RemoveChild(node);
			nodeRoot.AppendChild(nodeReading);

			// we need to edit the current item.
			bgeCurrent.SetTo(bge);	// this takes care of m_slbge
			ListViewItem lvi = null;

			// try to add it to the list of available meals
			try
				{
				if (bge.Meal.Length > 0)
					{
					AddMeal(bge.Meal);
					}
				}
			catch 
				{
				}

			if (bgeCurrent != m_bgeCurrent)
				{
				lvi = LviFindBge(bgeCurrent);

				if (lvi == null)
					MessageBox.Show("Couldn't find matching LVI for BGE");
				}
			else
				lvi = m_lvHistory.SelectedItems[0];

			UpdateBge(bgeCurrent, lvi);				// this handles updating the listbox
			if (fFromDevice)
				lvi.BackColor = Color.LightBlue;
			m_dom.Save("c:\\docs\\bg.xml");
			}

		m_fDirtyStats = true;
	}
Beispiel #10
0
	ListViewItem LviFindBge(BGE bge)
	{
		foreach (ListViewItem lviT in m_lvHistory.Items)
			{
			if (((BGE)lviT.Tag) == bge)
				return lviT;
			}
		return null;
	}
Beispiel #11
0
	/* A D D  B G E */
	/*----------------------------------------------------------------------------
		%%Function: AddBge
		%%Qualified: bg._bg.AddBge
		%%Contact: rlittle

		
	----------------------------------------------------------------------------*/
	void AddBge(BGE bge)
	{
		ListViewItem lvi = new ListViewItem();

		lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
		lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
		lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
		lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
		lvi.SubItems.Add(new ListViewItem.ListViewSubItem());
		if (bge != null && bge.Type == BGE.ReadingType.New)
			lvi.BackColor = Color.Yellow;
		m_lvHistory.Items.Add(lvi);
		UpdateBge(bge, lvi);
	}
Beispiel #12
0
	/* U P D A T E  B G E */
	/*----------------------------------------------------------------------------
		%%Function: UpdateBge
		%%Qualified: bg._bg.UpdateBge
		%%Contact: rlittle

	----------------------------------------------------------------------------*/
	void UpdateBge(BGE bge, ListViewItem lvi)
	{
		lvi.Tag = bge;

		if (bge == null)
			{
			lvi.SubItems[0].Text = "* (New Entry)";
			}
		else
			{
			lvi.SubItems[4].Text = bge.FullComment;
			if (bge.Carbs != 0)
				lvi.SubItems[3].Text = bge.Carbs.ToString();
			lvi.SubItems[2].Text = bge.Reading.ToString();
			lvi.SubItems[1].Text = BGE.StringFromReadingType(bge.Type);
			lvi.SubItems[0].Text = bge.Date.ToString();
			if (bge.Type == BGE.ReadingType.New)
				lvi.BackColor = Color.Yellow;
			else
				lvi.BackColor = m_lvHistory.BackColor;
			}
	}
Beispiel #13
0
	/* L O A D  B G  D A T A */
	/*----------------------------------------------------------------------------
		%%Function: LoadBgData
		%%Qualified: bg._bg.LoadBgData
		%%Contact: rlittle

		
	----------------------------------------------------------------------------*/
	void LoadBgData()
	{
		XmlDocument dom = new XmlDocument();

		InitReadings();

		dom.Load("c:\\docs\\bg.xml");

		XmlNamespaceManager nsmgr = new XmlNamespaceManager(dom.NameTable);

		nsmgr.AddNamespace("b", "http://www.thetasoft.com/schemas/bg");

		XmlNodeList nodes = dom.SelectNodes("//b:reading", nsmgr);

		if (nodes != null && nodes.Count > 0)
			{
			foreach (XmlNode nodeT in nodes)
				{
				BGE bge;

				string sDate, sTime, sType, sComment, sMeal;
				int nBg, nCarbs;
				BGE.ReadingType type;

				int iChild = 0;

				sDate = nodeT.ChildNodes[iChild++].InnerText;
				sTime = nodeT.ChildNodes[iChild++].InnerText;
				nBg = 0;
				nCarbs = 0;

				if (iChild < nodeT.ChildNodes.Count
					&& String.Compare(nodeT.ChildNodes[iChild].LocalName, "bg") == 0)
					{
					string sBg = nodeT.ChildNodes[iChild].InnerText;

					if (sBg.Length > 0)
						nBg = Int32.Parse(sBg);

					iChild++;
					}

				if (iChild < nodeT.ChildNodes.Count
					&& String.Compare(nodeT.ChildNodes[iChild].LocalName, "carbs") == 0)
					{
					string sCarbs = nodeT.ChildNodes[iChild].InnerText;

					if (sCarbs.Length > 0)
						nCarbs = Int32.Parse(sCarbs);

					iChild++;
					}

				if (iChild < nodeT.ChildNodes.Count
					&& String.Compare(nodeT.ChildNodes[iChild].LocalName, "comment") == 0)
					{
					sComment = nodeT.ChildNodes[iChild].InnerText;
					iChild++;
					}
				else
					{
					sComment = "";
					}

				if (iChild < nodeT.ChildNodes.Count
					&& String.Compare(nodeT.ChildNodes[iChild].LocalName, "meal") == 0)
					{
					sMeal = nodeT.ChildNodes[iChild].InnerText;
					iChild++;
					}
				else
					{
					sMeal = "";
					}

				sType = nodeT.Attributes.GetNamedItem("type", "").Value;

//				sDate = nodeT.SelectSingleNode("b:date", nsmgr).InnerText;
//				sTime = nodeT.SelectSingleNode("b:time", nsmgr).InnerText;
//				sType = nodeT.SelectSingleNode("@type").Value;
//				try
//				{
//					sComment = nodeT.SelectSingleNode("b:comment", nsmgr).InnerText;
//				} catch { sComment = ""; };

//				try
//				{
//					sMeal = nodeT.SelectSingleNode("b:meal", nsmgr).InnerText;
//				} catch { sMeal = ""; };

//				try
//				{
//					nCarbs = Int32.Parse(nodeT.SelectSingleNode("b:carbs", nsmgr).InnerText);
//				} catch { nCarbs = 0; };

				type = BGE.ReadingTypeFromString(sType);
				
				bge = new BGE(sDate, sTime, type, nBg, nCarbs, sComment, sMeal);
				m_slbge.Add(bge.Key, bge);
				}
			}

		foreach (BGE bge in m_slbge.Values)
			{
			AddBge(bge);

			try
				{
				if (bge.Meal.Length > 0)
					{
					AddMeal(bge.Meal);
					}
				}
			catch 
				{
				}
			}

		m_dom = dom;
		m_nsmgr = nsmgr;
	}
Beispiel #14
0
	public BGE(BGE bge)
	{
		m_dttm = bge.m_dttm;
		m_nBg = bge.m_nBg;
		m_type = bge.m_type;
		m_nCarbs = bge.m_nCarbs;
		m_sComment = bge.m_sComment;
		m_sMeal = bge.m_sMeal;
		m_fInterp = bge.m_fInterp;
		m_nMinutesSinceLastCarb = bge.m_nMinutesSinceLastCarb;
		m_nCarbsInLast4Hours = bge.m_nCarbsInLast4Hours;
		m_nWgtAvg = bge.m_nWgtAvg;
	}
Beispiel #15
0
	/* A D D  I N T E R P O L A T E D  B G E */
	/*----------------------------------------------------------------------------
		%%Function: AddInterpolatedBge
		%%Qualified: bg._bg.AddInterpolatedBge
		%%Contact: rlittle

	----------------------------------------------------------------------------*/
	void AddInterpolatedBge(SortedList slbge, DateTime dttmEst, int nEst, string sComment)
	{
		BGE bgeEst = new BGE(dttmEst.ToString("d"), dttmEst.ToString("T"), BGE.ReadingType.SpotTest, (int)nEst, 0, "interpolated: " + sComment, "");
		int cTries = 0;
		bgeEst.InterpReading = true;

		while (cTries < 4) // we allow attempts to miss a duplicate item
			{
			try
				{
				slbge.Add(bgeEst.Key, bgeEst);
//				if (bgeEst.Date.Month == 6)
//					Debug.WriteLine(String.Format("   AddInterp {0}", bgeEst.ToString()));
				return;	// we succeeded!
				}
			catch
				{
				dttmEst = dttmEst.AddMinutes(1.0);
				bgeEst = new BGE(dttmEst.ToString("d"), dttmEst.ToString("T"), BGE.ReadingType.SpotTest, (int)nEst, 0, "interpolated: " + sComment, "");
				bgeEst.InterpReading = true;
				}
			cTries++;
			}

		throw(new Exception("Too many BGE conflicts on interp add"));
	}
Beispiel #16
0
	/* R E A D  F R O M  D E V I C E */
	/*----------------------------------------------------------------------------
		%%Function: ReadFromDevice
		%%Qualified: bg._bg.ReadFromDevice
		%%Contact: rlittle

		
	----------------------------------------------------------------------------*/
	private void ReadFromDevice(object sender, System.EventArgs e) 
	{
		ArrayList pls = GetReadingsFromDeviceReal();

		foreach (string s in pls)
			{
			int iFirst = 0, iNext;

			if (s.Substring(0, 2) != "P ")
				continue;

			string sDay = SGetNextQuotedField(s, iFirst, out iNext);
			string sDate = SGetNextQuotedField(s, iFirst = iNext, out iNext);
			string sTime = SGetNextQuotedField(s, iFirst = iNext, out iNext);
			string sReading = SGetNextQuotedField(s, iFirst = iNext, out iNext);

			if (sReading.Substring(0,1) == "C")
				continue;

			BGE bge = new BGE(sDate, sTime, BGE.ReadingType.New, Int32.Parse(sReading), 0, "", "");

			AddEntryCore(bge, true);
			}
	}
Beispiel #17
0
	/* C O M P A R E  T O */
	/*----------------------------------------------------------------------------
		%%Function: CompareTo
		%%Qualified: bg.BGE.CompareTo
		%%Contact: rlittle

		
	----------------------------------------------------------------------------*/
	public int CompareTo(BGE bge, CompareType type)
	{	
		return Compare(this, bge, type);
	}
Beispiel #18
0
	SortedList SlbgeGetMealSubset(BGE bge)
	{
		int iMeal = m_slbge.IndexOfKey(bge.Key);
		int iFirst = iMeal;
		int iLast = iMeal + 1;

		while (iFirst >= 0)
			{
			BGE bgeT = (BGE)m_slbge.GetByIndex(iFirst);

			if (bgeT.Reading != 0 && bgeT.Type != BGE.ReadingType.Control)
				break;

			iFirst--;
			}

		if (iFirst == -1)
			return null;

		while (iLast < m_slbge.Count)
			{
			BGE bgeT = (BGE)m_slbge.GetByIndex(iLast);

			if (bgeT.Carbs > 0)
				break;
			iLast++;
			}

		if (iLast == m_slbge.Count)
			iLast--;

		SortedList slbge = new SortedList();

		for ( ; iFirst <= iLast; iFirst++)
			{
			BGE bgeT = (BGE)m_slbge.GetByIndex(iFirst);

			slbge.Add(bgeT.Key, bgeT.Clone());
			}

		return slbge;
	}
Beispiel #19
0
	/* A D D  E N T R Y */
	/*----------------------------------------------------------------------------
		%%Function: AddEntry
		%%Qualified: bg._bg.AddEntry
		%%Contact: rlittle

		
	----------------------------------------------------------------------------*/
	private void AddEntry(object sender, System.EventArgs e) 
	{  
		int nCarbs = m_ebCarbs.Text.Length > 0 ? Int32.Parse(m_ebCarbs.Text) : 0;
		BGE bge = new BGE(m_ebDate.Text, m_ebTime.Text, BGE.ReadingTypeFromString(m_cbxType.Text), Int32.Parse(m_ebReading.Text), nCarbs, m_ebComment.Text, m_cbxMeal.Text);

		AddEntryCore(bge, false);
	}
Beispiel #20
0
	/* A D D  M E A L */
	/*----------------------------------------------------------------------------
		%%Function: AddMeal
		%%Qualified: bg._bg:MP.AddMeal
		%%Contact: rlittle

	----------------------------------------------------------------------------*/
	public void AddMeal(SortedList slbge, SortedList slbgeRef, BGE bgeMeal)
	{
		if (m_sDescription == null)
			m_sDescription = bgeMeal.Meal;

		m_plslbgeMeals.Add(slbge);

		int n;

		n = NGetForDttm(slbgeRef, bgeMeal, bgeMeal.Date, 90.0, 0.0);
		if (n != 0)
			{
			m_mpmptnMealSum[(int)MPT.Hour0] += n;
			m_mpmptcMeals[(int)MPT.Hour0]++;
			}

		n = NGetForDttm(slbgeRef, bgeMeal, bgeMeal.Date.AddMinutes(60), 15.0, 15.0);
		if (n != 0)
			{
			m_mpmptnMealSum[(int)MPT.Hour1] += n;
			m_mpmptcMeals[(int)MPT.Hour1]++;
			}

		n = NGetForDttm(slbgeRef, bgeMeal, bgeMeal.Date.AddMinutes(120), 30.0, 30.0);
		if (n != 0)
			{
			m_mpmptnMealSum[(int)MPT.Hour2] += n;
			m_mpmptcMeals[(int)MPT.Hour2]++;
			}

		n = NGetForDttm(slbgeRef, bgeMeal, bgeMeal.Date.AddMinutes(240), 50.0, 50.0);
		if (n != 0)
			{
			m_mpmptnMealSum[(int)MPT.Hour4] += n;
			m_mpmptcMeals[(int)MPT.Hour4]++;
			}

		n = NGetForDttm(slbgeRef, bgeMeal, bgeMeal.Date.AddMinutes(120), 30.0, 45.0);
		if (n != 0)
			{
			m_mpmptnMealSum[(int)MPT.PostMeal] += n;
			m_mpmptcMeals[(int)MPT.PostMeal]++;
			}

		if (bgeMeal.Type == BGE.ReadingType.Dinner)
			{
			// look for the following mornings first reading
			n = NGetForDttm(slbgeRef, bgeMeal, new DateTime(bgeMeal.Date.Year, bgeMeal.Date.Month, bgeMeal.Date.Day).AddDays(1.0).AddHours(5.0), 0.0, 240.0);
			if (n != 0)
				{
				m_mpmptnMealSum[(int)MPT.Morning] += n;
				m_mpmptcMeals[(int)MPT.Morning]++;
				}
			}
	}
Beispiel #21
0
	/* D I S P L A Y  B G E */
	/*----------------------------------------------------------------------------
		%%Function: DisplayBge
		%%Qualified: bg._bg.DisplayBge
		%%Contact: rlittle

		
	----------------------------------------------------------------------------*/
	void DisplayBge(BGE bge)
	{
		if (bge == null)
			{
			m_ebDate.Text = System.DateTime.Now.ToString("d");
			m_ebTime.Text = System.DateTime.Now.ToString("T", DateTimeFormatInfo.InvariantInfo);
			m_ebComment.Text = "";
			m_cbxMeal.Text = "";
			m_cbxType.Text = "SpotTest";
			m_ebReading.Text = "";
			m_ebCarbs.Text = "";
			m_pbAdd.Text = "Add";
			m_bgeCurrent = null;
			}
		else
			{
			m_ebDate.Text = bge.Date.ToString("d");
			m_ebTime.Text = bge.Date.ToString("T", DateTimeFormatInfo.InvariantInfo);
			m_ebComment.Text = bge.Comment;
			m_cbxMeal.Text = bge.Meal;
			m_ebReading.Text = bge.Reading.ToString();
			if (bge.Carbs != 0)
				m_ebCarbs.Text = bge.Carbs.ToString(); 
			else
				m_ebCarbs.Text = "";
			m_cbxType.Text = BGE.StringFromReadingType(bge.Type);
			m_pbAdd.Text = "Update";
			m_bgeCurrent = bge;
			}
	}