-
Notifications
You must be signed in to change notification settings - Fork 2
/
NodeControlInfo.cpp
85 lines (81 loc) · 2.4 KB
/
NodeControlInfo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "StdAfx.h"
#include "nodecontrolinfo.h"
#include "Common/Common.h"
//--------------------------------class CControlInfo------------------//
CNodeControlInfo::CControlInfo::CControlInfo(void)
{}
CNodeControlInfo::CControlInfo::~CControlInfo(void)
{}
CNodeControlInfo::CControlInfo::CControlInfo(int mainIndex,int mode,CString spectrometerID,CString cfgFilePath)
{
m_mainIndex = mainIndex;
m_mode = mode;
m_spectrometerID.Format("%s", spectrometerID);
m_cfgFilePath.Format("%s", cfgFilePath);
}
//---------------------------class CNodeControlInfo------------------//
CNodeControlInfo::CNodeControlInfo(void)
{
m_controlInfoArray.SetSize(1);
}
CNodeControlInfo::~CNodeControlInfo(void)
{
m_controlInfoArray.RemoveAll();
}
//fill the nodes' information
void CNodeControlInfo::FillinNodeInfo(int mainIndex,int mode, const CString spectrometerID,CString cfgFilePath)
{
m_controlInfoArray.SetAtGrow(mainIndex,
new CControlInfo(mainIndex, mode, spectrometerID, cfgFilePath));
}
//return the sum of nodes
int CNodeControlInfo::GetNodeSum()
{
return (int)m_controlInfoArray.GetCount();
}
//get node operating status
int CNodeControlInfo::GetNodeStatus(int mainIndex)
{
int status = RUN_MODE;
if(mainIndex < 0 || mainIndex >= m_controlInfoArray.GetSize()){
return status;
}else{
CControlInfo* controlInfo = m_controlInfoArray.GetAt(mainIndex);
status = controlInfo->m_mode;
return status;
}
}
//set node operating status
void CNodeControlInfo::SetNodeStatus(int mainIndex,int status, CString& filePath)
{
// Error Check!
if(mainIndex < 0 || mainIndex >= m_controlInfoArray.GetCount())
return; // <-- added 2007.09.11
CControlInfo* controlInfo = m_controlInfoArray.GetAt(mainIndex);
controlInfo->m_mode = status;
controlInfo->m_cfgFilePath = filePath;
m_controlInfoArray.SetAt(mainIndex,controlInfo);
}
void CNodeControlInfo::GetNodeCfgFilePath(int mainIndex,CString& filePath)
{
if(mainIndex < 0 || mainIndex >= m_controlInfoArray.GetSize()){
filePath.Format("");
return;
}else{
CControlInfo* controlInfo = m_controlInfoArray.GetAt(mainIndex);
filePath = controlInfo->m_cfgFilePath;
}
}
//get main index by spectrometer id
int CNodeControlInfo::GetMainIndex(CString spectrometerID)
{
int i;
CControlInfo* controlInfo;
for(i=0; i< m_controlInfoArray.GetCount(); i++)
{
controlInfo = m_controlInfoArray.GetAt(i);
if(Equals(controlInfo->m_spectrometerID, spectrometerID))
return i;
}
return -1;
}