/// <summary> /// This method retrieves a list of diplay items from the device server. /// </summary> /// <param name="eDisplayType">The type of display items to retrieve.</param> /// <param name="iDisplayCount">The number of display items to retrieve.</param> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ --------------------------------------------- // 10/10/08 jrf 9.50 Created. // private void GetDisplayItems(DisplayType eDisplayType, int iDisplayCount) { object objQuantity = null; object objOccurenceType = null; object objPeakNum = null; object objTimeOfOccurence = null; object objIDCode = null; object objValue = null; OccurrenceType eOccurenceType = OccurrenceType.Current; DisplayItemSettings ItemSettings; DisplayScale QuantityScale = DisplayScale.Units; string strValue = null; short sMaxStringLength = 80; short sResponse = DEVICE_SERVER_SUCCESS; short sDisplayProgress = 0; short sPeakNumber = 0; short sIDCode = 0; int iQuantity = 0; int iOccurenceType = 0; int iIndex = 0; Collection <DisplayItemSettings> colDisplayItemSettings = null; switch (eDisplayType) { case DisplayType.Normal: { colDisplayItemSettings = m_DisplaySchedule.NormalDisplay; break; } case DisplayType.Alternate: { colDisplayItemSettings = m_DisplaySchedule.AlternateDisplay; break; } default: { colDisplayItemSettings = m_DisplaySchedule.TestDisplay; break; } } //Find each display item's settings. for (int i = 1; i <= iDisplayCount; i++) { sResponse = VirtualDevice.GetDisplayItem((short)eDisplayType, (short)i, ref objQuantity, ref objOccurenceType, ref objValue, ref strValue, sMaxStringLength, ref objPeakNum, ref objTimeOfOccurence, ref objIDCode, sDisplayProgress); if (DEVICE_SERVER_SUCCESS == sResponse && null != objQuantity && null != objOccurenceType && null != objValue && null != strValue && null != objPeakNum && null != objTimeOfOccurence && null != objIDCode) { iQuantity = (int)Convert.ChangeType(objQuantity, typeof(int), CultureInfo.InvariantCulture); iOccurenceType = (int)Convert.ChangeType(objOccurenceType, typeof(int), CultureInfo.InvariantCulture); eOccurenceType = (OccurrenceType)iOccurenceType; sPeakNumber = (short)Convert.ChangeType(objPeakNum, typeof(short), CultureInfo.InvariantCulture); sIDCode = (short)Convert.ChangeType(objIDCode, typeof(short), CultureInfo.InvariantCulture); //Extract the scale from the quantity code. QuantityCode Quantity = QuantityCode.Create((uint)iQuantity); ElectricalQuantityCode ElectricalQuantity = Quantity as ElectricalQuantityCode; if (null != ElectricalQuantity) { if (ElectricalQuantityCode.ElectricalScale.Kilo == ElectricalQuantity.Scale) { QuantityScale = DisplayScale.Kilo; } //Now that we have the scale store the quantity in it's units value for the display schedule. ElectricalQuantity.Scale = ElectricalQuantityCode.ElectricalScale.Units; iQuantity = (int)ElectricalQuantity.Code; } ItemSettings = new DisplayItemSettings((uint)iQuantity, eOccurenceType); ItemSettings.DisplayOrder = (uint)i; ItemSettings.IDCode = (uint)sIDCode; ItemSettings.PeakNumber = (uint)sPeakNumber; if (null != ElectricalQuantity && ElectricalQuantity.IsEnergyQuantity) { iIndex = ENERGY; } else if (null != ElectricalQuantity && ElectricalQuantity.IsDemandQuantity && false == ElectricalQuantity.IsCumulativeQuantity) { iIndex = DEMAND; } else if (null != ElectricalQuantity && ElectricalQuantity.IsCumulativeQuantity) { iIndex = CUMULATIVE; } ItemSettings.LeadingZeroesDisplayed = m_ablnDisplayLeadingZeroes[iIndex]; ItemSettings.FloatingDecimalEnabled = m_ablnDisplayFloatingDecimal[iIndex]; ItemSettings.DigitCount = (uint)m_aiDisplayDigitCount[iIndex]; ItemSettings.DecimalDigitCount = (uint)m_aiDisplayDecimalDigitCount[iIndex]; //Only set the following values if we have an //energy or demand quantity if (null != ElectricalQuantity) { //Only set the scale if we have an electrical quantity. ItemSettings.Scale = QuantityScale; if (strValue.Contains("-")) { //Since we have a date reset the scale and set the date. //Scale and date are stored in the same location in the //display schedule. Resetting this value allows us to //know which one to use. ItemSettings.TOODateDisplayed = true; ItemSettings.Scale = DisplayScale.Units; ItemSettings.DateDisplay = m_eDisplayDateFormat; } if (strValue.Contains(":")) { ItemSettings.TOOTimeDisplayed = true; } ItemSettings.AnnunciatorEnabled = m_blnDisplayAnnunciatorEnabled; } else { //Only set the date if we don't have an electrical quantity ItemSettings.DateDisplay = m_eDisplayDateFormat; } colDisplayItemSettings.Add(ItemSettings); } } }