void nwxXmlIOwxDateTime::UnitTest() { nwxXmlIOwxDateTime xx; wxString sTimeT("1230854460"); wxString sXML("2009-01-02T00:01:00"); wxString sTimeT2; wxString sXML2; wxDateTime dt; wxDateTime dtXML; dt = xx.FromString(sTimeT); dtXML = xx.FromString(sXML); sTimeT2 = xx.ToString((void *)&dt); xx.SetXML(true); sXML2 = xx.ToString((void *)&dtXML); if( (sTimeT != sTimeT2) || (sXML != sXML2) || (dt != dtXML) ) { wxString sMsg("nwxXmlIOwxDateTime::UnitTest failed\n"); sMsg.Append(nwxString::FormatDateTime(dt)); sMsg.Append("\n"); sMsg.Append(nwxString::FormatDateTime(dtXML)); wxASSERT_MSG(0,sMsg); } }
STDMETHODIMP CDataConnector::RequestModelFSerialComData(BSTR Id, BSTR ComPort, LONG* Handler) { HRESULT hr = E_OUTOFMEMORY; IXMLElementHandler* DataElementHandler = static_cast<IXMLElementHandler*>((IXMLElementHandler*)Handler); hr = RequestMockSensorsXML(Id, DataElementHandler, VARIANT_TRUE); if(FAILED(hr)) { try { CString sCommandHistory(_T("")); CString sXML(_T("")); int nComPort = -1; try { nComPort = boost::lexical_cast<int>(ComPort); } catch(boost::bad_lexical_cast&) { return E_OUTOFMEMORY; } CModelFHelper ModelFHelper; if(ModelFHelper.connectModelF(nComPort)) { ModelFHelper.poll(&sCommandHistory); sXML.Format(_T("<Sensatronics><BatteryStatus>%s</BatteryStatus><Group id=\"1\"><Probe id=\"1\"><Value>%s</Value></Probe><Probe id=\"2\"><Value>%s</Value></Probe></Group></Sensatronics>"), ModelFHelper.m_sBattery, ModelFHelper.m_sProbe1Temp, ModelFHelper.m_sProbe2Temp); ModelFHelper.disconnectModelF(); VARIANT varVal; VariantInit(&varVal); varVal.vt = VT_BSTR; varVal.bstrVal = CComBSTR(sXML).Copy(); hr = RequestXML(varVal, DataElementHandler); } else { return E_ACCESSDENIED; } } catch(...) { return E_OUTOFMEMORY; } } return hr; }