// DasWin32Doc.cpp : implementation of the CDasWin32Doc class // #include #include "stdafx.h" #include "DasWin32.h" #include "DasWin32Doc.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #include "dasinit.h" #include "commlib.h" ///////////////////////////////// // NOAA/ETL Global declarations extern CString TextOutString,PortOpenOutString,PortErrorOutString,StatsOutString, StatusOutString,DataOutString,BufferOutString,LastTimeOutString, NextTimeOutString; extern PORT *Port[MAX_PORTS]; extern int *ProcHandle,ProcIndex; extern struct DasComPortInfo Com; extern LPCTSTR CLParam; //Command Line Argument ///////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // CDasWin32Doc IMPLEMENT_DYNCREATE(CDasWin32Doc, CDocument) BEGIN_MESSAGE_MAP(CDasWin32Doc, CDocument) //{{AFX_MSG_MAP(CDasWin32Doc) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDasWin32Doc construction/destruction CDasWin32Doc::CDasWin32Doc() { // TODO: add one-time construction code here } CDasWin32Doc::~CDasWin32Doc() { } #include ////////////////////////////////////////////////////////////////////// // NOAA/ETL: remote data declarations and function prototypes... extern "C" struct DasComPortInfo ReadDasInitializationFile(char *); extern "C" void FreeMemory(char *,int *,int **); extern "C" int WriteToLog(char *,char *); ////////////////////////////////////////////////////////////////////// BOOL CDasWin32Doc::OnNewDocument() { char buf[MAX_STRING_LEN]; int i=0; if (!CDocument::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) StatusOutString=StatsOutString="Disabled"; PortOpenOutString=PortErrorOutString=DataOutString= BufferOutString=LastTimeOutString=NextTimeOutString="None"; ProcIndex++; ProcHandle=(int *)calloc(ProcIndex,sizeof(int)); Com=ReadDasInitializationFile("DasWin32.ini"); if(!Com.ErrorCode) { WriteToLog(Com.OutputDriveAndPath,"00 DasWin32 Startup - Settings acquired from DasWin32.ini and " "quality controlled successfully."); } else { WriteToLog(Com.OutputDriveAndPath,"01 DasWin32 Startup - Initialization error...program aborted."); sprintf(buf,"DasWin32 Initialization Error ... \n\n%s\n",Com.ErrorString); TextOutString=buf; if(Com.ErrorCode==-11) TextOutString+=" Please either make changes to DasWin32.ini and\\or\n" " check the drive\\path accessibility."; else TextOutString +="Please make changes to DasWin32.ini and restart DasWin32."; AfxMessageBox( TextOutString, MB_OK, 0 ); _spawnlp(_P_NOWAIT, "write.exe","write.exe","DasWin32.ini",NULL); if(Com.ErrorCode==-11) _spawnlp(_P_NOWAIT, "explorer.exe","explorer.exe",NULL); exit( - 1 ); return TRUE; } return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CDasWin32Doc serialization void CDasWin32Doc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } } ///////////////////////////////////////////////////////////////////////////// // CDasWin32Doc diagnostics #ifdef _DEBUG void CDasWin32Doc::AssertValid() const { CDocument::AssertValid(); } void CDasWin32Doc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CDasWin32Doc commands