WaterfallInfo에 따른 그래프 변경 함수 예제
2021. 10. 16. 18:13ㆍ프로그래밍
반응형
참고용
public bool AcquisitionBDTDatas(ushort unType, Dictionary<ushort, List<DataManagerUnit1.BDTWaterfallInfo>> dic, bool cType)
{
try
{
if (_infoBDT[unType - 1] == null) return false;
if (dic == null) return false;
DataManagerUnit1.BDTWaterfallInfo info = new DataManagerUnit1.BDTWaterfallInfo()
{
dt = _infoBDT[unType - 1].dt,
unLTWaterfallGram = _infoBDT[unType - 1].unLTWaterfallGram,
unSTWaterfallGram = _infoBDT[unType - 1].unSTWaterfallGram,
btrTime = _infoBDT[unType - 1].btrTime,
unBPStartFrequency = _infoBDT[unType - 1].unBPStartFrequency,
unBPEndFrequency = _infoBDT[unType - 1].unBPEndFrequency,
};
bool isChanged = false;
if (dic.ContainsKey(unType))
{
if (dic[unType].Count > 0)
{
DataManagerUnit1.BDTWaterfallInfo prevInfo = dic[unType][0];
if (!info.btrTime.Equals(prevInfo.btrTime))
{
if (dic[unType].Count(item => item.disp_dt && item.dt.ToString("HH:mm").Equals(info.dt.ToString("HH:mm"))) <= 0)
{
if (cType) _startCompareBDTDT[unType - 1] = null;
else _startMainBDTDT[unType - 1] = null;
}
isChanged = true;
}
if (!isChanged && (!info.unBPStartFrequency.Equals(prevInfo.unBPStartFrequency) || !info.unBPEndFrequency.Equals(prevInfo.unBPEndFrequency)))
isChanged = true;
}
}
else
{
dic.Add(unType, new List<DataManagerUnit1.BDTWaterfallInfo>());
}
info.changed = isChanged;
if (unType.Equals(5)) {
if (cType)
{
if (_startCompareBDTDT[unType - 1] == null) {
info.disp_dt = true;
_startCompareBDTDT[unType - 1] = info.dt;
}
else
{
TimeSpan ts = info.dt - _startCompareBDTDT[unType - 1].Value;
double minGap = info.btrTime / 5.0;
if (ts.TotalMinutes >= minGap)
{
info.disp_dt = true;
_startCompareBDTDT[unType - 1] = info.dt;
}
}
}
else
{
if (_startMainBDTDT[unType - 1] == null) {
info.disp_dt = true;
_startMainBDTDT[unType - 1] = info.dt;
}
else
{
TimeSpan ts = info.dt - _startMainBDTDT[unType - 1].Value;
double minGap = info.btrTime / 5.0;
if (ts.TotalMinutes >= minGap)
{
info.disp_dt = true;
_startMainBDTDT[unType - 1] = info.dt;
}
}
}
}
else
{
if (cType)
{
if (_startCompareBDTDT[unType - 1] == null) {
info.disp_dt = true;
_startCompareBDTDT[unType - 1] = info.dt;
}
else
{
TimeSpan ts = info.dt - _startCompareBDTDT[unType - 1].Value;
double minGap = info.btrTime / 5.0;
if (ts.TotalMinutes >= minGap)
{
info.disp_dt = true;
_startCompareBDTDT[unType - 1] = info.dt;
}
}
}
else
{
if (_startMainBDTDT[unType - 1] == null) {
info.disp_dt = true;
_startMainBDTDT[unType - 1] = info.dt;
}
else
{
TimeSpan ts = info.dt - _startMainBDTDT[unType - 1].Value;
double minGap = info.btrTime / 10.0;
if (ts.TotalMinutes >= minGap)
{
info.disp_dt = true;
_startMainBDTDT[unType - 1] = info.dt;
}
}
}
}
if (cType)
{
if (unType.Equals(1) || unType.Equals(3)) {
int index = unType.Equals(1) ? 0 : 1;
if (_startCompareCBDTDT[index] == null)
{
info.disp_cdt = true;
_startCompareCBDTDT[index] = info.dt;
}
else
{
TimeSpan ts = info.dt - _startCompareCBDTDT[index].Value;
double minGap = info.btrTime / 5.0;
if (ts.TotalMinutes >= minGap)
{
info.disp_cdt = true;
_startCompareCBDTDT[index] = info.dt;
}
}
}
}
else
{
if (unType.Equals(1) || unType.Equals(3)) {
int index = unType.Equals(1) ? 0 : 1;
if (_startMainCBDTDT[index] == null)
{
info.disp_cdt = true;
_startMainCBDTDT[index] = info.dt;
}
else
{
TimeSpan ts = info.dt - _startMainCBDTDT[index].Value;
double minGap = info.btrTime / 5.0;
if (ts.TotalMinutes >= minGap)
{
info.disp_cdt = true;
_startMainCBDTDT[index] = info.dt;
}
}
}
}
dic[unType].Insert(0, info);
if (dic[unType].Count > 1)
{
while ((dic[unType].First().dt - dic[unType].Last().dt).TotalHours >= 4)
{
if (dic[unType][dic[unType].Count - 1] != null) dic[unType][dic[unType].Count - 1].Dispose();
dic[unType].RemoveAt(dic[unType].Count - 1);
}
}
return true;
}
catch (Exception ee)
{
TraceManager.AddLog(string.Format("{0}r\n{1}", ee.StackTrace, ee.Message));
TraceManager.AddLog(string.Format("{0}", dic)); TraceManager.AddLog(string.Format("{0}", unType)); System.Diagnostics.Debug.WriteLine(string.Format("{0}r\n{1}", ee.StackTrace, ee.Message));
return false;
}
}
반응형
'프로그래밍' 카테고리의 다른 글
Degree 관련 각종 Convert 함수들 (4) | 2021.12.03 |
---|---|
ArrowLineBase 구조체 예제 (0) | 2021.11.03 |
타겟 추적 알고리즘 예제 소스 (0) | 2021.10.10 |
레이더 윈도우 리프레쉬 예제 소스 (0) | 2021.09.23 |
현 모드 체크 후 상황에 맞춰 업데이트 실행 예제 (0) | 2021.09.17 |