BOOL CGraphShowDlg::OnInitDialog() { CDialog::OnInitDialog(); if (m_uiADCFileLength > 0) { m_pSampleData = new double[m_uiADCFileLength]; } // 创建绘图控件并设置相关参数 CreateGraph(IDC_STATIC_GRAPHSHOW, &m_OScopeCtrl); // customize the control SetRange(DrawGraphYAxisLower, DrawGraphYAxisUpper, DecimalPlaces, &m_OScopeCtrl) ; SetYUnits(DrawGraphYAxisLabel, &m_OScopeCtrl) ; SetXUnits(DrawGraphXAxisLabel, &m_OScopeCtrl) ; SetBackgroundColor(DrawGraphSetBackgroundColor, &m_OScopeCtrl) ; SetGridColor(DrawGraphSetGridColor, &m_OScopeCtrl) ; SetPlotColor(DrawGraphSetPlotColor, &m_OScopeCtrl) ; m_Sec_GraphADCShow.Lock(); m_uiADCGraphDrowFromNb = (m_pADCDataRecThread->m_uiADCDataFrameCount[m_uiADCGraphNb - 1]) * ReceiveDataSize; m_Sec_GraphADCShow.Unlock(); if (m_uiADCGraphDrowFromNb > m_OScopeCtrl.m_uiXAxisPointNum) { m_OScopeCtrl.m_uiXAxisLabelMax = m_uiADCGraphDrowFromNb; } else { m_OScopeCtrl.m_uiXAxisLabelMax = m_OScopeCtrl.m_uiXAxisPointNum; } m_OScopeCtrl.m_uiXAxisLabelMin = m_OScopeCtrl.m_uiXAxisLabelMax - m_OScopeCtrl.m_uiXAxisPointNum; m_OScopeCtrl.Reset(false); m_OScopeCtrl.m_dPreviousPosition = 0.0; m_OScopeCtrl.m_uiPointNum = m_uiADCGraphDrowFromNb; // 绘制了的点的个数 // OnSetHScrollBarRange(); m_OScopeCtrl.m_bStopSample = m_bStopSample; m_Sec_GraphADCShow.Lock(); m_pADCDataRecThread->m_pOScopeCtrl[m_uiADCGraphNb - 1] = &m_OScopeCtrl; m_pADCDataRecThread->m_uiADCGraphIP[m_uiADCGraphNb - 1] = IPSetAddrStart + IPSetAddrInterval * m_uiADCGraphNb; m_Sec_GraphADCShow.Unlock(); return TRUE; // return TRUE unless you set the focus to a control }
BOOL CGraphShowDlg::OnInitDialog() { CDialog::OnInitDialog(); // 创建绘图控件并设置相关参数 CreateGraph(IDC_STATIC_GRAPHSHOW, &m_OScopeCtrl); // customize the control SetRange(-2.5, 2.5, DecimalPlaces, &m_OScopeCtrl) ; SetYUnits("Y", &m_OScopeCtrl) ; SetXUnits("X", &m_OScopeCtrl) ; SetBackgroundColor(RGB(0, 0, 64), &m_OScopeCtrl) ; SetGridColor(RGB(192, 192, 255), &m_OScopeCtrl) ; SetPlotColor(RGB(255, 255, 255), &m_OScopeCtrl) ; unsigned int uiLength = 0; m_Sec.Lock(); uiLength = m_ADCDataRecThread->m_uiADCDataFrameCount[m_uiADCGraphNb - 1] * ReceiveDataSize; m_Sec.Unlock(); if (uiLength > m_OScopeCtrl.m_uiXAxisPointNum) { m_OScopeCtrl.m_uiXAxisLabelMax = uiLength; } else { m_OScopeCtrl.m_uiXAxisLabelMax = m_OScopeCtrl.m_uiXAxisPointNum; } m_OScopeCtrl.m_uiXAxisLabelMin = m_OScopeCtrl.m_uiXAxisLabelMax - m_OScopeCtrl.m_uiXAxisPointNum; m_OScopeCtrl.Reset(false); m_OScopeCtrl.m_dPreviousPosition = 0.0; m_OScopeCtrl.m_uiPointNum = uiLength; // 绘制了的点的个数 m_dSampleData.reserve(1024); OnSetHScrollBarRange(); m_Sec.Lock(); m_ADCDataRecThread->m_uiADCGraphIP = 71 + 10 * m_uiADCGraphNb; m_Sec.Unlock(); m_OScopeCtrl.m_bStopSample = m_bStopSample; return TRUE; // return TRUE unless you set the focus to a control }
void QueryAttributes::SetFromNode(DataNode *parentNode) { if(parentNode == 0) return; DataNode *searchNode = parentNode->GetNode("QueryAttributes"); if(searchNode == 0) return; DataNode *node; if((node = searchNode->GetNode("resultsMessage")) != 0) SetResultsMessage(node->AsString()); if((node = searchNode->GetNode("resultsValue")) != 0) SetResultsValue(node->AsDoubleVector()); if((node = searchNode->GetNode("timeStep")) != 0) SetTimeStep(node->AsInt()); if((node = searchNode->GetNode("varTypes")) != 0) SetVarTypes(node->AsIntVector()); if((node = searchNode->GetNode("pipeIndex")) != 0) SetPipeIndex(node->AsInt()); if((node = searchNode->GetNode("xUnits")) != 0) SetXUnits(node->AsString()); if((node = searchNode->GetNode("yUnits")) != 0) SetYUnits(node->AsString()); if((node = searchNode->GetNode("floatFormat")) != 0) SetFloatFormat(node->AsString()); if((node = searchNode->GetNode("xmlResult")) != 0) SetXmlResult(node->AsString()); if((node = searchNode->GetNode("suppressOutput")) != 0) SetSuppressOutput(node->AsBool()); if((node = searchNode->GetNode("queryInputParams")) != 0) SetQueryInputParams(node->AsMapNode()); if((node = searchNode->GetNode("defaultName")) != 0) SetDefaultName(node->AsString()); if((node = searchNode->GetNode("defaultVars")) != 0) SetDefaultVars(node->AsStringVector()); }
void QueryAttributes::SetFromNode(DataNode *parentNode) { if(parentNode == 0) return; DataNode *searchNode = parentNode->GetNode("QueryAttributes"); if(searchNode == 0) return; DataNode *node; if((node = searchNode->GetNode("name")) != 0) SetName(node->AsString()); if((node = searchNode->GetNode("variables")) != 0) SetVariables(node->AsStringVector()); if((node = searchNode->GetNode("resultsMessage")) != 0) SetResultsMessage(node->AsString()); if((node = searchNode->GetNode("worldPoint")) != 0) SetWorldPoint(node->AsDoubleArray()); if((node = searchNode->GetNode("domain")) != 0) SetDomain(node->AsInt()); if((node = searchNode->GetNode("element")) != 0) SetElement(node->AsInt()); if((node = searchNode->GetNode("resultsValue")) != 0) SetResultsValue(node->AsDoubleVector()); if((node = searchNode->GetNode("elementType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 2) SetElementType(ElementType(ival)); } else if(node->GetNodeType() == STRING_NODE) { ElementType value; if(ElementType_FromString(node->AsString(), value)) SetElementType(value); } } if((node = searchNode->GetNode("timeStep")) != 0) SetTimeStep(node->AsInt()); if((node = searchNode->GetNode("varTypes")) != 0) SetVarTypes(node->AsIntVector()); if((node = searchNode->GetNode("dataType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 2) SetDataType(DataType(ival)); } else if(node->GetNodeType() == STRING_NODE) { DataType value; if(DataType_FromString(node->AsString(), value)) SetDataType(value); } } if((node = searchNode->GetNode("pipeIndex")) != 0) SetPipeIndex(node->AsInt()); if((node = searchNode->GetNode("useGlobalId")) != 0) SetUseGlobalId(node->AsBool()); if((node = searchNode->GetNode("xUnits")) != 0) SetXUnits(node->AsString()); if((node = searchNode->GetNode("yUnits")) != 0) SetYUnits(node->AsString()); if((node = searchNode->GetNode("darg1")) != 0) SetDarg1(node->AsDoubleVector()); if((node = searchNode->GetNode("darg2")) != 0) SetDarg2(node->AsDoubleVector()); if((node = searchNode->GetNode("floatFormat")) != 0) SetFloatFormat(node->AsString()); if((node = searchNode->GetNode("xmlResult")) != 0) SetXmlResult(node->AsString()); }
void CTabSample::OnInit(void) { m_iGraphViewId[0] = IDC_GRAPHSHOW1; m_iGraphViewId[1] = IDC_GRAPHSHOW2; m_iGraphViewId[2] = IDC_GRAPHSHOW3; m_iGraphViewId[3] = IDC_GRAPHSHOW4; for (int i=0; i<GraphViewNum;i++) { m_dSampleData[i].reserve(10240); } // 输入控件ID m_iMathId[0][0] = IDC_STATIC_AVERAGE1; m_iMathId[0][1] = IDC_STATIC_RMS1; m_iMathId[0][2] = IDC_STATIC_MAX1; m_iMathId[0][3] = IDC_STATIC_MIN1; m_iMathId[1][0] = IDC_STATIC_AVERAGE2; m_iMathId[1][1] = IDC_STATIC_RMS2; m_iMathId[1][2] = IDC_STATIC_MAX2; m_iMathId[1][3] = IDC_STATIC_MIN2; m_iMathId[2][0] = IDC_STATIC_AVERAGE3; m_iMathId[2][1] = IDC_STATIC_RMS3; m_iMathId[2][2] = IDC_STATIC_MAX3; m_iMathId[2][3] = IDC_STATIC_MIN3; m_iMathId[3][0] = IDC_STATIC_AVERAGE4; m_iMathId[3][1] = IDC_STATIC_RMS4; m_iMathId[3][2] = IDC_STATIC_MAX4; m_iMathId[3][3] = IDC_STATIC_MIN4; // 控件选择 for (int k=0; k<GraphViewNum; k++) { m_iSelectObject[k] = 0; m_iSelectObjectNoise[k] = 0; } m_cSelectObjectName[0] = _T("仪器一"); m_cSelectObjectName[1] = _T("仪器二"); m_cSelectObjectName[2] = _T("仪器三"); m_cSelectObjectName[3] = _T("仪器四"); // 得到当前路径 char cSaveToFilePath[MAX_PATH]; GetCurrentDirectory(MAX_PATH, cSaveToFilePath); m_csSaveFilePath = cSaveToFilePath; CScrollBar*pSB =(CScrollBar*)GetDlgItem(IDC_SCROLLBAR_GRAPHVIEW); pSB->SetScrollRange(m_uiScrollBarMin,m_uiScrollBarMax); // 创建绘图控件并设置相关参数 CreateGraph(GraphViewNum, m_iGraphViewId, m_OScopeCtrl); // customize the control SetRange(-2.5, 2.5, 1, GraphViewNum, m_OScopeCtrl) ; SetYUnits("Y", GraphViewNum, m_OScopeCtrl) ; SetXUnits("X", GraphViewNum, m_OScopeCtrl) ; SetBackgroundColor(RGB(0, 0, 64), GraphViewNum, m_OScopeCtrl) ; SetGridColor(RGB(192, 192, 255), GraphViewNum, m_OScopeCtrl) ; SetPlotColor(RGB(255, 255, 255), GraphViewNum, m_OScopeCtrl) ; // 得到本机IP地址 char name[255]; CString ip; PHOSTENT hostinfo; if( gethostname (name, sizeof(name)) == 0) { if((hostinfo = gethostbyname(name)) != NULL) { ip = inet_ntoa(*(struct in_addr*)*hostinfo-> h_addr_list); } } m_oThreadManage.m_HeadFrameSocket.m_csIPSource = ip; m_oThreadManage.m_TailFrameSocket.m_csIPSource = ip; m_oThreadManage.m_TailTimeFrameSocket.m_csIPSource = ip; m_oThreadManage.m_oSysTimeSocket.m_csIPSource = ip; m_oThreadManage.m_ADCDataSocket.m_csIPSource = ip; m_oThreadManage.m_oSysTimeSocket.m_pADCSet = &m_oADCSet; CString str; str.Format("0x%04x", 0x8202); GetDlgItem(IDC_EDIT_SENDPORT)->SetWindowText(str); str.Format("%d", 406); GetDlgItem(IDC_EDIT_ADCSAVEFRAMENB)->SetWindowText(str); m_iconDisconnected = AfxGetApp()->LoadIcon(IDI_ICON1); m_iconConnected = AfxGetApp()->LoadIcon(IDI_ICON2); m_oThreadManage.m_oInstrumentList.m_iconDisconnected = m_iconDisconnected; m_oThreadManage.m_oInstrumentList.m_pwnd = this; m_oThreadManage.m_IPSetSocket.m_iconConnected = m_iconConnected; m_oThreadManage.m_IPSetSocket.m_pwnd = this; // m_oThreadManage.m_ADCDataSocket.m_pwnd = this; m_oThreadManage.m_ADCDataSocket.m_pSelectObject = m_iSelectObject; m_oThreadManage.m_ADCDataSocket.m_pSelectObjectNoise = m_iSelectObjectNoise; for(int i=0; i<GraphViewNum; i++) { m_oThreadManage.m_ADCDataSocket.m_pSampleData[i] = &m_dSampleData[i]; m_oThreadManage.m_ADCDataSocket.m_pOScopeCtrl[i] = &m_OScopeCtrl[i]; m_oThreadManage.m_ADCDataSocket.m_cSelectObjectName[i] = m_cSelectObjectName[i]; } CStatic* icon; icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT1); icon->SetIcon(m_iconDisconnected); icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT2); icon->SetIcon(m_iconDisconnected); icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT3); icon->SetIcon(m_iconDisconnected); icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT4); icon->SetIcon(m_iconDisconnected); m_oThreadManage.OnInit(); OnOpen(); // 监测尾包定时器 SetTimer(4, 1000, NULL); }