Handle the various formats used for analog alarm points (High# and Low#) so that the ROs will be correctly replaced on the cover page. The various formats include either a space or a dash or a underscore followed by High, HI, Low or LO followed by a number. The code will treat all of the formats consistently.

This commit is contained in:
Rich 2015-03-11 12:37:12 +00:00
parent 79adb37f12
commit a533c8fc71

View File

@ -5,6 +5,7 @@ using System.Text;
using System.ComponentModel;
using System.Text.RegularExpressions;
using System.IO;
using Volian.Base.Library;
namespace VEPROMS.CSLA.Library
{
@ -1096,7 +1097,7 @@ namespace VEPROMS.CSLA.Library
{
string accpage = accPageID.Substring(0, accPageID.Length - 3);
int index = accPageID.Substring(accPageID.Length - 2, 1)[0] - 'A';
child = GetRoChildByAccPagID(accpage, spDefault, igDefault);
child = GetRoChildByAccPagID(accpage.TrimStart("<".ToCharArray()), spDefault, igDefault);
if (child == null) return null;
if (((rochild)child).children != null && ((rochild)child).children.Length > 0 && ((rochild)child).children.Length > index)
return ((rochild)child).children[index];
@ -1132,12 +1133,24 @@ namespace VEPROMS.CSLA.Library
accPageID = accPageID.Replace("<SP-", "<" + spDefault + "-");
accPageID = accPageID.Replace("<IG-", "<" + igDefault + "-");
accPageID = accPageID.Trim("<>".ToCharArray()); // String < and >
if (_dicROAPID.ContainsKey(accPageID))
return _dicROAPID[accPageID];
string key = FormatKey(accPageID);
if (_dicROAPID.ContainsKey(key))
return _dicROAPID[key];
return null;
}
Regex regRoKeyHigh = new Regex("( |-|_)(HIGH|HI)([0-9])");
Regex regRoKeyLow = new Regex("( |-|_)(LOW|LO)([0-9])");
public string FormatKey(string keyOrig)
{
string key=keyOrig.ToUpper();
key=regRoKeyHigh.Replace(key,"_HIGH$3");
key=regRoKeyLow.Replace(key,"_LOW$3");
if (key != keyOrig) Console.WriteLine("{0}!={1}", key, keyOrig);
return key;
}
private void BuildROAPIDDictionary()
{
int profileDepth = ProfileTimer.Push(">>>> BuildROAPIDDictionary");
if (dicRos == null)
ParseIntoDictionary(_ROFst != null ? _ROFst.ROLookup : _ROFstInfo.ROLookup);
_dicROAPID = new Dictionary<string, rochild>();
@ -1146,6 +1159,7 @@ namespace VEPROMS.CSLA.Library
if (dbi.children != null)
BuildROAPIDDictionary(dbi.dbiAP, dbi.children);
}
ProfileTimer.Pop(profileDepth);
}
private void BuildROAPIDDictionary(string prefix, rochild[] children)
{
@ -1153,7 +1167,7 @@ namespace VEPROMS.CSLA.Library
{
if (child.appid != null && child.appid != "" && child.ID != 0)
{
string key = string.Format("{0}-{1}", prefix, child.appid);
string key = string.Format("{0}-{1}", prefix, FormatKey(child.appid));
if (!_dicROAPID.ContainsKey(key))
_dicROAPID.Add(key, child);
}