Refactor Charter code
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
@@ -8,43 +8,42 @@ namespace LeafWeb.Web.Charter
|
||||
[Serializable]
|
||||
public class CurveParamSet
|
||||
{
|
||||
private readonly ArrayList anetMeasChloro1Data; // y=AnetMeas column, x=PCO2c, for PointLimitType=1
|
||||
private readonly ArrayList anetMeasChloro2Data; // y=AnetMeas column, x=PCO2c, for PointLimitType=2
|
||||
private readonly ArrayList anetMeasChloro3Data; // y=AnetMeas column, x=PCO2c, for PointLimitType=3
|
||||
private readonly ArrayList anetMeasInter1Data; // y=AnetMeas column, x=PCO2i, for PointLimitType=1
|
||||
private readonly ArrayList anetMeasInter2Data; // y=AnetMeas column, x=PCO2i, for PointLimitType=2
|
||||
private readonly ArrayList anetMeasInter3Data; // y=AnetMeas column, x=PCO2i, for PointLimitType=3
|
||||
private readonly ArrayList acChloroData; // y=Ac column, x=CO2cc column
|
||||
private readonly ArrayList ajChloroData; // y=Aj column, x=CO2cj column
|
||||
private readonly ArrayList atChloroData; // y=At column, x=CO2ct column
|
||||
private readonly ArrayList acInterData; // y=Ac column, x=CO2i column
|
||||
private readonly ArrayList ajInterData; // y=Aj column, x=CO2i column
|
||||
private readonly ArrayList atInterData; // y=At column, x=CO2i column
|
||||
private readonly List<XyPoint> _anetMeasChloro1Data; // y=AnetMeas column, x=PCO2c, for PointLimitType=1
|
||||
private readonly List<XyPoint> _anetMeasChloro2Data; // y=AnetMeas column, x=PCO2c, for PointLimitType=2
|
||||
private readonly List<XyPoint> _anetMeasChloro3Data; // y=AnetMeas column, x=PCO2c, for PointLimitType=3
|
||||
private readonly List<XyPoint> _anetMeasInter1Data; // y=AnetMeas column, x=PCO2i, for PointLimitType=1
|
||||
private readonly List<XyPoint> _anetMeasInter2Data; // y=AnetMeas column, x=PCO2i, for PointLimitType=2
|
||||
private readonly List<XyPoint> _anetMeasInter3Data; // y=AnetMeas column, x=PCO2i, for PointLimitType=3
|
||||
private readonly List<XyPoint> _acChloroData; // y=Ac column, x=CO2cc column
|
||||
private readonly List<XyPoint> _ajChloroData; // y=Aj column, x=CO2cj column
|
||||
private readonly List<XyPoint> _atChloroData; // y=At column, x=CO2ct column
|
||||
private readonly List<XyPoint> _acInterData; // y=Ac column, x=CO2i column
|
||||
private readonly List<XyPoint> _ajInterData; // y=Aj column, x=CO2i column
|
||||
private readonly List<XyPoint> _atInterData; // y=At column, x=CO2i column
|
||||
|
||||
public CurveParamSet()
|
||||
{
|
||||
}
|
||||
|
||||
public CurveParamSet(StreamReader sr, ref String errMsg, ref int lineNbr, ref String curveID)
|
||||
public CurveParamSet(StreamReader sr, ref String errMsg, ref int lineNbr, ref String curveId)
|
||||
{
|
||||
bool curveIDSet = false, doneWithAnet = false;
|
||||
String line, firstField;
|
||||
bool curveIdSet = false, doneWithAnet = false;
|
||||
String line;
|
||||
var errorMsg = new StringBuilder("");
|
||||
ArrayList phrases;
|
||||
XYPoint xyPoint1, xyPoint2;
|
||||
int pointLimitType;
|
||||
anetMeasChloro1Data = new ArrayList();
|
||||
anetMeasChloro2Data = new ArrayList();
|
||||
anetMeasChloro3Data = new ArrayList();
|
||||
anetMeasInter1Data = new ArrayList();
|
||||
anetMeasInter2Data = new ArrayList();
|
||||
anetMeasInter3Data = new ArrayList();
|
||||
acChloroData = new ArrayList();
|
||||
ajChloroData = new ArrayList();
|
||||
atChloroData = new ArrayList();
|
||||
acInterData = new ArrayList();
|
||||
ajInterData = new ArrayList();
|
||||
atInterData = new ArrayList();
|
||||
List<string> phrases;
|
||||
XyPoint xyPoint1;
|
||||
_anetMeasChloro1Data = new List<XyPoint>();
|
||||
_anetMeasChloro2Data = new List<XyPoint>();
|
||||
_anetMeasChloro3Data = new List<XyPoint>();
|
||||
_anetMeasInter1Data = new List<XyPoint>();
|
||||
_anetMeasInter2Data = new List<XyPoint>();
|
||||
_anetMeasInter3Data = new List<XyPoint>();
|
||||
_acChloroData = new List<XyPoint>();
|
||||
_ajChloroData = new List<XyPoint>();
|
||||
_atChloroData = new List<XyPoint>();
|
||||
_acInterData = new List<XyPoint>();
|
||||
_ajInterData = new List<XyPoint>();
|
||||
_atInterData = new List<XyPoint>();
|
||||
|
||||
while (!doneWithAnet)
|
||||
{
|
||||
@@ -58,9 +57,9 @@ namespace LeafWeb.Web.Charter
|
||||
return;
|
||||
}
|
||||
|
||||
phrases = splitCSVLine(line);
|
||||
phrases = SplitCsvLine(line);
|
||||
|
||||
firstField = (String) phrases[0];
|
||||
String firstField = phrases[0];
|
||||
if (firstField.Equals("CO2i"))
|
||||
{
|
||||
doneWithAnet = true;
|
||||
@@ -84,27 +83,27 @@ namespace LeafWeb.Web.Charter
|
||||
// 12 weitedrms
|
||||
// 13 PointLimitType
|
||||
|
||||
if (!curveIDSet)
|
||||
if (!curveIdSet)
|
||||
{
|
||||
curveID = firstField;
|
||||
curveIDSet = true;
|
||||
curveId = firstField;
|
||||
curveIdSet = true;
|
||||
}
|
||||
xyPoint1 = new XYPoint((String) phrases[9], (String) phrases[10]); // AnetMeas(y), PCO2c(x)
|
||||
xyPoint2 = new XYPoint((String) phrases[8], (String) phrases[10]); // AnetMeas(y), PCO2i(x)
|
||||
pointLimitType = Int32.Parse((String) phrases[13]);
|
||||
xyPoint1 = new XyPoint(phrases[9], phrases[10]); // AnetMeas(y), PCO2c(x)
|
||||
var xyPoint2 = new XyPoint(phrases[8], phrases[10]);
|
||||
var pointLimitType = Int32.Parse(phrases[13]);
|
||||
switch (pointLimitType)
|
||||
{
|
||||
case 1:
|
||||
anetMeasChloro1Data.Add(xyPoint1);
|
||||
anetMeasInter1Data.Add(xyPoint2);
|
||||
_anetMeasChloro1Data.Add(xyPoint1);
|
||||
_anetMeasInter1Data.Add(xyPoint2);
|
||||
break;
|
||||
case 2:
|
||||
anetMeasChloro2Data.Add(xyPoint1);
|
||||
anetMeasInter2Data.Add(xyPoint2);
|
||||
_anetMeasChloro2Data.Add(xyPoint1);
|
||||
_anetMeasInter2Data.Add(xyPoint2);
|
||||
break;
|
||||
case 3:
|
||||
anetMeasChloro3Data.Add(xyPoint1);
|
||||
anetMeasInter3Data.Add(xyPoint2);
|
||||
_anetMeasChloro3Data.Add(xyPoint1);
|
||||
_anetMeasInter3Data.Add(xyPoint2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -140,30 +139,28 @@ namespace LeafWeb.Web.Charter
|
||||
moreData = false;
|
||||
else
|
||||
{
|
||||
phrases = splitCSVLine(line);
|
||||
xyPoint1 = new XYPoint((String) phrases[1], (String) phrases[2]); // Ac(y),CO2cc(x)
|
||||
if (xyPoint1.yIsInRange(-20.0, 50.0))
|
||||
acChloroData.Add(xyPoint1);
|
||||
xyPoint1 = new XYPoint((String) phrases[3], (String) phrases[4]); // Aj(y),CO2cj(x)
|
||||
if (xyPoint1.yIsInRange(-20.0, 50.0))
|
||||
ajChloroData.Add(xyPoint1);
|
||||
xyPoint1 = new XYPoint((String) phrases[5], (String) phrases[6]); // At(y),CO2ct(x)
|
||||
if (xyPoint1.yIsInRange(-20.0, 50.0))
|
||||
atChloroData.Add(xyPoint1);
|
||||
phrases = SplitCsvLine(line);
|
||||
xyPoint1 = new XyPoint(phrases[1],phrases[2]); // Ac(y),CO2cc(x)
|
||||
if (xyPoint1.YIsInRange(-20.0, 50.0))
|
||||
_acChloroData.Add(xyPoint1);
|
||||
xyPoint1 = new XyPoint(phrases[3], phrases[4]); // Aj(y),CO2cj(x)
|
||||
if (xyPoint1.YIsInRange(-20.0, 50.0))
|
||||
_ajChloroData.Add(xyPoint1);
|
||||
xyPoint1 = new XyPoint(phrases[5], phrases[6]); // At(y),CO2ct(x)
|
||||
if (xyPoint1.YIsInRange(-20.0, 50.0))
|
||||
_atChloroData.Add(xyPoint1);
|
||||
|
||||
xyPoint1 = new XYPoint((String) phrases[0], (String) phrases[2]); // Ac(y),CO2i(x)
|
||||
if (xyPoint1.yIsInRange(-20.0, 50.0))
|
||||
acInterData.Add(xyPoint1);
|
||||
xyPoint1 = new XYPoint((String) phrases[0], (String) phrases[4]); // Aj(y),CO2i(x)
|
||||
if (xyPoint1.yIsInRange(-20.0, 50.0))
|
||||
ajInterData.Add(xyPoint1);
|
||||
xyPoint1 = new XYPoint((String) phrases[0], (String) phrases[6]); // At(y),CO2i(x)
|
||||
if (xyPoint1.yIsInRange(-20.0, 50.0))
|
||||
atInterData.Add(xyPoint1);
|
||||
xyPoint1 = new XyPoint(phrases[0], phrases[2]); // Ac(y),CO2i(x)
|
||||
if (xyPoint1.YIsInRange(-20.0, 50.0))
|
||||
_acInterData.Add(xyPoint1);
|
||||
xyPoint1 = new XyPoint(phrases[0], phrases[4]); // Aj(y),CO2i(x)
|
||||
if (xyPoint1.YIsInRange(-20.0, 50.0))
|
||||
_ajInterData.Add(xyPoint1);
|
||||
xyPoint1 = new XyPoint(phrases[0], phrases[6]); // At(y),CO2i(x)
|
||||
if (xyPoint1.YIsInRange(-20.0, 50.0))
|
||||
_atInterData.Add(xyPoint1);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -174,75 +171,68 @@ namespace LeafWeb.Web.Charter
|
||||
/// </summary>
|
||||
/// <param name="line"></param>
|
||||
/// <returns></returns>
|
||||
private ArrayList splitCSVLine(String line)
|
||||
private static List<string> SplitCsvLine(String line)
|
||||
{
|
||||
int i;
|
||||
char[] separator;
|
||||
separator = new char[3];
|
||||
separator[0] = ',';
|
||||
separator[1] = ' ';
|
||||
separator[2] = '\t';
|
||||
var separator = new [] {',', ' ', '\t'};
|
||||
var phrases = line.Split(separator);
|
||||
String phrase;
|
||||
|
||||
//int lastNonBlank = -1;
|
||||
var retPhrases = new ArrayList();
|
||||
var retPhrases = new List<string>();
|
||||
for (i = 0; i < phrases.Length; i++)
|
||||
{
|
||||
phrase = phrases[i].Trim();
|
||||
var phrase = phrases[i].Trim();
|
||||
if (phrase.Length > 0)
|
||||
// lastNonBlank = i;
|
||||
retPhrases.Add(phrase);
|
||||
}
|
||||
|
||||
//int firstBlankToRemove = lastNonBlank + 1;
|
||||
//if( firstBlankToRemove <= phrases.Length - 1 )
|
||||
// retPhrases.RemoveRange(firstBlankToRemove, phrases.Length - firstBlankToRemove);
|
||||
|
||||
return retPhrases;
|
||||
}
|
||||
|
||||
public ArrayList getAnetMeasData()
|
||||
public List<List<XyPoint>> GetAnetMeasData()
|
||||
{
|
||||
var list = new ArrayList();
|
||||
list.Add(anetMeasChloro1Data);
|
||||
list.Add(anetMeasChloro2Data);
|
||||
list.Add(anetMeasChloro3Data);
|
||||
list.Add(anetMeasInter1Data);
|
||||
list.Add(anetMeasInter2Data);
|
||||
list.Add(anetMeasInter3Data);
|
||||
var list = new List<List<XyPoint>>
|
||||
{
|
||||
_anetMeasChloro1Data,
|
||||
_anetMeasChloro2Data,
|
||||
_anetMeasChloro3Data,
|
||||
_anetMeasInter1Data,
|
||||
_anetMeasInter2Data,
|
||||
_anetMeasInter3Data
|
||||
};
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList getAcChloroData()
|
||||
public List<XyPoint> GetAcChloroData()
|
||||
{
|
||||
return acChloroData;
|
||||
return _acChloroData;
|
||||
}
|
||||
|
||||
public ArrayList getAjChloroData()
|
||||
public List<XyPoint> GetAjChloroData()
|
||||
{
|
||||
return ajChloroData;
|
||||
return _ajChloroData;
|
||||
}
|
||||
|
||||
public ArrayList getAtChloroData()
|
||||
public List<XyPoint> GetAtChloroData()
|
||||
{
|
||||
return atChloroData;
|
||||
return _atChloroData;
|
||||
}
|
||||
|
||||
public ArrayList getAcInterData()
|
||||
public List<XyPoint> GetAcInterData()
|
||||
{
|
||||
return acInterData;
|
||||
return _acInterData;
|
||||
}
|
||||
|
||||
public ArrayList getAjInterData()
|
||||
public List<XyPoint> GetAjInterData()
|
||||
{
|
||||
return ajInterData;
|
||||
return _ajInterData;
|
||||
}
|
||||
|
||||
public ArrayList getAtInterData()
|
||||
public List<XyPoint> GetAtInterData()
|
||||
{
|
||||
return atInterData;
|
||||
return _atInterData;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user