diff --git a/CapServer/20051130220909421.jpg b/CapServer/20051130220909421.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220909421.jpg differ diff --git a/CapServer/20051130220911609.jpg b/CapServer/20051130220911609.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220911609.jpg differ diff --git a/CapServer/20051130220913750.jpg b/CapServer/20051130220913750.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220913750.jpg differ diff --git a/CapServer/20051130220915921.jpg b/CapServer/20051130220915921.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220915921.jpg differ diff --git a/CapServer/20051130220918187.jpg b/CapServer/20051130220918187.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220918187.jpg differ diff --git a/CapServer/20051130220920453.jpg b/CapServer/20051130220920453.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220920453.jpg differ diff --git a/CapServer/20051130220922703.jpg b/CapServer/20051130220922703.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220922703.jpg differ diff --git a/CapServer/20051130220924875.jpg b/CapServer/20051130220924875.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220924875.jpg differ diff --git a/CapServer/2005113022092715.jpg b/CapServer/2005113022092715.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/2005113022092715.jpg differ diff --git a/CapServer/20051130220929187.jpg b/CapServer/20051130220929187.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220929187.jpg differ diff --git a/CapServer/20051130220931453.jpg b/CapServer/20051130220931453.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220931453.jpg differ diff --git a/CapServer/20051130220933703.jpg b/CapServer/20051130220933703.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220933703.jpg differ diff --git a/CapServer/20051130220935968.jpg b/CapServer/20051130220935968.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220935968.jpg differ diff --git a/CapServer/20051130220938156.jpg b/CapServer/20051130220938156.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220938156.jpg differ diff --git a/CapServer/20051130220940296.jpg b/CapServer/20051130220940296.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220940296.jpg differ diff --git a/CapServer/20051130220942468.jpg b/CapServer/20051130220942468.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220942468.jpg differ diff --git a/CapServer/20051130220944734.jpg b/CapServer/20051130220944734.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130220944734.jpg differ diff --git a/CapServer/20051130221457468.jpg b/CapServer/20051130221457468.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221457468.jpg differ diff --git a/CapServer/20051130221459734.jpg b/CapServer/20051130221459734.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221459734.jpg differ diff --git a/CapServer/20051130221501984.jpg b/CapServer/20051130221501984.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221501984.jpg differ diff --git a/CapServer/20051130221504156.jpg b/CapServer/20051130221504156.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221504156.jpg differ diff --git a/CapServer/20051130221506296.jpg b/CapServer/20051130221506296.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221506296.jpg differ diff --git a/CapServer/20051130221508484.jpg b/CapServer/20051130221508484.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221508484.jpg differ diff --git a/CapServer/20051130221510734.jpg b/CapServer/20051130221510734.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221510734.jpg differ diff --git a/CapServer/20051130221512984.jpg b/CapServer/20051130221512984.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221512984.jpg differ diff --git a/CapServer/20051130221515156.jpg b/CapServer/20051130221515156.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221515156.jpg differ diff --git a/CapServer/20051130221517296.jpg b/CapServer/20051130221517296.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221517296.jpg differ diff --git a/CapServer/20051130221519468.jpg b/CapServer/20051130221519468.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221519468.jpg differ diff --git a/CapServer/20051130221521750.jpg b/CapServer/20051130221521750.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221521750.jpg differ diff --git a/CapServer/2005113022152415.jpg b/CapServer/2005113022152415.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/2005113022152415.jpg differ diff --git a/CapServer/20051130221526250.jpg b/CapServer/20051130221526250.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221526250.jpg differ diff --git a/CapServer/20051130221528421.jpg b/CapServer/20051130221528421.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221528421.jpg differ diff --git a/CapServer/20051130221530578.jpg b/CapServer/20051130221530578.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221530578.jpg differ diff --git a/CapServer/20051130221532765.jpg b/CapServer/20051130221532765.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221532765.jpg differ diff --git a/CapServer/2005113022153515.jpg b/CapServer/2005113022153515.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/2005113022153515.jpg differ diff --git a/CapServer/20051130221537390.jpg b/CapServer/20051130221537390.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221537390.jpg differ diff --git a/CapServer/20051130221539531.jpg b/CapServer/20051130221539531.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221539531.jpg differ diff --git a/CapServer/20051130221541703.jpg b/CapServer/20051130221541703.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221541703.jpg differ diff --git a/CapServer/20051130221543843.jpg b/CapServer/20051130221543843.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221543843.jpg differ diff --git a/CapServer/2005113022154631.jpg b/CapServer/2005113022154631.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/2005113022154631.jpg differ diff --git a/CapServer/20051130221548265.jpg b/CapServer/20051130221548265.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221548265.jpg differ diff --git a/CapServer/20051130221550437.jpg b/CapServer/20051130221550437.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130221550437.jpg differ diff --git a/CapServer/20051130222002343.bmp b/CapServer/20051130222002343.bmp new file mode 100644 index 0000000..3b36403 Binary files /dev/null and b/CapServer/20051130222002343.bmp differ diff --git a/CapServer/20051130222445656.bmp b/CapServer/20051130222445656.bmp new file mode 100644 index 0000000..3b36403 Binary files /dev/null and b/CapServer/20051130222445656.bmp differ diff --git a/CapServer/20051130223038812tmp.jpg b/CapServer/20051130223038812tmp.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130223038812tmp.jpg differ diff --git a/CapServer/20051130224123468tmp.jpg b/CapServer/20051130224123468tmp.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130224123468tmp.jpg differ diff --git a/CapServer/20051130224729375.jpg b/CapServer/20051130224729375.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130224729375.jpg differ diff --git a/CapServer/20051130224729453.bmp b/CapServer/20051130224729453.bmp new file mode 100644 index 0000000..3b36403 Binary files /dev/null and b/CapServer/20051130224729453.bmp differ diff --git a/CapServer/20051130225022656.jpg b/CapServer/20051130225022656.jpg new file mode 100644 index 0000000..c95b8d7 Binary files /dev/null and b/CapServer/20051130225022656.jpg differ diff --git a/CapServer/CapServer.aps b/CapServer/CapServer.aps new file mode 100644 index 0000000..e3318c7 Binary files /dev/null and b/CapServer/CapServer.aps differ diff --git a/CapServer/CapServer.dsp b/CapServer/CapServer.dsp new file mode 100644 index 0000000..be83abd --- /dev/null +++ b/CapServer/CapServer.dsp @@ -0,0 +1,133 @@ +# Microsoft Developer Studio Project File - Name="CapServer" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=CapServer - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "CapServer.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "CapServer.mak" CFG="CapServer - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "CapServer - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "CapServer - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "CapServer - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "CapServer - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /Gz /MTd /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "STRICT" /D "__FLAT__" /D "_COMMON_USENLS_" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib winmm.lib vfw32.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "CapServer - Win32 Release" +# Name "CapServer - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\gensrv.cpp +# End Source File +# Begin Source File + +SOURCE=.\Main.cpp +# End Source File +# Begin Source File + +SOURCE=.\MainApplication.cpp +# End Source File +# Begin Source File + +SOURCE=.\MonitorThread.cpp +# End Source File +# Begin Source File + +SOURCE=.\Params.cpp +# End Source File +# Begin Source File + +SOURCE=.\SocketHeader.cpp +# End Source File +# Begin Source File + +SOURCE=.\SocketServer.cpp +# End Source File +# Begin Source File + +SOURCE=.\WDMCap.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\CapServer.rc +# End Source File +# End Group +# End Target +# End Project diff --git a/CapServer/CapServer.dsw b/CapServer/CapServer.dsw new file mode 100644 index 0000000..e2efabe --- /dev/null +++ b/CapServer/CapServer.dsw @@ -0,0 +1,134 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "CapServer"=.\CapServer.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name bsptree + End Project Dependency + Begin Project Dependency + Project_Dep_Name codec + End Project Dependency + Begin Project Dependency + Project_Dep_Name common + End Project Dependency + Begin Project Dependency + Project_Dep_Name jpeg6b + End Project Dependency + Begin Project Dependency + Project_Dep_Name socket + End Project Dependency + Begin Project Dependency + Project_Dep_Name vidcaplib + End Project Dependency + Begin Project Dependency + Project_Dep_Name thread + End Project Dependency +}}} + +############################################################################### + +Project: "bsptree"=..\bsptree\bsptree.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "codec"=..\codec\codec.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "common"=..\common\common.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "jpeg6b"="..\..\parts\jpeg-6b\jpeg6b.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "socket"=..\socket\socket.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "thread"=..\thread\thread.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "vidcaplib"=..\vidcap\vidcaplib.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/CapServer/CapServer.h b/CapServer/CapServer.h new file mode 100644 index 0000000..cfef402 --- /dev/null +++ b/CapServer/CapServer.h @@ -0,0 +1,4 @@ +#ifndef _CAPSEVER_CAPSERVER_H_ +#define _CAPSEVER_CAPSERVER_H_ + +#endif diff --git a/CapServer/CapServer.ncb b/CapServer/CapServer.ncb new file mode 100644 index 0000000..a145cc4 Binary files /dev/null and b/CapServer/CapServer.ncb differ diff --git a/CapServer/CapServer.opt b/CapServer/CapServer.opt new file mode 100644 index 0000000..e9a3a88 Binary files /dev/null and b/CapServer/CapServer.opt differ diff --git a/CapServer/CapServer.plg b/CapServer/CapServer.plg new file mode 100644 index 0000000..8f444a2 --- /dev/null +++ b/CapServer/CapServer.plg @@ -0,0 +1,55 @@ + + +
+

Build Log

+

+--------------------Configuration: vidcaplib - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\sean\LOCALS~1\Temp\RSP251.tmp" with contents +[ +/nologo /Gz /MTd /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "STRICT" /D "__FLAT__" /Fp"debug/vidcaplib.pch" /YX /Fo"debug/" /Fd"debug/" /FD /GZ /c +"D:\work\vidcap\BMPCAP.CPP" +] +Creating command line "cl.exe @C:\DOCUME~1\sean\LOCALS~1\Temp\RSP251.tmp" +Creating command line "link.exe -lib /nologo /out:"debug\vidcaplib.lib" .\debug\BMPCAP.OBJ .\debug\VIDCAP.OBJ .\debug\VidReg.obj " +

Output Window

+Compiling... +BMPCAP.CPP +Creating library... +

+--------------------Configuration: CapServer - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\sean\LOCALS~1\Temp\RSP252.tmp" with contents +[ +kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib winmm.lib vfw32.lib wsock32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/CapServer.pdb" /debug /machine:I386 /out:"Debug/CapServer.exe" /pdbtype:sept +.\Debug\gensrv.obj +.\Debug\Main.obj +.\Debug\MainApplication.obj +.\Debug\MonitorThread.obj +.\Debug\Params.obj +.\Debug\SocketHeader.obj +.\Debug\SocketServer.obj +.\Debug\WDMCap.obj +.\Debug\CapServer.res +\work\exe\msbsp.lib +\work\codec\Debug\codec.lib +\work\exe\mscommon.lib +"\parts\jpeg-6b\lib\jpeg6b.lib" +\work\exe\mssocket.lib +\work\vidcap\debug\vidcaplib.lib +\work\exe\msthread.lib +] +Creating command line "link.exe @C:\DOCUME~1\sean\LOCALS~1\Temp\RSP252.tmp" +

Output Window

+Linking... + Creating library Debug/CapServer.lib and object Debug/CapServer.exp + + + +

Results

+CapServer.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/CapServer/CapServer.rc b/CapServer/CapServer.rc new file mode 100644 index 0000000..5f26b51 --- /dev/null +++ b/CapServer/CapServer.rc @@ -0,0 +1,2 @@ +#include + diff --git a/CapServer/Debug/CapServer.exe b/CapServer/Debug/CapServer.exe new file mode 100644 index 0000000..dc6f1c2 Binary files /dev/null and b/CapServer/Debug/CapServer.exe differ diff --git a/CapServer/Debug/CapServer.exp b/CapServer/Debug/CapServer.exp new file mode 100644 index 0000000..5c6fc09 Binary files /dev/null and b/CapServer/Debug/CapServer.exp differ diff --git a/CapServer/Debug/CapServer.ilk b/CapServer/Debug/CapServer.ilk new file mode 100644 index 0000000..8f967b7 Binary files /dev/null and b/CapServer/Debug/CapServer.ilk differ diff --git a/CapServer/Debug/CapServer.lib b/CapServer/Debug/CapServer.lib new file mode 100644 index 0000000..55a7eca Binary files /dev/null and b/CapServer/Debug/CapServer.lib differ diff --git a/CapServer/Debug/CapServer.pdb b/CapServer/Debug/CapServer.pdb new file mode 100644 index 0000000..dfb7cf8 Binary files /dev/null and b/CapServer/Debug/CapServer.pdb differ diff --git a/CapServer/Debug/CapServer.res b/CapServer/Debug/CapServer.res new file mode 100644 index 0000000..36f26e2 Binary files /dev/null and b/CapServer/Debug/CapServer.res differ diff --git a/CapServer/Debug/Main.obj b/CapServer/Debug/Main.obj new file mode 100644 index 0000000..9335a0b Binary files /dev/null and b/CapServer/Debug/Main.obj differ diff --git a/CapServer/Debug/MainApplication.obj b/CapServer/Debug/MainApplication.obj new file mode 100644 index 0000000..719153f Binary files /dev/null and b/CapServer/Debug/MainApplication.obj differ diff --git a/CapServer/Debug/MonitorThread.obj b/CapServer/Debug/MonitorThread.obj new file mode 100644 index 0000000..c1f6937 Binary files /dev/null and b/CapServer/Debug/MonitorThread.obj differ diff --git a/CapServer/Debug/Params.obj b/CapServer/Debug/Params.obj new file mode 100644 index 0000000..b08ad74 Binary files /dev/null and b/CapServer/Debug/Params.obj differ diff --git a/CapServer/Debug/SocketHeader.obj b/CapServer/Debug/SocketHeader.obj new file mode 100644 index 0000000..bbf3437 Binary files /dev/null and b/CapServer/Debug/SocketHeader.obj differ diff --git a/CapServer/Debug/SocketServer.obj b/CapServer/Debug/SocketServer.obj new file mode 100644 index 0000000..8c247fa Binary files /dev/null and b/CapServer/Debug/SocketServer.obj differ diff --git a/CapServer/Debug/WDMCap.obj b/CapServer/Debug/WDMCap.obj new file mode 100644 index 0000000..07409c9 Binary files /dev/null and b/CapServer/Debug/WDMCap.obj differ diff --git a/CapServer/Debug/gensrv.obj b/CapServer/Debug/gensrv.obj new file mode 100644 index 0000000..909b123 Binary files /dev/null and b/CapServer/Debug/gensrv.obj differ diff --git a/CapServer/Debug/image.jpg b/CapServer/Debug/image.jpg new file mode 100644 index 0000000..2018a1d Binary files /dev/null and b/CapServer/Debug/image.jpg differ diff --git a/CapServer/Debug/read.bat b/CapServer/Debug/read.bat new file mode 100644 index 0000000..ee66a79 --- /dev/null +++ b/CapServer/Debug/read.bat @@ -0,0 +1,3 @@ +:loop +capserver client +goto loop diff --git a/CapServer/Debug/vc60.idb b/CapServer/Debug/vc60.idb new file mode 100644 index 0000000..0afab62 Binary files /dev/null and b/CapServer/Debug/vc60.idb differ diff --git a/CapServer/Debug/vc60.pdb b/CapServer/Debug/vc60.pdb new file mode 100644 index 0000000..4e725e3 Binary files /dev/null and b/CapServer/Debug/vc60.pdb differ diff --git a/CapServer/Main.cpp b/CapServer/Main.cpp new file mode 100644 index 0000000..6e1babc --- /dev/null +++ b/CapServer/Main.cpp @@ -0,0 +1,25 @@ +#include +#include +#include + +int handlerRoutine(DWORD ctrlType); + +bool running=true; + +MainApplication mainApplication; + +void main(int argc,char **argv) +{ + mainApplication.run(argc,argv); +} + +int handlerRoutine(DWORD eventType) // this is connected ad-hoc to generic server, could be cleaner +{ + if(CTRL_C_EVENT==eventType) + { + ::printf("Caught Ctrl-C...\n"); + running=false; + return true; + } + return false; +} diff --git a/CapServer/MainApplication.cpp b/CapServer/MainApplication.cpp new file mode 100644 index 0000000..d7e795b --- /dev/null +++ b/CapServer/MainApplication.cpp @@ -0,0 +1,125 @@ +#include + +MainApplication::MainApplication() +{ +} + +MainApplication::~MainApplication() +{ +} + +int MainApplication::run(int argc,char **argv) +{ + String command; + + mParams.setArgs(argc,argv); + switch(mParams.getRequest()) + { + case Params::Client : + mParams.showParams(); + handleClient(mParams.getServer(),mParams.getPort().toInt()); + break; + case Params::Server : + mParams.showParams(); + handleServer(mParams.getHost(),mParams.getPort().toInt(),mParams.getTimeout().toInt(),mParams.getDevice().toInt(),mParams.getRetain(),mParams.getDebug(),mParams.getShowSrcDlg()); + break; + case Params::Settings : + mParams.showParams(); + handleSettings(mParams.getShowSrcDlg()); + break; + case Params::None : + displayUsage(); + break; + } + return 0; +} + +void MainApplication::handleServer(const String &host,int port,int timeout,int deviceIndex,bool retain,bool debug,bool showSrcDlg) +{ + message("[MainApplication::handleServer]starting server"); + SocketServer socketServer(host,port,deviceIndex,retain,debug,showSrcDlg,timeout); + socketServer.listen(host,port); +} + +void MainApplication::handleClient(const String &host,int port) +{ + INETSocketAddress internetSocketAddress; + InternetAddress internetAddress(127,0,0,1); + Socket socket; + SocketHeader socketHeader; + Array content; + + message("[MainApplication::handleClient]starting client"); + internetSocketAddress.family(PF_INET); + internetSocketAddress.port(1024); + internetSocketAddress.internetAddress(internetAddress); + if(!socket.create()) + { + message("[MainApplication::handleClient]create failed..."); + return; + } + if(!socket.connect(internetSocketAddress)) + { + message("[MainApplication::handleClient]connect failed..."); + return; + } + message("[MainApplication::handleClient]reading socket header..."); + socketHeader.unmarshall(socket); + message("[MainApplication::handleClient]header length",socketHeader.getSizeHeader()); + message("[MainApplication::handleClient]version",socketHeader.getVersion()); + message("[MainApplication::handleClient]content length",socketHeader.getContentLength()); + message("[MainApplication::handleClient]content type",(int)socketHeader.getContentType()); + content.size(socketHeader.getContentLength()); + message("[MainApplication::handleClient]reading content..."); + socket.receive((char*)&content[0],content.size()); + message("[MainApplication::handleClient]done..."); + socket.destroy(); +} + +void MainApplication::handleSettings(bool showSrcDlg) +{ + VidReg vidReg; + Block driverInfoBlock; + + VidCap::getDrivers(driverInfoBlock); + message("[MainApplication::handleSettings]Capture File",vidReg.getCaptureFile()); + message("[MainApplication::handleSettings]Sequencing",vidReg.getSequencing()?"true":"false"); + message("[MainApplication::handleSettings]Preview Rate",vidReg.getPreviewRate()); + message("[MainApplication::handleSettings]Preview Width",vidReg.getPreviewWidth()); + message("[MainApplication::handleSettings]Preview Height",vidReg.getPreviewHeight()); + message("[MainApplication::handleSettings]Capture Width",vidReg.getCaptureWidth()); + message("[MainApplication::handleSettings]Capture Height",vidReg.getCaptureHeight()); + message("[MainApplication::handleSettings]Capture Quality",vidReg.getQuality()); + message("[MainApplication::handleSettings]***********CAPTURE DEVICE LIST*********"); + if(!driverInfoBlock.size())message("[MainApplication::handleSettings]No capture devices on system."); + for(int index=0;index | "); + message(" host= | "); + message(" port="); + message(" device="); + message(" retain={true} | {false}"); + message(" debug={true} | {false}"); + message(" showsrcdlg={true} | {false}"); + message(" timeout= (Delay between frame grab for retain mode. (ms))"); + message(" "); + message(" CapServer run=server host=127.0.0.1 port=1024"); + message(" CapServer run=server host=127.0.0.1 port=1024 device=0"); + message(" CapServer run=client server=127.0.0.1 port=1024"); + message(" CapServer run=settings"); +} + diff --git a/CapServer/MainApplication.hpp b/CapServer/MainApplication.hpp new file mode 100644 index 0000000..1022e91 --- /dev/null +++ b/CapServer/MainApplication.hpp @@ -0,0 +1,55 @@ +#ifndef _CAPSERVER_MAINAPPLICATION_HPP_ +#define _CAPSERVER_MAINAPPLICATION_HPP_ +#ifndef _CAPSERVER_SOCKET_HEADER_HPP_ +#include +#endif +#ifndef _SOCKET_WSADATA_HPP_ +#include +#endif +#ifndef _CAPSERVER_SOCKETSERVER_HPP_ +#include +#endif +#ifndef _CAPSERVER_PARAMS_HPP_ +#include +#endif +#ifndef _VIDCAP_VIDREG_HPP_ +#include +#endif + +class MainApplication +{ +public: + MainApplication(); + virtual ~MainApplication(); + int run(int argc,char **argv); +private: + void message(const String &message); + void message(const String &message,int arg); + void message(const String &message,const String &arg); + void handleServer(const String &host,int port,int timeout,int deviceIndex,bool retain,bool debug,bool showSrcDlg); + void handleClient(const String &server,int port); + void handleSettings(bool showSrcDlg); + void displayUsage(void); + + WSASystem mWSASystem; + Params mParams; +}; + +inline +void MainApplication::message(const String &message) +{ + printf("%s\n",message.str()); +} + +inline +void MainApplication::message(const String &message,int arg) +{ + printf("%s=%d\n",message.str(),arg); +} + +inline +void MainApplication::message(const String &message,const String &arg) +{ + printf("%s=%s\n",message.str(),arg.str()); +} +#endif diff --git a/CapServer/MonitorThread.cpp b/CapServer/MonitorThread.cpp new file mode 100644 index 0000000..2703abf --- /dev/null +++ b/CapServer/MonitorThread.cpp @@ -0,0 +1,161 @@ +#include +#include +#include +#include +#include +#include +#include + +MonitorThread::MonitorThread() +: mIsRunning(false), mTimeout(DefaultTimeout) +{ + mCallback.setCallback(this,&MonitorThread::threadCallback); + insertHandler(&mCallback); +} + +MonitorThread::~MonitorThread() +{ + stop(); + removeHandler(&mCallback); +} + +void MonitorThread::startMonitor(const String &host,int port,DWORD timeout) +{ + message("MonitorThread::startMonitor"); + ThreadMessage threadMessage(ThreadMessage::TM_USER,MsgMonitorStart); + mHost=host; + mPort=port; + mTimeout=timeout; + getHostAddress(); + postMessage(threadMessage); +} + +void MonitorThread::stopMonitor(void) +{ + message("MonitorThread::startMonitor"); + ThreadMessage threadMessage(ThreadMessage::TM_USER,MsgMonitorStop); + postMessage(threadMessage); + mMonitorEvent.waitEvent(); +} + +DWORD MonitorThread::threadCallback(ThreadMessage &threadMessage) +{ + switch(threadMessage.message()) + { + case ThreadMessage::TM_CREATE : + break; + case ThreadMessage::TM_DESTROY : + break; + case ThreadMessage::TM_USER : + switch(MonitorThMsg(threadMessage.userDataOne())) + { + case MsgMonitorStart : + handleMonitorStart(); + break; + case MsgMonitorStop : + handleMonitorStop(); + break; + } + break; + } + return 0; +} + +void MonitorThread::handleMonitorStart() +{ + DWORD elapsedTime; + message("[MonitorThread::handleMonitorStart]ENTER"); + mIsRunning=true; + message(String("[MonitorThread::handleMonitorStart]InitDelay=")+String().fromInt(InitDelay)+String(" (ms).")); + ::Sleep(InitDelay); + while(mIsRunning) + { + elapsedTime=::GetTickCount(); + getImage(); + elapsedTime=::GetTickCount()-elapsedTime; + message("[MonitorThread::handleMonitorStart]GetImage Took "+String().fromInt(elapsedTime)+String(" (ms).")); + ::Sleep(mTimeout); + } + message("]MonitorThread::handleMonitorStart]LEAVE"); +} + +void MonitorThread::handleMonitorStop() +{ + message("[MonitorThread::handleMonitorStop]ENTER"); + message("[MonitorThread::handleMonitorStop]LEAVE"); + mIsRunning=false; +} + +void MonitorThread::getHostAddress() +{ + Block internetAddresses; + HostEnt hostEnt; + + hostEnt.hostByName(mHost); + internetAddresses=hostEnt.addresses(); + if(!internetAddresses.size())return; + for(int index=0;index")+internetAddresses[0].toString()); + } + mInternetAddress=internetAddresses[0]; +} + +void MonitorThread::getImage() +{ + INETSocketAddress internetSocketAddress; + Socket socket; + SocketHeader socketHeader; + Array content; + + message("[MonitorThread::getImage]starting client"); + internetSocketAddress.family(PF_INET); + internetSocketAddress.port(mPort); + internetSocketAddress.internetAddress(mInternetAddress); + if(!socket.create()) + { + message("[MonitorThread::getImage]create socket failed..."); + return; + } + if(!socket.connect(internetSocketAddress)) + { + message(String("[MonitorThread::getImage]connect to '")+internetSocketAddress.toString()+String("' failed...")); + return; + } + message("[MonitorThread::getImage]reading socket header..."); + socketHeader.unmarshall(socket); + message("[MonitorThread::getImage]header length",socketHeader.getSizeHeader()); + message("[MonitorThread::getImage]version",socketHeader.getVersion()); + message("[MonitorThread::getImage]content length",socketHeader.getContentLength()); + message("[MonitorThread::getImage]content type",(int)socketHeader.getContentType()); + content.size(socketHeader.getContentLength()); + message("[MonitorThread::getImage]reading content..."); + socket.receive((char*)&content[0],content.size()); + saveImage(content); + message("[MonitorThread::getImage]done..."); + socket.destroy(); +} + +bool MonitorThread::saveImage(Array &imageData) +{ + SystemTime systemTime; + String strPathImageFile; + FileHandle openFile; + + if(!imageData.size())return message("[MonitorThread::saveImage] No Data"),false; + strPathImageFile.reserve(1024); + ::sprintf(strPathImageFile,"%04d%02d%02d%02d%02d%02d%02d.jpg", + systemTime.year(),systemTime.month(),systemTime.day(), + systemTime.hour(),systemTime.minute(),systemTime.second(), + systemTime.milliseconds()); + if(!openFile.open(strPathImageFile,FileHandle::Write,FileHandle::ShareRead,FileHandle::Overwrite)) + { + message(String("[MonitorThread::saveImage]Open '")+strPathImageFile+String("' for write Failed.")); + return false; + } + openFile.write(&imageData[0],imageData.size()); + openFile.close(); + return true; +} + + diff --git a/CapServer/MonitorThread.hpp b/CapServer/MonitorThread.hpp new file mode 100644 index 0000000..293be97 --- /dev/null +++ b/CapServer/MonitorThread.hpp @@ -0,0 +1,50 @@ +#ifndef _CAPSERVER_MONITORTHREAD_HPP_ +#define _CAPSERVER_MONITORTHREAD_HPP_ +#ifndef _SOCKET_SOCKET_HPP_ +#include +#endif +#ifndef _THREAD_MESSAGETHREAD_HPP_ +#include +#endif + +class MonitorThread : private MessageThread +{ +public: + MonitorThread(); + virtual ~MonitorThread(); + void startMonitor(const String &host,int port,DWORD timeout); + void stopMonitor(void); +private: + typedef enum MonitorThMsg{MsgMonitorStart,MsgMonitorStop}; + enum{DefaultTimeout=1000,InitDelay=0}; // InitDelay=10000 + DWORD threadCallback(ThreadMessage &threadMessage); + void handleMonitorStart(void); + void handleMonitorStop(void); + void message(const String &string); + void message(const String &string,int value); + void getHostAddress(void); + void getImage(void); + bool saveImage(Array &imageData); + + ThreadCallback mCallback; + InternetAddress mInternetAddress; + Event mMonitorEvent; + bool mIsRunning; + String mHost; + int mPort; + DWORD mTimeout; +}; + +inline +void MonitorThread::message(const String &string) +{ + ::printf("%s\n",string.str()); +} + +inline +void MonitorThread::message(const String &string,int value) +{ + ::printf("%s=%d\n",string.str(),value); +} +#endif + diff --git a/CapServer/NameValuePair.hpp b/CapServer/NameValuePair.hpp new file mode 100644 index 0000000..86a5650 --- /dev/null +++ b/CapServer/NameValuePair.hpp @@ -0,0 +1,72 @@ +#ifndef _CAPSERVER_NAMEVALUE_HPP_ +#define _CAPSERVER_NAMEVALUE_HPP_ +#ifndef _COMMON_STRING_HPP_ +#include +#endif + +class NameValuePair +{ +public: + NameValuePair(); + NameValuePair(const String &name,const String &value); + const String &getName(void)const; + void setName(const String &name); + const String &getValue(void)const; + void setValue(const String &value); + bool fromString(const String &string); + String toString(void)const; +private: + String mName; + String mValue; +}; + +inline +NameValuePair::NameValuePair() +{ +} + +inline +NameValuePair::NameValuePair(const String &name,const String &value) +: mName(name), mValue(value) +{ +} + +inline +const String &NameValuePair::getName(void)const +{ + return mName; +} + +inline +void NameValuePair::setName(const String &name) +{ + mName=name; +} + +inline +const String &NameValuePair::getValue(void)const +{ + return mValue; +} + +inline +void NameValuePair::setValue(const String &value) +{ + mValue=value; +} + +inline +bool NameValuePair::fromString(const String &string) +{ + if(string.isNull())return false; + mName=string.betweenString(0,'='); + mValue=string.betweenString('=',0); + return true; +} + +inline +String NameValuePair::toString(void)const +{ + return mName+String("=")+mValue; +} +#endif diff --git a/CapServer/Params.cpp b/CapServer/Params.cpp new file mode 100644 index 0000000..b02afa6 --- /dev/null +++ b/CapServer/Params.cpp @@ -0,0 +1,86 @@ +#include +#include + +void Params::setArgs(int argc,char **argv) +{ + String strArg; + getParams(argc,argv); + if(getServer().isNull())setServer("127.0.0.1"); + if(getHost().isNull())setHost("127.0.0.1"); + if(getPort().isNull())setPort("1024"); + if(getTimeout().isNull())setTimeout("1000"); + if(getDevice().isNull())setDevice("0"); + strArg=getValue(mRetainKey); + strArg.lower(); + if(!(strArg==String("true")) && !(strArg==String("false")))setRetain(false); + else if(strArg==String("true"))setRetain(true); + else setRetain(false); + strArg=getValue(mDebugKey); + strArg.lower(); + if(!(strArg==String("true")) && !(strArg==String("false")))setDebug(false); + else if(strArg==String("true"))setDebug(true); + else setDebug(false); + strArg=getValue(mShowSrcDlgKey); + strArg.lower(); + if(!(strArg==String("true")) && !(strArg==String("false")))setShowSrcDlg(false); + else if(strArg==String("true"))setShowSrcDlg(true); + else setShowSrcDlg(false); +} + +int Params::getParams(int argc,char**argv) +{ + mNameValuePairs.remove(); + for(int index=0;index +#endif +#ifndef _CAPSERVER_NAMEVALUE_HPP_ +#include +#endif + +class Params +{ +public: + typedef enum Request{Server,Client,Settings,None}; + Params(int argc,char **argv); + Params(); + virtual ~Params(); + Request getRequest(void)const; + String getServer(void)const; + String getHost(void)const; + String getPort(void)const; + String getDevice(void)const; + bool getRetain(void)const; + bool getDebug(void)const; + String getTimeout(void)const; + bool getShowSrcDlg(void)const; + void setArgs(int argc,char **argv); + void showParams(void); +private: + int getParams(int argc,char **argv); + String getValue(const String &key)const; + void setValue(const String &key,const String &value); + String getRun(void)const; + void setServer(const String &server); + void setHost(const String &host); + void setPort(const String &port); + void setDevice(const String &device); + void setRetain(bool retain); + void setDebug(bool debug); + void setTimeout(const String &timeout); + void setShowSrcDlg(bool showSrcDlg); + + Block mNameValuePairs; + String mRunKey; + String mServerKey; + String mHostKey; + String mPortKey; + String mDeviceKey; + String mRetainKey; + String mDebugKey; + String mShowSrcDlgKey; + String mTimeoutKey; +}; + +inline +Params::Params(int argc,char **argv) +: mRunKey("run"), mServerKey("server"), mHostKey("host"), mPortKey("port"), mDeviceKey("device"), + mRetainKey("retain"), mDebugKey("debug"), mShowSrcDlgKey("showsrcdlg"), mTimeoutKey("timeout") +{ + getParams(argc,argv); +} + +inline +Params::Params() +: mRunKey("run"), mServerKey("server"), mHostKey("host"), mPortKey("port"), mDeviceKey("device"), + mRetainKey("retain"), mDebugKey("debug"), mShowSrcDlgKey("showsrcdlg"), mTimeoutKey("timeout") +{ +} + +inline +Params::~Params() +{ +} + +inline +String Params::getRun(void)const +{ + return getValue(mRunKey); +} + +inline +String Params::getServer(void)const +{ + return getValue(mServerKey); +} + +inline +String Params::getHost(void)const +{ + return getValue(mHostKey); +} + +inline +String Params::getPort(void)const +{ + return getValue(mPortKey); +} + +inline +String Params::getDevice(void)const +{ + return getValue(mDeviceKey); +} + +inline +bool Params::getRetain(void)const +{ + String strRetain(getValue(mRetainKey)); + if(strRetain=="true")return true; + return false; +} + +inline +bool Params::getDebug(void)const +{ + String strDebug(getValue(mDebugKey)); + if(strDebug=="true")return true; + return false; +} + +inline +bool Params::getShowSrcDlg(void)const +{ + String strValue(getValue(mShowSrcDlgKey)); + if(strValue=="true")return true; + return false; +} + +inline +void Params::setServer(const String &server) +{ + setValue(mServerKey,server); +} + +inline +void Params::setHost(const String &host) +{ + setValue(mHostKey,host); +} + +inline +void Params::setPort(const String &port) +{ + setValue(mPortKey,port); +} + +inline +void Params::setDevice(const String &device) +{ + setValue(mDeviceKey,device); +} + +inline +void Params::setRetain(bool retain) +{ + if(retain)setValue(mRetainKey,"true"); + else setValue(mRetainKey,"false"); +} + +inline +void Params::setDebug(bool debug) +{ + if(debug)setValue(mDebugKey,"true"); + else setValue(mDebugKey,"false"); +} + +inline +void Params::setShowSrcDlg(bool showSrcDlg) +{ + if(showSrcDlg)setValue(mShowSrcDlgKey,"true"); + else setValue(mShowSrcDlgKey,"false"); +} + +inline +String Params::getTimeout(void)const +{ + return getValue(mTimeoutKey); +} + +inline +void Params::setTimeout(const String &timeout) +{ + setValue(mTimeoutKey,timeout); +} +#endif diff --git a/CapServer/SocketHeader.cpp b/CapServer/SocketHeader.cpp new file mode 100644 index 0000000..f487ab4 --- /dev/null +++ b/CapServer/SocketHeader.cpp @@ -0,0 +1,64 @@ +#include + +SocketHeader::SocketHeader() +: mSizeHeader(sizeof(mSizeHeader)+sizeof(mVersion)+sizeof(mContentLength)+sizeof(mContentType)), + mVersion(0), mContentLength(0), mContentType(Unknown) +{ +} + +SocketHeader::~SocketHeader() +{ +} + +int SocketHeader::getSizeHeader(void)const +{ + return mSizeHeader; +} + +int SocketHeader::getVersion(void)const +{ + return mVersion; +} + +void SocketHeader::setVersion(int version) +{ + mVersion=version; +} + +int SocketHeader::getContentLength(void)const +{ + return mContentLength; +} + +void SocketHeader::setContentLength(int contentLength) +{ + mContentLength=contentLength; +} + +SocketHeader::ContentType SocketHeader::getContentType(void)const +{ + return (ContentType)mContentType; +} + +void SocketHeader::setContentType(int contentType) +{ + mContentType=(ContentType)contentType; +} + +bool SocketHeader::marshall(Socket &socket) +{ + if(!socket.send((char*)&mSizeHeader,sizeof(int)))return false; + if(!socket.send((char*)&mVersion,sizeof(int)))return false; + if(!socket.send((char*)&mContentLength,sizeof(int)))return false; + if(!socket.send((char*)&mContentType,sizeof(int)))return false; + return true; +} + +bool SocketHeader::unmarshall(Socket &socket) +{ + if(!socket.receive((char*)&mSizeHeader,sizeof(int)))return false; + if(!socket.receive((char*)&mVersion,sizeof(int)))return false; + if(!socket.receive((char*)&mContentLength,sizeof(int)))return false; + if(!socket.receive((char*)&mContentType,sizeof(int)))return false; + return true; +} \ No newline at end of file diff --git a/CapServer/SocketHeader.hpp b/CapServer/SocketHeader.hpp new file mode 100644 index 0000000..cf9dd25 --- /dev/null +++ b/CapServer/SocketHeader.hpp @@ -0,0 +1,31 @@ +#ifndef _CAPSERVER_SOCKET_HEADER_HPP_ +#define _CAPSERVER_SOCKET_HEADER_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _SOCKET_SOCKET_HPP_ +#include +#endif + +class SocketHeader +{ +public: + typedef enum ContentType{Unknown,ImageJPG}; + SocketHeader(); + virtual ~SocketHeader(); + int getSizeHeader(void)const; + int getVersion(void)const; + void setVersion(int version); + int getContentLength(void)const; + void setContentLength(int contentLength); + ContentType getContentType(void)const; + void setContentType(int contentType); + bool marshall(Socket &socket); + bool unmarshall(Socket &socket); +private: + int mSizeHeader; + int mVersion; + int mContentLength; + int mContentType; +}; +#endif \ No newline at end of file diff --git a/CapServer/SocketServer.cpp b/CapServer/SocketServer.cpp new file mode 100644 index 0000000..7ce1bc8 --- /dev/null +++ b/CapServer/SocketServer.cpp @@ -0,0 +1,105 @@ +#include +#include +#include +#include +#include + +SocketServer::SocketServer(const String &host,int port,int deviceIndex,bool retain,bool debug,bool showSrcDlg,int timeout) +: mWDMCap(deviceIndex), mDebug(debug) +{ + if(showSrcDlg)mWDMCap.dialogVideoSource(); + if(retain)mMonitorThread.startMonitor(host,port,timeout); +} + +SocketServer::~SocketServer() +{ + mMonitorThread.stopMonitor(); +} + +void SocketServer::acceptHandler(SmartPointer &socketControl) +{ + if(mDebug)sendDebugFrame(*socketControl); + else sendFrame(*socketControl); + +} + +void SocketServer::message(const String &string) +{ + ::printf("%s\n",string.str()); +} + +void SocketServer::sendFrame(Socket &socketControl) +{ + DiskInfo diskInfo; + SystemTime systemTime; + String strPathCaptureFile; + SocketHeader socketHeader; + Array charBytes; + FileHandle openFile; + DWORD elapsedTime; + + socketHeader.setVersion(1); + socketHeader.setContentType(SocketHeader::ImageJPG); + socketHeader.setContentLength(0); + strPathCaptureFile.reserve(1024); + ::sprintf(strPathCaptureFile,"%04d%02d%02d%02d%02d%02d%02d.jpg", + systemTime.year(),systemTime.month(),systemTime.day(), + systemTime.hour(),systemTime.minute(),systemTime.second(), + systemTime.milliseconds()); + elapsedTime=::GetTickCount(); + mWDMCap.setCaptureFileName(strPathCaptureFile); + mWDMCap.grabFrameNoStop(); + elapsedTime=::GetTickCount()-elapsedTime; + message(String("[SocketServer::sendFrame] Grab frame took ")+String().fromInt(elapsedTime)+String(" (ms)")); + if(!openFile.open(strPathCaptureFile,FileHandle::Read,FileHandle::ShareRead)) + { + socketHeader.marshall(socketControl); + } + else + { + charBytes.size(openFile.size()); + socketHeader.setContentLength(charBytes.size()); + elapsedTime=::GetTickCount(); + openFile.read((BYTE*)&charBytes[0],charBytes.size()); + elapsedTime=::GetTickCount()-elapsedTime; + message(String("[SocketServer::sendFrame] Read ")+String().fromInt(charBytes.size())+String(" bytes took ")+String().fromInt(elapsedTime)+String(" (ms)")); + elapsedTime=::GetTickCount(); + socketHeader.marshall(socketControl); + socketControl.send((char*)&charBytes[0],charBytes.size()); + elapsedTime=::GetTickCount()-elapsedTime; + message(String("[SocketServer::sendFrame] Send ")+String().fromInt(charBytes.size())+String(" bytes took ")+String().fromInt(elapsedTime)+String(" (ms)")); + openFile.close(); + diskInfo.unlink(strPathCaptureFile); + } + message(String("[SocketServer::sendFrame]Sent ")+String().fromInt(charBytes.size())+String(" bytes")); + return; +} + +void SocketServer::sendDebugFrame(Socket &socketControl) +{ + DiskInfo diskInfo; + Array charBytes; + FileHandle openFile; + SocketHeader socketHeader; + String strPathFileName; + + strPathFileName="./image.jpg"; + socketHeader.setVersion(1); + socketHeader.setContentType(SocketHeader::ImageJPG); + socketHeader.setContentLength(0); + if(!openFile.open(strPathFileName,FileHandle::Read,FileHandle::ShareRead)) + { + message("[SocketServer::sendDebugFrame] 'image.jpg' was not found, sending empty content"); + socketHeader.marshall(socketControl); + } + else + { + charBytes.size(openFile.size()); + socketHeader.setContentLength(charBytes.size()); + openFile.read((BYTE*)&charBytes[0],charBytes.size()); + socketHeader.marshall(socketControl); + socketControl.send((char*)&charBytes[0],charBytes.size()); + message(String("[SocketServer::sendDebugFrame] Send ")+String().fromInt(charBytes.size())); + openFile.close(); + } +} diff --git a/CapServer/SocketServer.hpp b/CapServer/SocketServer.hpp new file mode 100644 index 0000000..b26c01c --- /dev/null +++ b/CapServer/SocketServer.hpp @@ -0,0 +1,36 @@ +#ifndef _CAPSERVER_SOCKETSERVER_HPP_ +#define _CAPSERVER_SOCKETSERVER_HPP_ +#ifndef _COMMON_BLOCK_HPP_ +#include +#endif +#ifndef _THREAD_MONITOR_HPP_ +#include +#endif +#ifndef _CAPSERVER_WDMCAP_HPP_ +#include +#endif +#ifndef _CAPSERVER_GENERICSERVER_HPP_ +#include +#endif +#ifndef _CAPSERVER_MONITORTHREAD_HPP_ +#include +#endif + +class SocketServer : public GenericServer +{ +public: + SocketServer(const String &host,int port,int deviceIndex=0,bool retain=false,bool debug=false,bool showSrcDlg=false,int timeout=1000); + virtual ~SocketServer(); +protected: + virtual void acceptHandler(SmartPointer &socketControl); + virtual void message(const String &message); +private: + void sendFrame(Socket &socketControl); + void sendDebugFrame(Socket &socketControl); + + MonitorThread mMonitorThread; + WDMCap mWDMCap; + VidCap mVidCap; + bool mDebug; +}; +#endif diff --git a/CapServer/WDMCap.cpp b/CapServer/WDMCap.cpp new file mode 100644 index 0000000..cca61f0 --- /dev/null +++ b/CapServer/WDMCap.cpp @@ -0,0 +1,101 @@ +#include +#include + +WDMCap::WDMCap(int deviceIndex) +: mDriverIndex(deviceIndex) +{ + initialize(); +} + +WDMCap::~WDMCap() +{ +} + +void WDMCap::setCaptureFileName(const String &strPathCaptureFile) +{ + BmpCap::setCaptureFileName(strPathCaptureFile); +} + +const String &WDMCap::getCaptureFileName(void)const +{ + return BmpCap::getCaptureFileName(); +} + +bool WDMCap::initialize(void) +{ + String pathOutputFileName="capture.jpg"; + VidReg vidReg; + + vidReg.setCaptureFile(pathOutputFileName); + vidReg.setSequencing(false); + VidCap::getDrivers(mDriverInfoBlock); + if(!mDriverInfoBlock.size()) + { + message("No drivers found! drivercount",mDriverInfoBlock.size()); + return false; + } + if(mDriverIndex>=mDriverInfoBlock.size()) + { + message("[WDMCap::initilialize]Driver not found! device",mDriverIndex); + return false; + } + showSettings(); + mControl=::new Control(); + mControl.disposition(PointerDisposition::Delete); + mControl->createControl("BUTTON","",0,Rect(0,0,vidReg.getCaptureWidth(),vidReg.getCaptureHeight()),::GetDesktopWindow(),ControlID); + BmpCap::initialize(mControl->getHandle(),mDriverIndex); + if(!connect(mDriverIndex)) + { + ::printf("\007"); + message("[WDMCap::initilialize]Failed to connect to device",mDriverInfoBlock[mDriverIndex].driverName()); + return false; + } + saveFrames(true); + return isConnected(); +} + +void WDMCap::showSettings(void) +{ + VidReg vidReg; + + message("[WDMCap::initilialize]Capture File",vidReg.getCaptureFile()); + message("[WDMCap::initilialize]Sequencing",vidReg.getSequencing()?"true":"false"); + message("[WDMCap::initilialize]Preview Rate",vidReg.getPreviewRate()); + message("[WDMCap::initilialize]Preview Width",vidReg.getPreviewWidth()); + message("[WDMCap::initilialize]Preview Height",vidReg.getPreviewHeight()); + message("[WDMCap::initilialize]Capture Width",vidReg.getCaptureWidth()); + message("[WDMCap::initilialize]Capture Height",vidReg.getCaptureHeight()); + message("[WDMCap::initilialize]Capture Quality",vidReg.getQuality()); + for(int index=0;index +#endif +#ifndef _COMMON_BLOCK_HPP_ +#include +#endif +#ifndef _COMMON_CONTROL_HPP_ +#include +#endif +#ifndef _THREAD_EVENT_HPP_ +#include +#endif +#ifndef _VIDCAP_BMPCAP_HPP_ +#include +#endif + +class WDMCap : private BmpCap +{ +public: + WDMCap(int deviceIndex=0); + virtual ~WDMCap(); + bool grabFrame(void); + bool grabFrameNoStop(void); + bool dialogVideoSource(void); + bool isConnected(void)const; + bool getDriverCaps(DriverCaps &someDriverCaps); + bool getCaptureParams(CaptureParams &someCaptureParams); + void setCaptureFileName(const String &strPathCaptureFile); + const String &getCaptureFileName(void)const; +protected: + virtual void frameHandler(VIDEOHDR &videoHeader); +private: + enum{ControlID=100}; + bool initialize(void); + void showSettings(void); + void message(const String &message); + void message(const String &message,const String &arg); + void message(const String &message,int arg); + + SmartPointer mControl; + Block mDriverInfoBlock; + Event mFrameEvent; + DWORD mDriverIndex; + DWORD mGrabTime; +}; + +inline +bool WDMCap::dialogVideoSource(void) +{ + return BmpCap::dialogVideoSource(); +} + +inline +bool WDMCap::isConnected(void)const +{ + return BmpCap::isConnected(); +} + +inline +bool WDMCap::getDriverCaps(DriverCaps &someDriverCaps) +{ + return BmpCap::getDriverCaps(someDriverCaps); +} + +inline +bool WDMCap::getCaptureParams(CaptureParams &someCaptureParams) +{ + return BmpCap::getCaptureParams(someCaptureParams); +} + +inline +void WDMCap::message(const String &message,int arg) +{ + ::printf("%s=%d\n",message.str(),arg); +} + +inline +void WDMCap::message(const String &message,const String &arg) +{ + ::printf("%s=%s\n",message.str(),arg.str()); +} + +inline +void WDMCap::message(const String &message) +{ + ::printf("%s\n",message.str()); +} +#endif diff --git a/CapServer/gensrv.cpp b/CapServer/gensrv.cpp new file mode 100644 index 0000000..3e5f028 --- /dev/null +++ b/CapServer/gensrv.cpp @@ -0,0 +1,96 @@ +#include +#include +#include + +extern bool running; + +GenericServer::GenericServer(void) +: mIsRunning(TRUE) +{ +} + +GenericServer::~GenericServer() +{ + message("[GenericServer::~GenericServer]Server is destructing..."); +} + +void GenericServer::close(void) +{ + mIsRunning=FALSE; +} + +WORD GenericServer::listen(const String &hostName,short portNum) +{ + HostEnt hostEntry; + ServEnt serverEntry; + String stringData; + SystemTime systemTime; + DWORD elapsedTime; + + message(String("[GenericServer::listen]trying host'")+hostName+String("'...")); + if(!mWSASystem.isInitialized()){message("[GenericServer::listen]WINSOCK initialization failure.");return FALSE;} + InternetAddress internetAddress(hostName); + if(!internetAddress.isZero()){if(!hostEntry.hostByAddress(internetAddress)){message(String("[GenericServer::listen]no DNS entry for ")+hostName);return FALSE;}} + else if(!hostEntry.hostByName(hostName)){message(String("[GenericServer::listen]no DNS entry for ")+hostName);return FALSE;} + message(String("[GenericServer::listen]connect...")+String("'")+hostEntry.hostName()+String("' (")+(String)(hostEntry.addresses())[0]+String(")")); + mInternetSocketAddress.internetAddress((hostEntry.addresses())[0]); + mInternetSocketAddress.family(PF_INET); + mInternetSocketAddress.port(portNum); + if(!mGenericControl.create()){message("[GenericServer::listen]socket initialization failure.");return FALSE;} + mGenericControl.reuseAddress(); + if(!mGenericControl.bind(mInternetSocketAddress)){message("[GenericServer::listen]bind failed");return FALSE;} + while(mIsRunning&&running) + { + SmartPointer socketControl; + socketControl=::new Socket(); +// socketControl.disposition(PointerDisposition::Assume); + socketControl.disposition(PointerDisposition::Delete); + INETSocketAddress internetSocketAddress; + message(String("[GenericServer::listen]host='")+(hostEntry.addresses())[0]+String("' port=")+String().fromInt(portNum)); + String strLocalHost((String)mInternetSocketAddress.internetAddress()); + message(String("[GenericServer::listen]local address is ")+strLocalHost); + if(!mGenericControl.listen()){message("[GenericServer::listen]listen failed");return FALSE;} + message("[GenericServer::listen]waiting for connection..."); + if(!mGenericControl.accept(*socketControl,internetSocketAddress)){message("[GenericServer::listen]accept returned FALSE;");return FALSE;} + +// socketControl->setLinger(0); +// socketControl->bind(internetSocketAddress); + + systemTime.refresh(); + message(String("[GenericServer::listen]service started from ")+internetSocketAddress.internetAddress().toString()+String(" on ")+systemTime.toString()); + elapsedTime=::GetTickCount(); + acceptHandler(socketControl); + socketControl->destroy(); + socketControl.destroy(); + elapsedTime=::GetTickCount()-elapsedTime; + message(String("[GenericServer::listen]service took ")+String().fromInt(elapsedTime)+String("(ms)")); + } + mGenericControl.destroy(); + message("[GenericServer::listen]terminating connection"); + return TRUE; +} + +// virtuals + +void GenericServer::message(const String &message) +{ + ::OutputDebugString(message+String("\n")); +} + +void GenericServer::message(Block &msgData) +{ + for(int msgIndex=0;msgIndex &socket) +{ + SmartPointer socketControl; + + socketControl=socket; + socketControl.disposition(PointerDisposition::Delete); + String acceptString("[GenericServer::acceptHandler]200 GenericServer::acceptHandler accepting connection."); + socketControl->send(acceptString); + message(acceptString); + return; +} + diff --git a/CapServer/gensrv.hpp b/CapServer/gensrv.hpp new file mode 100644 index 0000000..7e94a03 --- /dev/null +++ b/CapServer/gensrv.hpp @@ -0,0 +1,42 @@ +#ifndef _CAPSERVER_GENERICSERVER_HPP_ +#define _CAPSERVER_GENERICSERVER_HPP_ +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif +#ifndef _SOCKET_HOSTENT_HPP_ +#include +#endif +#ifndef _SOCKET_SERVENT_HPP_ +#include +#endif +#ifndef _SOCKET_INETSOCKETADDRESS_HPP_ +#include +#endif +#ifndef _SOCKET_SOCKET_HPP_ +#include +#endif + +class GenericServer +{ +public: + GenericServer(void); + virtual ~GenericServer(); + WORD listen(const String &hostName,short portNum); + WORD receive(char &charData,BOOL waitForData=TRUE); + void close(void); +protected: + virtual void acceptHandler(SmartPointer &socketControl); + virtual void message(const String &message); + virtual void message(Block &msgData); +private: + enum{TimeOut=1000}; + INETSocketAddress mInternetSocketAddress; + Socket mGenericControl; + WSASystem mWSASystem; + BOOL mIsRunning; +}; + +#endif \ No newline at end of file diff --git a/CapServer/hold/Main.cpp b/CapServer/hold/Main.cpp new file mode 100644 index 0000000..6e1babc --- /dev/null +++ b/CapServer/hold/Main.cpp @@ -0,0 +1,25 @@ +#include +#include +#include + +int handlerRoutine(DWORD ctrlType); + +bool running=true; + +MainApplication mainApplication; + +void main(int argc,char **argv) +{ + mainApplication.run(argc,argv); +} + +int handlerRoutine(DWORD eventType) // this is connected ad-hoc to generic server, could be cleaner +{ + if(CTRL_C_EVENT==eventType) + { + ::printf("Caught Ctrl-C...\n"); + running=false; + return true; + } + return false; +} diff --git a/CapServer/hold/MainApplication.cpp b/CapServer/hold/MainApplication.cpp new file mode 100644 index 0000000..163ac11 --- /dev/null +++ b/CapServer/hold/MainApplication.cpp @@ -0,0 +1,124 @@ +#include + +MainApplication::MainApplication() +{ +} + +MainApplication::~MainApplication() +{ +} + +int MainApplication::run(int argc,char **argv) +{ + String command; + + mParams.setArgs(argc,argv); + switch(mParams.getRequest()) + { + case Params::Client : + mParams.showParams(); + handleClient(mParams.getServer(),mParams.getPort().toInt()); + break; + case Params::Server : + mParams.showParams(); + handleServer(mParams.getHost(),mParams.getPort().toInt(),mParams.getDevice().toInt(),mParams.getRetain(),mParams.getDebug(),mParams.getShowSrcDlg()); + break; + case Params::Settings : + mParams.showParams(); + handleSettings(mParams.getShowSrcDlg()); + break; + case Params::None : + displayUsage(); + break; + } + return 0; +} + +void MainApplication::handleServer(const String &host,int port,int deviceIndex,bool retain,bool debug,bool showSrcDlg) +{ + message("[MainApplication::handleServer]starting server"); + SocketServer socketServer(deviceIndex,retain,debug,showSrcDlg); + socketServer.listen(host,port); +} + +void MainApplication::handleClient(const String &host,int port) +{ + INETSocketAddress internetSocketAddress; + InternetAddress internetAddress(127,0,0,1); + Socket socket; + SocketHeader socketHeader; + Array content; + + message("[MainApplication::handleClient]starting client"); + internetSocketAddress.family(PF_INET); + internetSocketAddress.port(1024); + internetSocketAddress.internetAddress(internetAddress); + if(!socket.create()) + { + message("[MainApplication::handleClient]create failed..."); + return; + } + if(!socket.connect(internetSocketAddress)) + { + message("[MainApplication::handleClient]connect failed..."); + return; + } + message("[MainApplication::handleClient]reading socket header..."); + socketHeader.unmarshall(socket); + message("[MainApplication::handleClient]header length",socketHeader.getSizeHeader()); + message("[MainApplication::handleClient]version",socketHeader.getVersion()); + message("[MainApplication::handleClient]content length",socketHeader.getContentLength()); + message("[MainApplication::handleClient]content type",(int)socketHeader.getContentType()); + content.size(socketHeader.getContentLength()); + message("[MainApplication::handleClient]reading content..."); + socket.receive((char*)&content[0],content.size()); + message("[MainApplication::handleClient]done..."); + socket.destroy(); +} + +void MainApplication::handleSettings(bool showSrcDlg) +{ + VidReg vidReg; + Block driverInfoBlock; + + VidCap::getDrivers(driverInfoBlock); + message("[MainApplication::handleSettings]Capture File",vidReg.getCaptureFile()); + message("[MainApplication::handleSettings]Sequencing",vidReg.getSequencing()?"true":"false"); + message("[MainApplication::handleSettings]Preview Rate",vidReg.getPreviewRate()); + message("[MainApplication::handleSettings]Preview Width",vidReg.getPreviewWidth()); + message("[MainApplication::handleSettings]Preview Height",vidReg.getPreviewHeight()); + message("[MainApplication::handleSettings]Capture Width",vidReg.getCaptureWidth()); + message("[MainApplication::handleSettings]Capture Height",vidReg.getCaptureHeight()); + message("[MainApplication::handleSettings]Capture Quality",vidReg.getQuality()); + message("[MainApplication::handleSettings]***********CAPTURE DEVICE LIST*********"); + if(!driverInfoBlock.size())message("[MainApplication::handleSettings]No capture devices on system."); + for(int index=0;index | "); + message(" host= | "); + message(" port="); + message(" device="); + message(" retain={true} | {false}"); + message(" debug={true} | {false}"); + message(" showsrcdlg={true} | {false}"); + message(" "); + message(" CapServer run=server host=127.0.0.1 port=1024"); + message(" CapServer run=server host=127.0.0.1 port=1024 device=0"); + message(" CapServer run=client server=127.0.0.1 port=1024"); + message(" CapServer run=settings"); +} + diff --git a/CapServer/hold/MainApplication.hpp b/CapServer/hold/MainApplication.hpp new file mode 100644 index 0000000..d010e02 --- /dev/null +++ b/CapServer/hold/MainApplication.hpp @@ -0,0 +1,55 @@ +#ifndef _CAPSERVER_MAINAPPLICATION_HPP_ +#define _CAPSERVER_MAINAPPLICATION_HPP_ +#ifndef _CAPSERVER_SOCKET_HEADER_HPP_ +#include +#endif +#ifndef _SOCKET_WSADATA_HPP_ +#include +#endif +#ifndef _CAPSERVER_SOCKETSERVER_HPP_ +#include +#endif +#ifndef _CAPSERVER_PARAMS_HPP_ +#include +#endif +#ifndef _VIDCAP_VIDREG_HPP_ +#include +#endif + +class MainApplication +{ +public: + MainApplication(); + virtual ~MainApplication(); + int run(int argc,char **argv); +private: + void message(const String &message); + void message(const String &message,int arg); + void message(const String &message,const String &arg); + void handleServer(const String &host,int port,int deviceIndex,bool retain,bool debug,bool showSrcDlg); + void handleClient(const String &server,int port); + void handleSettings(bool showSrcDlg); + void displayUsage(void); + + WSASystem mWSASystem; + Params mParams; +}; + +inline +void MainApplication::message(const String &message) +{ + printf("%s\n",message.str()); +} + +inline +void MainApplication::message(const String &message,int arg) +{ + printf("%s=%d\n",message.str(),arg); +} + +inline +void MainApplication::message(const String &message,const String &arg) +{ + printf("%s=%s\n",message.str(),arg.str()); +} +#endif diff --git a/CapServer/hold/NameValuePair.hpp b/CapServer/hold/NameValuePair.hpp new file mode 100644 index 0000000..480917b --- /dev/null +++ b/CapServer/hold/NameValuePair.hpp @@ -0,0 +1,65 @@ +#ifndef _CAPSERVER_NAMEVALUE_HPP_ +#define _CAPSERVER_NAMEVALUE_HPP_ +#ifndef _COMMON_STRING_HPP_ +#include +#endif + +class NameValuePair +{ +public: + NameValuePair(); + NameValuePair(const String &name,const String &value); + const String &getName(void)const; + void setName(const String &name); + const String &getValue(void)const; + void setValue(const String &value); + bool fromString(const String &string); +private: + String mName; + String mValue; +}; + +inline +NameValuePair::NameValuePair() +{ +} + +inline +NameValuePair::NameValuePair(const String &name,const String &value) +: mName(name), mValue(value) +{ +} + +inline +const String &NameValuePair::getName(void)const +{ + return mName; +} + +inline +void NameValuePair::setName(const String &name) +{ + mName=name; +} + +inline +const String &NameValuePair::getValue(void)const +{ + return mValue; +} + +inline +void NameValuePair::setValue(const String &value) +{ + mValue=value; +} + +inline +bool NameValuePair::fromString(const String &string) +{ + if(string.isNull())return false; + mName=string.betweenString(0,'='); + mValue=string.betweenString('=',0); + return true; +} +#endif diff --git a/CapServer/hold/Params.cpp b/CapServer/hold/Params.cpp new file mode 100644 index 0000000..9b8db0b --- /dev/null +++ b/CapServer/hold/Params.cpp @@ -0,0 +1,84 @@ +#include +#include + +void Params::setArgs(int argc,char **argv) +{ + String strArg; + getParams(argc,argv); + if(getServer().isNull())setServer("127.0.0.1"); + if(getHost().isNull())setHost("127.0.0.1"); + if(getPort().isNull())setPort("1024"); + if(getDevice().isNull())setDevice("0"); + strArg=getValue(mRetainKey); + strArg.lower(); + if(!(strArg==String("true")) && !(strArg==String("false")))setRetain(false); + else if(strArg==String("true"))setRetain(true); + else setRetain(false); + strArg=getValue(mDebugKey); + strArg.lower(); + if(!(strArg==String("true")) && !(strArg==String("false")))setDebug(false); + else if(strArg==String("true"))setDebug(true); + else setDebug(false); + strArg=getValue(mShowSrcDlgKey); + strArg.lower(); + if(!(strArg==String("true")) && !(strArg==String("false")))setShowSrcDlg(false); + else if(strArg==String("true"))setShowSrcDlg(true); + else setShowSrcDlg(false); +} + +int Params::getParams(int argc,char**argv) +{ + mNameValuePairs.remove(); + for(int index=0;index +#endif +#ifndef _CAPSERVER_NAMEVALUE_HPP_ +#include +#endif + +class Params +{ +public: + typedef enum Request{Server,Client,Settings,None}; + Params(int argc,char **argv); + Params(); + virtual ~Params(); + Request getRequest(void)const; + String getServer(void)const; + String getHost(void)const; + String getPort(void)const; + String getDevice(void)const; + bool getRetain(void)const; + bool getDebug(void)const; + bool getShowSrcDlg(void)const; + void setArgs(int argc,char **argv); + void showParams(void); +private: + int getParams(int argc,char **argv); + String getValue(const String &key)const; + void setValue(const String &key,const String &value); + String getRun(void)const; + void setServer(const String &server); + void setHost(const String &host); + void setPort(const String &port); + void setDevice(const String &device); + void setRetain(bool retain); + void setDebug(bool debug); + void setShowSrcDlg(bool showSrcDlg); + + Block mNameValuePairs; + String mRunKey; + String mServerKey; + String mHostKey; + String mPortKey; + String mDeviceKey; + String mRetainKey; + String mDebugKey; + String mShowSrcDlgKey; +}; + +inline +Params::Params(int argc,char **argv) +: mRunKey("run"), mServerKey("server"), mHostKey("host"), mPortKey("port"), mDeviceKey("device"), + mRetainKey("retain"), mDebugKey("debug"), mShowSrcDlgKey("showsrcdlg") +{ + getParams(argc,argv); +} + +inline +Params::Params() +: mRunKey("run"), mServerKey("server"), mHostKey("host"), mPortKey("port"), mDeviceKey("device"), + mRetainKey("retain"), mDebugKey("debug"), mShowSrcDlgKey("showsrcdlg") +{ +} + +inline +Params::~Params() +{ +} + +inline +String Params::getRun(void)const +{ + return getValue(mRunKey); +} + +inline +String Params::getServer(void)const +{ + return getValue(mServerKey); +} + +inline +String Params::getHost(void)const +{ + return getValue(mHostKey); +} + +inline +String Params::getPort(void)const +{ + return getValue(mPortKey); +} + +inline +String Params::getDevice(void)const +{ + return getValue(mDeviceKey); +} + +inline +bool Params::getRetain(void)const +{ + String strRetain(getValue(mRetainKey)); + if(strRetain=="true")return true; + return false; +} + +inline +bool Params::getDebug(void)const +{ + String strDebug(getValue(mDebugKey)); + if(strDebug=="true")return true; + return false; +} + +inline +bool Params::getShowSrcDlg(void)const +{ + String strValue(getValue(mShowSrcDlgKey)); + if(strValue=="true")return true; + return false; +} + +inline +void Params::setServer(const String &server) +{ + setValue(mServerKey,server); +} + +inline +void Params::setHost(const String &host) +{ + setValue(mHostKey,host); +} + +inline +void Params::setPort(const String &port) +{ + setValue(mPortKey,port); +} + +inline +void Params::setDevice(const String &device) +{ + setValue(mDeviceKey,device); +} + +inline +void Params::setRetain(bool retain) +{ + if(retain)setValue(mRetainKey,"true"); + else setValue(mRetainKey,"false"); +} + +inline +void Params::setDebug(bool debug) +{ + if(debug)setValue(mDebugKey,"true"); + else setValue(mDebugKey,"false"); +} + +inline +void Params::setShowSrcDlg(bool showSrcDlg) +{ + if(showSrcDlg)setValue(mShowSrcDlgKey,"true"); + else setValue(mShowSrcDlgKey,"false"); +} +#endif diff --git a/CapServer/hold/SocketHeader.hpp b/CapServer/hold/SocketHeader.hpp new file mode 100644 index 0000000..8cf77dc --- /dev/null +++ b/CapServer/hold/SocketHeader.hpp @@ -0,0 +1,105 @@ +#ifndef _CAPSERVER_SOCKET_HEADER_HPP_ +#define _CAPSERVER_SOCKET_HEADER_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _SOCKET_SOCKET_HPP_ +#include +#endif + +class SocketHeader +{ +public: + typedef enum ContentType{Unknown,ImageJPG}; + SocketHeader(); + virtual ~SocketHeader(); + int getSizeHeader(void)const; + int getVersion(void)const; + void setVersion(int version); + int getContentLength(void)const; + void setContentLength(int contentLength); + ContentType getContentType(void)const; + void setContentType(int contentType); + bool marshall(Socket &socket); + bool unmarshall(Socket &socket); +private: + int mSizeHeader; + int mVersion; + int mContentLength; + int mContentType; +}; + +inline +SocketHeader::SocketHeader() +: mSizeHeader(sizeof(int)+sizeof(int)+sizeof(int)+sizeof(int)), + mVersion(0), mContentLength(0), mContentType(Unknown) +{ +} + +inline +SocketHeader::~SocketHeader() +{ +} + +inline +int SocketHeader::getSizeHeader(void)const +{ + return mSizeHeader; +} + +inline +int SocketHeader::getVersion(void)const +{ + return mVersion; +} + +inline +void SocketHeader::setVersion(int version) +{ + mVersion=version; +} + +inline +int SocketHeader::getContentLength(void)const +{ + return mContentLength; +} + +inline +void SocketHeader::setContentLength(int contentLength) +{ + mContentLength=contentLength; +} + +inline +SocketHeader::ContentType SocketHeader::getContentType(void)const +{ + return (ContentType)mContentType; +} + +inline +void SocketHeader::setContentType(int contentType) +{ + mContentType=(ContentType)contentType; +} + +inline +bool SocketHeader::marshall(Socket &socket) +{ + if(!socket.send((char*)&mSizeHeader,sizeof(int)))return false; + if(!socket.send((char*)&mVersion,sizeof(int)))return false; + if(!socket.send((char*)&mContentLength,sizeof(int)))return false; + if(!socket.send((char*)&mContentType,sizeof(int)))return false; + return true; +} + +inline +bool SocketHeader::unmarshall(Socket &socket) +{ + if(!socket.receive((char*)&mSizeHeader,sizeof(int)))return false; + if(!socket.receive((char*)&mVersion,sizeof(int)))return false; + if(!socket.receive((char*)&mContentLength,sizeof(int)))return false; + if(!socket.receive((char*)&mContentType,sizeof(int)))return false; + return true; +} +#endif \ No newline at end of file diff --git a/CapServer/hold/SocketServer.cpp b/CapServer/hold/SocketServer.cpp new file mode 100644 index 0000000..1b877d7 --- /dev/null +++ b/CapServer/hold/SocketServer.cpp @@ -0,0 +1,103 @@ +#include +#include +#include +#include +#include + +SocketServer::SocketServer(int deviceIndex,bool retain,bool debug,bool showSrcDlg) +: mWDMCap(deviceIndex), mRetainImage(retain), mDebug(debug) +{ + if(showSrcDlg)mWDMCap.dialogVideoSource(); +} + +SocketServer::~SocketServer() +{ +} + +void SocketServer::acceptHandler(SmartPointer &socketControl) +{ + if(mDebug)sendDebugFrame(*socketControl); + else sendFrame(*socketControl); + +} + +void SocketServer::message(const String &string) +{ + ::printf("%s\n",string.str()); +} + +void SocketServer::sendFrame(Socket &socketControl) +{ + DiskInfo diskInfo; + SystemTime systemTime; + String strPathCaptureFile; + SocketHeader socketHeader; + Array charBytes; + FileHandle openFile; + DWORD elapsedTime; + + socketHeader.setVersion(1); + socketHeader.setContentType(SocketHeader::ImageJPG); + socketHeader.setContentLength(0); + strPathCaptureFile.reserve(1024); + ::sprintf(strPathCaptureFile,"%04d%02d%02d%02d%02d%02d%02d.jpg", + systemTime.year(),systemTime.month(),systemTime.day(), + systemTime.hour(),systemTime.minute(),systemTime.second(), + systemTime.milliseconds()); + elapsedTime=::GetTickCount(); + mWDMCap.setCaptureFileName(strPathCaptureFile); + mWDMCap.grabFrameNoStop(); + elapsedTime=::GetTickCount()-elapsedTime; + message(String("[SocketServer::sendFrame] Grab frame took ")+String().fromInt(elapsedTime)+String(" (ms)")); + if(!openFile.open(strPathCaptureFile,FileHandle::Read,FileHandle::ShareRead)) + { + socketHeader.marshall(socketControl); + } + else + { + charBytes.size(openFile.size()); + socketHeader.setContentLength(charBytes.size()); + elapsedTime=::GetTickCount(); + openFile.read((BYTE*)&charBytes[0],charBytes.size()); + elapsedTime=::GetTickCount()-elapsedTime; + message(String("[SocketServer::sendFrame] Read ")+String().fromInt(charBytes.size())+String(" bytes took ")+String().fromInt(elapsedTime)+String(" (ms)")); + elapsedTime=::GetTickCount(); + socketHeader.marshall(socketControl); + socketControl.send((char*)&charBytes[0],charBytes.size()); + elapsedTime=::GetTickCount()-elapsedTime; + message(String("[SocketServer::sendFrame] Send ")+String().fromInt(charBytes.size())+String(" bytes took ")+String().fromInt(elapsedTime)+String(" (ms)")); + openFile.close(); + if(!mRetainImage)diskInfo.unlink(strPathCaptureFile); + } + message(String("[SocketServer::sendFrame]Sent ")+String().fromInt(charBytes.size())+String(" bytes")); + return; +} + +void SocketServer::sendDebugFrame(Socket &socketControl) +{ + DiskInfo diskInfo; + Array charBytes; + FileHandle openFile; + SocketHeader socketHeader; + String strPathFileName; + + strPathFileName="./image.jpg"; + socketHeader.setVersion(1); + socketHeader.setContentType(SocketHeader::ImageJPG); + socketHeader.setContentLength(0); + if(!openFile.open(strPathFileName,FileHandle::Read,FileHandle::ShareRead)) + { + message("[SocketServer::sendDebugFrame] 'image.jpg' was not found, sending empty content"); + socketHeader.marshall(socketControl); + } + else + { + charBytes.size(openFile.size()); + socketHeader.setContentLength(charBytes.size()); + openFile.read((BYTE*)&charBytes[0],charBytes.size()); + socketHeader.marshall(socketControl); + socketControl.send((char*)&charBytes[0],charBytes.size()); + message(String("[SocketServer::sendDebugFrame] Send ")+String().fromInt(charBytes.size())); + openFile.close(); + } +} diff --git a/CapServer/hold/SocketServer.hpp b/CapServer/hold/SocketServer.hpp new file mode 100644 index 0000000..4a0dd5b --- /dev/null +++ b/CapServer/hold/SocketServer.hpp @@ -0,0 +1,32 @@ +#ifndef _CAPSERVER_SOCKETSERVER_HPP_ +#define _CAPSERVER_SOCKETSERVER_HPP_ +#ifndef _COMMON_BLOCK_HPP_ +#include +#endif +#ifndef _THREAD_MONITOR_HPP_ +#include +#endif +#ifndef _CAPSERVER_WDMCAP_HPP_ +#include +#endif +#ifndef _CAPSERVER_GENERICSERVER_HPP_ +#include +#endif + +class SocketServer : public GenericServer +{ +public: + SocketServer(int deviceIndex=0,bool retain=false,bool debug=false,bool showSrcDlg=false); + virtual ~SocketServer(); +protected: + virtual void acceptHandler(SmartPointer &socketControl); + virtual void message(const String &message); +private: + void sendFrame(Socket &socketControl); + void sendDebugFrame(Socket &socketControl); + + WDMCap mWDMCap; + bool mRetainImage; + bool mDebug; +}; +#endif diff --git a/CapServer/hold/WDMCap.cpp b/CapServer/hold/WDMCap.cpp new file mode 100644 index 0000000..cca61f0 --- /dev/null +++ b/CapServer/hold/WDMCap.cpp @@ -0,0 +1,101 @@ +#include +#include + +WDMCap::WDMCap(int deviceIndex) +: mDriverIndex(deviceIndex) +{ + initialize(); +} + +WDMCap::~WDMCap() +{ +} + +void WDMCap::setCaptureFileName(const String &strPathCaptureFile) +{ + BmpCap::setCaptureFileName(strPathCaptureFile); +} + +const String &WDMCap::getCaptureFileName(void)const +{ + return BmpCap::getCaptureFileName(); +} + +bool WDMCap::initialize(void) +{ + String pathOutputFileName="capture.jpg"; + VidReg vidReg; + + vidReg.setCaptureFile(pathOutputFileName); + vidReg.setSequencing(false); + VidCap::getDrivers(mDriverInfoBlock); + if(!mDriverInfoBlock.size()) + { + message("No drivers found! drivercount",mDriverInfoBlock.size()); + return false; + } + if(mDriverIndex>=mDriverInfoBlock.size()) + { + message("[WDMCap::initilialize]Driver not found! device",mDriverIndex); + return false; + } + showSettings(); + mControl=::new Control(); + mControl.disposition(PointerDisposition::Delete); + mControl->createControl("BUTTON","",0,Rect(0,0,vidReg.getCaptureWidth(),vidReg.getCaptureHeight()),::GetDesktopWindow(),ControlID); + BmpCap::initialize(mControl->getHandle(),mDriverIndex); + if(!connect(mDriverIndex)) + { + ::printf("\007"); + message("[WDMCap::initilialize]Failed to connect to device",mDriverInfoBlock[mDriverIndex].driverName()); + return false; + } + saveFrames(true); + return isConnected(); +} + +void WDMCap::showSettings(void) +{ + VidReg vidReg; + + message("[WDMCap::initilialize]Capture File",vidReg.getCaptureFile()); + message("[WDMCap::initilialize]Sequencing",vidReg.getSequencing()?"true":"false"); + message("[WDMCap::initilialize]Preview Rate",vidReg.getPreviewRate()); + message("[WDMCap::initilialize]Preview Width",vidReg.getPreviewWidth()); + message("[WDMCap::initilialize]Preview Height",vidReg.getPreviewHeight()); + message("[WDMCap::initilialize]Capture Width",vidReg.getCaptureWidth()); + message("[WDMCap::initilialize]Capture Height",vidReg.getCaptureHeight()); + message("[WDMCap::initilialize]Capture Quality",vidReg.getQuality()); + for(int index=0;index +#endif +#ifndef _COMMON_BLOCK_HPP_ +#include +#endif +#ifndef _COMMON_CONTROL_HPP_ +#include +#endif +#ifndef _THREAD_EVENT_HPP_ +#include +#endif +#ifndef _VIDCAP_BMPCAP_HPP_ +#include +#endif + +class WDMCap : private BmpCap +{ +public: + WDMCap(int deviceIndex=0); + virtual ~WDMCap(); + bool grabFrame(void); + bool grabFrameNoStop(void); + bool dialogVideoSource(void); + bool isConnected(void)const; + bool getDriverCaps(DriverCaps &someDriverCaps); + bool getCaptureParams(CaptureParams &someCaptureParams); + void setCaptureFileName(const String &strPathCaptureFile); + const String &getCaptureFileName(void)const; +protected: + virtual void frameHandler(VIDEOHDR &videoHeader); +private: + enum{ControlID=100}; + bool initialize(void); + void showSettings(void); + void message(const String &message); + void message(const String &message,const String &arg); + void message(const String &message,int arg); + + SmartPointer mControl; + Block mDriverInfoBlock; + Event mFrameEvent; + DWORD mDriverIndex; + DWORD mGrabTime; +}; + +inline +bool WDMCap::dialogVideoSource(void) +{ + return BmpCap::dialogVideoSource(); +} + +inline +bool WDMCap::isConnected(void)const +{ + return BmpCap::isConnected(); +} + +inline +bool WDMCap::getDriverCaps(DriverCaps &someDriverCaps) +{ + return BmpCap::getDriverCaps(someDriverCaps); +} + +inline +bool WDMCap::getCaptureParams(CaptureParams &someCaptureParams) +{ + return BmpCap::getCaptureParams(someCaptureParams); +} + +inline +void WDMCap::message(const String &message,int arg) +{ + ::printf("%s=%d\n",message.str(),arg); +} + +inline +void WDMCap::message(const String &message,const String &arg) +{ + ::printf("%s=%s\n",message.str(),arg.str()); +} + +inline +void WDMCap::message(const String &message) +{ + ::printf("%s\n",message.str()); +} +#endif diff --git a/CapServer/hold/gensrv.cpp b/CapServer/hold/gensrv.cpp new file mode 100644 index 0000000..3e5f028 --- /dev/null +++ b/CapServer/hold/gensrv.cpp @@ -0,0 +1,96 @@ +#include +#include +#include + +extern bool running; + +GenericServer::GenericServer(void) +: mIsRunning(TRUE) +{ +} + +GenericServer::~GenericServer() +{ + message("[GenericServer::~GenericServer]Server is destructing..."); +} + +void GenericServer::close(void) +{ + mIsRunning=FALSE; +} + +WORD GenericServer::listen(const String &hostName,short portNum) +{ + HostEnt hostEntry; + ServEnt serverEntry; + String stringData; + SystemTime systemTime; + DWORD elapsedTime; + + message(String("[GenericServer::listen]trying host'")+hostName+String("'...")); + if(!mWSASystem.isInitialized()){message("[GenericServer::listen]WINSOCK initialization failure.");return FALSE;} + InternetAddress internetAddress(hostName); + if(!internetAddress.isZero()){if(!hostEntry.hostByAddress(internetAddress)){message(String("[GenericServer::listen]no DNS entry for ")+hostName);return FALSE;}} + else if(!hostEntry.hostByName(hostName)){message(String("[GenericServer::listen]no DNS entry for ")+hostName);return FALSE;} + message(String("[GenericServer::listen]connect...")+String("'")+hostEntry.hostName()+String("' (")+(String)(hostEntry.addresses())[0]+String(")")); + mInternetSocketAddress.internetAddress((hostEntry.addresses())[0]); + mInternetSocketAddress.family(PF_INET); + mInternetSocketAddress.port(portNum); + if(!mGenericControl.create()){message("[GenericServer::listen]socket initialization failure.");return FALSE;} + mGenericControl.reuseAddress(); + if(!mGenericControl.bind(mInternetSocketAddress)){message("[GenericServer::listen]bind failed");return FALSE;} + while(mIsRunning&&running) + { + SmartPointer socketControl; + socketControl=::new Socket(); +// socketControl.disposition(PointerDisposition::Assume); + socketControl.disposition(PointerDisposition::Delete); + INETSocketAddress internetSocketAddress; + message(String("[GenericServer::listen]host='")+(hostEntry.addresses())[0]+String("' port=")+String().fromInt(portNum)); + String strLocalHost((String)mInternetSocketAddress.internetAddress()); + message(String("[GenericServer::listen]local address is ")+strLocalHost); + if(!mGenericControl.listen()){message("[GenericServer::listen]listen failed");return FALSE;} + message("[GenericServer::listen]waiting for connection..."); + if(!mGenericControl.accept(*socketControl,internetSocketAddress)){message("[GenericServer::listen]accept returned FALSE;");return FALSE;} + +// socketControl->setLinger(0); +// socketControl->bind(internetSocketAddress); + + systemTime.refresh(); + message(String("[GenericServer::listen]service started from ")+internetSocketAddress.internetAddress().toString()+String(" on ")+systemTime.toString()); + elapsedTime=::GetTickCount(); + acceptHandler(socketControl); + socketControl->destroy(); + socketControl.destroy(); + elapsedTime=::GetTickCount()-elapsedTime; + message(String("[GenericServer::listen]service took ")+String().fromInt(elapsedTime)+String("(ms)")); + } + mGenericControl.destroy(); + message("[GenericServer::listen]terminating connection"); + return TRUE; +} + +// virtuals + +void GenericServer::message(const String &message) +{ + ::OutputDebugString(message+String("\n")); +} + +void GenericServer::message(Block &msgData) +{ + for(int msgIndex=0;msgIndex &socket) +{ + SmartPointer socketControl; + + socketControl=socket; + socketControl.disposition(PointerDisposition::Delete); + String acceptString("[GenericServer::acceptHandler]200 GenericServer::acceptHandler accepting connection."); + socketControl->send(acceptString); + message(acceptString); + return; +} + diff --git a/CapServer/hold/gensrv.hpp b/CapServer/hold/gensrv.hpp new file mode 100644 index 0000000..7e94a03 --- /dev/null +++ b/CapServer/hold/gensrv.hpp @@ -0,0 +1,42 @@ +#ifndef _CAPSERVER_GENERICSERVER_HPP_ +#define _CAPSERVER_GENERICSERVER_HPP_ +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif +#ifndef _SOCKET_HOSTENT_HPP_ +#include +#endif +#ifndef _SOCKET_SERVENT_HPP_ +#include +#endif +#ifndef _SOCKET_INETSOCKETADDRESS_HPP_ +#include +#endif +#ifndef _SOCKET_SOCKET_HPP_ +#include +#endif + +class GenericServer +{ +public: + GenericServer(void); + virtual ~GenericServer(); + WORD listen(const String &hostName,short portNum); + WORD receive(char &charData,BOOL waitForData=TRUE); + void close(void); +protected: + virtual void acceptHandler(SmartPointer &socketControl); + virtual void message(const String &message); + virtual void message(Block &msgData); +private: + enum{TimeOut=1000}; + INETSocketAddress mInternetSocketAddress; + Socket mGenericControl; + WSASystem mWSASystem; + BOOL mIsRunning; +}; + +#endif \ No newline at end of file diff --git a/CapServer/image.jpg b/CapServer/image.jpg new file mode 100644 index 0000000..2018a1d Binary files /dev/null and b/CapServer/image.jpg differ diff --git a/CapServer/pspbrwse.jbf b/CapServer/pspbrwse.jbf new file mode 100644 index 0000000..7696e8e Binary files /dev/null and b/CapServer/pspbrwse.jbf differ diff --git a/CapServer/scraps.txt b/CapServer/scraps.txt new file mode 100644 index 0000000..d26acf3 --- /dev/null +++ b/CapServer/scraps.txt @@ -0,0 +1,205 @@ +/* while(running) + { + ::printf("Grabbing Frame...\n"); + bmpCap->grabFrame(); + ::Sleep(timeout); + } */ + + +// portControl.bind(internetSocketAddress); +// acceptHandler(portControl); +// if(mPortControl.receive(stringData))stringHandler(stringData); +/* Block receiveStrings; + printf("Received data..."); + if(mPortControl.receive(receiveStrings)) + { + for(int index=0;index drivers; + SmartPointer bmpCap; + SmartPointer control; + String pathOutputFileName; + int timeout; + VidReg vidReg; + + if(3!=argc) + { + ::printf("CAPTURE \n"); + return; + } + ::SetConsoleCtrlHandler(&handlerRoutine,true); + pathOutputFileName=argv[1]; + timeout=String(argv[2]).toInt(); + vidReg.setCaptureWidth(320); + vidReg.setCaptureHeight(240); + vidReg.setCaptureFile(pathOutputFileName); + vidReg.setSequencing(false); + ::printf("Capture File:%s\n",vidReg.getCaptureFile().str()); + ::printf("Sequencing:%s\n",vidReg.getSequencing()?"true":"false"); + ::printf("Preview Rate:%d\n",vidReg.getPreviewRate()); + ::printf("Preview Width:%d\n",vidReg.getPreviewWidth()); + ::printf("Preview Height:%d\n",vidReg.getPreviewHeight()); + ::printf("Capture Width:%d\n",vidReg.getCaptureWidth()); + ::printf("Capture Height:%d\n",vidReg.getCaptureHeight()); + ::printf("Refresh:%d\n",timeout/1000); + + VidCap::getDrivers(drivers); + if(!drivers.size()) + { + ::printf("No drivers found!\n"); + return; + } + for(int index=0;indexcreateControl("BUTTON","",0,Rect(0,0,320,240),::GetDesktopWindow(),100); + + bmpCap=::new BmpCap(control->getHandle(),0); + bmpCap.disposition(PointerDisposition::Delete); + if(!bmpCap->connect(0)) + { + ::printf("Failed to connect to device '%s'\n",drivers[0].driverName().str()); + return; + } + bmpCap->saveFrames(true); + while(running) + { + ::printf("Grabbing Frame...\n"); + bmpCap->grabFrame(); + ::Sleep(timeout); + } + return; +} +*/ + + +/* + int sizeHeader=htons(mSizeHeader); + int version=htons(mVersion); + int contentLength=htons(mContentLength); + int contentType=htons(mContentType); + + + if(!socket.send((char*)&sizeHeader,sizeof(int)))return false; + if(!socket.send((char*)&version,sizeof(int)))return false; + if(!socket.send((char*)&contentLength,sizeof(int)))return false; + if(!socket.send((char*)&contentType,sizeof(int)))return false; +*/ + + + + + +/* +#include + +void main(int argc,char **argv) +{ + ::printf("convert %s %s",argv[1],argv[2]); + ImageConverter::convert(argv[1],argv[2],75); +} +*/ + + + +/* + + + + WSASystem wsaSystem; + String strOption; + + + + if(argc!=2) + { + ::printf("CapServer {server}{client}\n"); + return; + } + strOption=argv[1]; + ::SetConsoleCtrlHandler(&handlerRoutine,true); + + + + if(strOption=="server") + { + ::printf("starting server\n"); + SocketServer socketServer; + socketServer.listen("rocinante",1024); + } + else + { + INETSocketAddress internetSocketAddress; + InternetAddress internetAddress(127,0,0,1); + Socket socket; + SocketHeader socketHeader; + Array content; + + ::printf("starting client\n"); + internetSocketAddress.family(PF_INET); + internetSocketAddress.port(1024); + internetSocketAddress.internetAddress(internetAddress); + if(!socket.create()) + { + ::printf("create failed...\n"); + return; + } + if(!socket.connect(internetSocketAddress)) + { + ::printf("connect failed...\n"); + return; + } + ::printf("reading socket header...\n"); + socketHeader.unmarshall(socket); + ::printf("size header is %d bytes\n",socketHeader.getSizeHeader()); + ::printf("version is %d \n",socketHeader.getVersion()); + ::printf("content length is %d bytes\n",socketHeader.getContentLength()); + ::printf("content type is %d \n",(int)socketHeader.getContentType()); + content.size(socketHeader.getContentLength()); + ::printf("reading content...\n"); + socket.receive((char*)&content[0],content.size()); + ::printf("done...\n"); + socket.destroy(); + } +*/ + + + + socketHeader.setVersion(1); + socketHeader.setContentType(SocketHeader::ImageJPG); + socketHeader.setContentLength(0); + strPathCaptureFile.reserve(1024); + ::sprintf(strPathCaptureFile,"%04d%02d%02d%02d%02d%02d%02d.jpg", + systemTime.year(),systemTime.month(),systemTime.day(), + systemTime.hour(),systemTime.minute(),systemTime.second(), + systemTime.milliseconds()); +// strPathCaptureFile="image000.jpg"; + mWDMCap.setCaptureFileName(strPathCaptureFile); + mWDMCap.grabFrame(); + if(!openFile.open(strPathCaptureFile,FileHandle::Read,FileHandle::ShareRead)) + { + socketHeader.marshall(socketControl); + } + + + + int mSizeHeader; + int mVersion; + int mContentLength; + int mContentType; diff --git a/ClassGen/Debug/classgen.exe b/ClassGen/Debug/classgen.exe new file mode 100644 index 0000000..5aeab03 Binary files /dev/null and b/ClassGen/Debug/classgen.exe differ diff --git a/ClassGen/Debug/classgen.pdb b/ClassGen/Debug/classgen.pdb new file mode 100644 index 0000000..9c0090d Binary files /dev/null and b/ClassGen/Debug/classgen.pdb differ diff --git a/ClassGen/Debug/vc60.idb b/ClassGen/Debug/vc60.idb new file mode 100644 index 0000000..b90f29e Binary files /dev/null and b/ClassGen/Debug/vc60.idb differ diff --git a/ClassGen/Debug/vc60.pdb b/ClassGen/Debug/vc60.pdb new file mode 100644 index 0000000..b65134e Binary files /dev/null and b/ClassGen/Debug/vc60.pdb differ diff --git a/ClassGen/Historic.cs b/ClassGen/Historic.cs new file mode 100644 index 0000000..7673797 --- /dev/null +++ b/ClassGen/Historic.cs @@ -0,0 +1,628 @@ +using System; + + +namespace ZBI.Risk.Server.Mapped +{ + [Serializable] + public class Historic + { + private DateTime tradeDate; + private string tradeDateTxt; + private string portfolio; + private string subPortfolio; + private string ticker; + private string tickerDesc; + private string uticker; + private string instrument; + private decimal contractSize; + private string hedgeIndex; + private string hedgeSector; + private string area; + private string areaSector; + private decimal yClose; + private decimal utickerClose; + private decimal yUtickerClose; + private decimal delta; + private decimal yDelta; + private decimal hedgeBeta; + private decimal areaBeta; + private decimal sectorBeta; + private decimal groupBeta; + private decimal qty; + private decimal yQty; + private decimal qtyChange; + private decimal hedgeClose; + private decimal hedgePerc; + private decimal areaClose; + private decimal areaPerc; + private decimal sectorClose; + private decimal sectorPerc; + private decimal mktValue; + private decimal yMktValue; + private decimal exposure; + private decimal yExposure; + private decimal hbExposure; + private decimal yHbExposure; + private decimal abExposure; + private decimal yAbExposure; + private decimal sbExposure; + private decimal ySbExposure; + private decimal pnl; + private decimal pnlPerc; + private decimal priceChange; + private decimal priceChangePerc; + private decimal priceChangeAmt; + private decimal sectorAlphaPerc; + private decimal groupAlphaPerc; + private decimal areaAlphaPerc; + private decimal hedgeAlphaPerc; + private decimal areaPnlAmt; + private decimal sectorPnlAmt; + private decimal sectorAlphaAmt; + private decimal groupAlphaAmt; + private decimal areaAlphaAmt; + private decimal hedgeAlphaAmt; + private decimal abReturnAmt; + private decimal abReturnPerc; + private decimal altIndexReturnPerc; + private decimal altIndexReturnAmt; + private decimal indexBetaAdjPerc; + private decimal indexBetaAdjAmt; + private decimal intradayPerc; + private decimal intradayAmt; + private decimal optionalityPerc; + private decimal optionalityAmt; + private string currency; + private decimal baseClose; + private decimal yBaseClose; + private decimal fxPerc; + private decimal fxAmt; + private decimal fxRate; + private decimal yFxRate; + private string exposureView; + private string marketView; + private string callPut; + private int daysExpire; + private decimal strikePrice; + private string associate; + private bool ipo; + private decimal ratio; + private bool exported; + private string source; + private decimal vwap; + private decimal vwapPnl; + private decimal adh; + private decimal aac; + private decimal azap; + private DateTime goAround; + private decimal alphaGoAround; + private decimal alphaReal; + private decimal alphaUnreal; + private decimal pnlReal; + private decimal pnlUnreal; + private decimal cashFlow; + private decimal betaCashFlow; + private DateTime lastTradeDate; + private decimal lastTradeQty; + private decimal enterpriseValue; + private decimal mktCap; + private decimal wgtAve; + private decimal volume; + private long rowID; + public DateTime TradeDate + { + get{return tradeDate;} + set{tradeDate=value;} + } + public string TradeDateTxt + { + get{return tradeDateTxt;} + set{tradeDateTxt=value;} + } + public string Portfolio + { + get{return portfolio;} + set{portfolio=value;} + } + public string SubPortfolio + { + get{return subPortfolio;} + set{subPortfolio=value;} + } + public string Ticker + { + get{return ticker;} + set{ticker=value;} + } + public string TickerDesc + { + get{return tickerDesc;} + set{tickerDesc=value;} + } + public string Uticker + { + get{return uticker;} + set{uticker=value;} + } + public string Instrument + { + get{return instrument;} + set{instrument=value;} + } + public decimal ContractSize + { + get{return contractSize;} + set{contractSize=value;} + } + public string HedgeIndex + { + get{return hedgeIndex;} + set{hedgeIndex=value;} + } + public string HedgeSector + { + get{return hedgeSector;} + set{hedgeSector=value;} + } + public string Area + { + get{return area;} + set{area=value;} + } + public string AreaSector + { + get{return areaSector;} + set{areaSector=value;} + } + public decimal YClose + { + get{return yClose;} + set{yClose=value;} + } + public decimal UtickerClose + { + get{return utickerClose;} + set{utickerClose=value;} + } + public decimal YUtickerClose + { + get{return yUtickerClose;} + set{yUtickerClose=value;} + } + public decimal Delta + { + get{return delta;} + set{delta=value;} + } + public decimal YDelta + { + get{return yDelta;} + set{yDelta=value;} + } + public decimal HedgeBeta + { + get{return hedgeBeta;} + set{hedgeBeta=value;} + } + public decimal AreaBeta + { + get{return areaBeta;} + set{areaBeta=value;} + } + public decimal SectorBeta + { + get{return sectorBeta;} + set{sectorBeta=value;} + } + public decimal GroupBeta + { + get{return groupBeta;} + set{groupBeta=value;} + } + public decimal Qty + { + get{return qty;} + set{qty=value;} + } + public decimal YQty + { + get{return yQty;} + set{yQty=value;} + } + public decimal QtyChange + { + get{return qtyChange;} + set{qtyChange=value;} + } + public decimal HedgeClose + { + get{return hedgeClose;} + set{hedgeClose=value;} + } + public decimal HedgePerc + { + get{return hedgePerc;} + set{hedgePerc=value;} + } + public decimal AreaClose + { + get{return areaClose;} + set{areaClose=value;} + } + public decimal AreaPerc + { + get{return areaPerc;} + set{areaPerc=value;} + } + public decimal SectorClose + { + get{return sectorClose;} + set{sectorClose=value;} + } + public decimal SectorPerc + { + get{return sectorPerc;} + set{sectorPerc=value;} + } + public decimal MktValue + { + get{return mktValue;} + set{mktValue=value;} + } + public decimal YMktValue + { + get{return yMktValue;} + set{yMktValue=value;} + } + public decimal Exposure + { + get{return exposure;} + set{exposure=value;} + } + public decimal YExposure + { + get{return yExposure;} + set{yExposure=value;} + } + public decimal HbExposure + { + get{return hbExposure;} + set{hbExposure=value;} + } + public decimal YHbExposure + { + get{return yHbExposure;} + set{yHbExposure=value;} + } + public decimal AbExposure + { + get{return abExposure;} + set{abExposure=value;} + } + public decimal YAbExposure + { + get{return yAbExposure;} + set{yAbExposure=value;} + } + public decimal SbExposure + { + get{return sbExposure;} + set{sbExposure=value;} + } + public decimal YSbExposure + { + get{return ySbExposure;} + set{ySbExposure=value;} + } + public decimal Pnl + { + get{return pnl;} + set{pnl=value;} + } + public decimal PnlPerc + { + get{return pnlPerc;} + set{pnlPerc=value;} + } + public decimal PriceChange + { + get{return priceChange;} + set{priceChange=value;} + } + public decimal PriceChangePerc + { + get{return priceChangePerc;} + set{priceChangePerc=value;} + } + public decimal PriceChangeAmt + { + get{return priceChangeAmt;} + set{priceChangeAmt=value;} + } + public decimal SectorAlphaPerc + { + get{return sectorAlphaPerc;} + set{sectorAlphaPerc=value;} + } + public decimal GroupAlphaPerc + { + get{return groupAlphaPerc;} + set{groupAlphaPerc=value;} + } + public decimal AreaAlphaPerc + { + get{return areaAlphaPerc;} + set{areaAlphaPerc=value;} + } + public decimal HedgeAlphaPerc + { + get{return hedgeAlphaPerc;} + set{hedgeAlphaPerc=value;} + } + public decimal AreaPnlAmt + { + get{return areaPnlAmt;} + set{areaPnlAmt=value;} + } + public decimal SectorPnlAmt + { + get{return sectorPnlAmt;} + set{sectorPnlAmt=value;} + } + public decimal SectorAlphaAmt + { + get{return sectorAlphaAmt;} + set{sectorAlphaAmt=value;} + } + public decimal GroupAlphaAmt + { + get{return groupAlphaAmt;} + set{groupAlphaAmt=value;} + } + public decimal AreaAlphaAmt + { + get{return areaAlphaAmt;} + set{areaAlphaAmt=value;} + } + public decimal HedgeAlphaAmt + { + get{return hedgeAlphaAmt;} + set{hedgeAlphaAmt=value;} + } + public decimal AbReturnAmt + { + get{return abReturnAmt;} + set{abReturnAmt=value;} + } + public decimal AbReturnPerc + { + get{return abReturnPerc;} + set{abReturnPerc=value;} + } + public decimal AltIndexReturnPerc + { + get{return altIndexReturnPerc;} + set{altIndexReturnPerc=value;} + } + public decimal AltIndexReturnAmt + { + get{return altIndexReturnAmt;} + set{altIndexReturnAmt=value;} + } + public decimal IndexBetaAdjPerc + { + get{return indexBetaAdjPerc;} + set{indexBetaAdjPerc=value;} + } + public decimal IndexBetaAdjAmt + { + get{return indexBetaAdjAmt;} + set{indexBetaAdjAmt=value;} + } + public decimal IntradayPerc + { + get{return intradayPerc;} + set{intradayPerc=value;} + } + public decimal IntradayAmt + { + get{return intradayAmt;} + set{intradayAmt=value;} + } + public decimal OptionalityPerc + { + get{return optionalityPerc;} + set{optionalityPerc=value;} + } + public decimal OptionalityAmt + { + get{return optionalityAmt;} + set{optionalityAmt=value;} + } + public string Currency + { + get{return currency;} + set{currency=value;} + } + public decimal BaseClose + { + get{return baseClose;} + set{baseClose=value;} + } + public decimal YBaseClose + { + get{return yBaseClose;} + set{yBaseClose=value;} + } + public decimal FxPerc + { + get{return fxPerc;} + set{fxPerc=value;} + } + public decimal FxAmt + { + get{return fxAmt;} + set{fxAmt=value;} + } + public decimal FxRate + { + get{return fxRate;} + set{fxRate=value;} + } + public decimal YFxRate + { + get{return yFxRate;} + set{yFxRate=value;} + } + public string ExposureView + { + get{return exposureView;} + set{exposureView=value;} + } + public string MarketView + { + get{return marketView;} + set{marketView=value;} + } + public string CallPut + { + get{return callPut;} + set{callPut=value;} + } + public int DaysExpire + { + get{return daysExpire;} + set{daysExpire=value;} + } + public decimal StrikePrice + { + get{return strikePrice;} + set{strikePrice=value;} + } + public string Associate + { + get{return associate;} + set{associate=value;} + } + public bool Ipo + { + get{return ipo;} + set{ipo=value;} + } + public decimal Ratio + { + get{return ratio;} + set{ratio=value;} + } + public bool Exported + { + get{return exported;} + set{exported=value;} + } + public string Source + { + get{return source;} + set{source=value;} + } + public decimal Vwap + { + get{return vwap;} + set{vwap=value;} + } + public decimal VwapPnl + { + get{return vwapPnl;} + set{vwapPnl=value;} + } + public decimal Adh + { + get{return adh;} + set{adh=value;} + } + public decimal Aac + { + get{return aac;} + set{aac=value;} + } + public decimal Azap + { + get{return azap;} + set{azap=value;} + } + public DateTime GoAround + { + get{return goAround;} + set{goAround=value;} + } + public decimal AlphaGoAround + { + get{return alphaGoAround;} + set{alphaGoAround=value;} + } + public decimal AlphaReal + { + get{return alphaReal;} + set{alphaReal=value;} + } + public decimal AlphaUnreal + { + get{return alphaUnreal;} + set{alphaUnreal=value;} + } + public decimal PnlReal + { + get{return pnlReal;} + set{pnlReal=value;} + } + public decimal PnlUnreal + { + get{return pnlUnreal;} + set{pnlUnreal=value;} + } + public decimal CashFlow + { + get{return cashFlow;} + set{cashFlow=value;} + } + public decimal BetaCashFlow + { + get{return betaCashFlow;} + set{betaCashFlow=value;} + } + public DateTime LastTradeDate + { + get{return lastTradeDate;} + set{lastTradeDate=value;} + } + public decimal LastTradeQty + { + get{return lastTradeQty;} + set{lastTradeQty=value;} + } + public decimal EnterpriseValue + { + get{return enterpriseValue;} + set{enterpriseValue=value;} + } + public decimal MktCap + { + get{return mktCap;} + set{mktCap=value;} + } + public decimal WgtAve + { + get{return wgtAve;} + set{wgtAve=value;} + } + public decimal Volume + { + get{return volume;} + set{volume=value;} + } + public long RowID + { + get{return rowID;} + set{rowID=value;} + } + } +} diff --git a/ClassGen/Historic.java b/ClassGen/Historic.java new file mode 100644 index 0000000..71c97ad --- /dev/null +++ b/ClassGen/Historic.java @@ -0,0 +1,951 @@ +package zbi.risk.server.vhi.mapped + + +public class Historic +{ + private Timestamp tradeDate; + private String tradeDateTxt; + private String portfolio; + private String subPortfolio; + private String ticker; + private String tickerDesc; + private String uticker; + private String instrument; + private float mktCap; + private float wgtAve; + private float volume; + private float contractSize; + private String hedgeIndex; + private String hedgeSector; + private String area; + private String areaSector; + private float close; + private float yClose; + private float utickerClose; + private float yUtickerClose; + private float delta; + private float yDelta; + private int daysExpire; + private float strikePrice; + private float hedgeBeta; + private float areaBeta; + private float sectorBeta; + private float groupBeta; + private float qty; + private float yQty; + private float qtyChange; + private float hedgeClose; + private float hedgePerc; + private float areaClose; + private float areaPerc; + private float sectorClose; + private float sectorPerc; + private float mktValue; + private float yMktValue; + private float pnl; + private float exposure; + private float yExposure; + private float hbExposure; + private float yHbExposure; + private float abExposure; + private float yAbExposure; + private float sbExposure; + private float ySbExposure; + private float areaPnlAmt; + private float sectorPnlAmt; + private float pnlPerc; + private float priceChange; + private float priceChangePerc; + private float priceChangeAmt; + private float sectorAlphaPerc; + private float groupAlphaPerc; + private float areaAlphaPerc; + private float sectorAlphaAmt; + private float groupAlphaAmt; + private float areaAlphaAmt; + private float abReturnAmt; + private float abReturnPerc; + private float intradayPerc; + private float intradayAmt; + private float optionalityAmt; + private float optionalityPerc; + private String currency; + private float baseClose; + private float yBaseClose; + private float fxPerc; + private float fxAmt; + private float fxRate; + private float yFxRate; + private float altIndexReturnPerc; + private float altIndexReturnAmt; + private float indexBetaAdjPerc; + private float indexBetaAdjAmt; + private float vwap; + private float vwapPnl; + private float hedgeAlphaAmt; + private String exposureView; + private String marketView; + private String callPut; + private String [month]; + private boolean private; + private boolean ipo; + private float ratio; + private String source; + private Timestamp goAround; + private float adh; + private float aac; + private float azap; + private boolean exported; + private float hedgeAlphaPerc; + private float alphaGoAround; + private float alphaReal; + private float alphaUnreal; + private float pnlReal; + private float pnlUnreal; + private float cashFlow; + private float betaCashFlow; + private Timestamp lastTradeDate; + private float lastTradeQty; + private float enterpriseValue; + private String associate; + public Timestamp getTradeDate() + { + return tradeDate; + } + public void setTradeDate(Timestamp tradeDate) + { + this.tradeDate=tradeDate; + } + public String getTradeDateTxt() + { + return tradeDateTxt; + } + public void setTradeDateTxt(String tradeDateTxt) + { + this.tradeDateTxt=tradeDateTxt; + } + public String getPortfolio() + { + return portfolio; + } + public void setPortfolio(String portfolio) + { + this.portfolio=portfolio; + } + public String getSubPortfolio() + { + return subPortfolio; + } + public void setSubPortfolio(String subPortfolio) + { + this.subPortfolio=subPortfolio; + } + public String getTicker() + { + return ticker; + } + public void setTicker(String ticker) + { + this.ticker=ticker; + } + public String getTickerDesc() + { + return tickerDesc; + } + public void setTickerDesc(String tickerDesc) + { + this.tickerDesc=tickerDesc; + } + public String getUticker() + { + return uticker; + } + public void setUticker(String uticker) + { + this.uticker=uticker; + } + public String getInstrument() + { + return instrument; + } + public void setInstrument(String instrument) + { + this.instrument=instrument; + } + public float getMktCap() + { + return mktCap; + } + public void setMktCap(float mktCap) + { + this.mktCap=mktCap; + } + public float getWgtAve() + { + return wgtAve; + } + public void setWgtAve(float wgtAve) + { + this.wgtAve=wgtAve; + } + public float getVolume() + { + return volume; + } + public void setVolume(float volume) + { + this.volume=volume; + } + public float getContractSize() + { + return contractSize; + } + public void setContractSize(float contractSize) + { + this.contractSize=contractSize; + } + public String getHedgeIndex() + { + return hedgeIndex; + } + public void setHedgeIndex(String hedgeIndex) + { + this.hedgeIndex=hedgeIndex; + } + public String getHedgeSector() + { + return hedgeSector; + } + public void setHedgeSector(String hedgeSector) + { + this.hedgeSector=hedgeSector; + } + public String getArea() + { + return area; + } + public void setArea(String area) + { + this.area=area; + } + public String getAreaSector() + { + return areaSector; + } + public void setAreaSector(String areaSector) + { + this.areaSector=areaSector; + } + public float get[close]() + { + return [close]; + } + public void set[close](float [close]) + { + this.[close]=[close]; + } + public float getYClose() + { + return yClose; + } + public void setYClose(float yClose) + { + this.yClose=yClose; + } + public float getUtickerClose() + { + return utickerClose; + } + public void setUtickerClose(float utickerClose) + { + this.utickerClose=utickerClose; + } + public float getYUtickerClose() + { + return yUtickerClose; + } + public void setYUtickerClose(float yUtickerClose) + { + this.yUtickerClose=yUtickerClose; + } + public float getDelta() + { + return delta; + } + public void setDelta(float delta) + { + this.delta=delta; + } + public float getYDelta() + { + return yDelta; + } + public void setYDelta(float yDelta) + { + this.yDelta=yDelta; + } + public int getDaysExpire() + { + return daysExpire; + } + public void setDaysExpire(int daysExpire) + { + this.daysExpire=daysExpire; + } + public float getStrikePrice() + { + return strikePrice; + } + public void setStrikePrice(float strikePrice) + { + this.strikePrice=strikePrice; + } + public float getHedgeBeta() + { + return hedgeBeta; + } + public void setHedgeBeta(float hedgeBeta) + { + this.hedgeBeta=hedgeBeta; + } + public float getAreaBeta() + { + return areaBeta; + } + public void setAreaBeta(float areaBeta) + { + this.areaBeta=areaBeta; + } + public float getSectorBeta() + { + return sectorBeta; + } + public void setSectorBeta(float sectorBeta) + { + this.sectorBeta=sectorBeta; + } + public float getGroupBeta() + { + return groupBeta; + } + public void setGroupBeta(float groupBeta) + { + this.groupBeta=groupBeta; + } + public float getQty() + { + return qty; + } + public void setQty(float qty) + { + this.qty=qty; + } + public float getYQty() + { + return yQty; + } + public void setYQty(float yQty) + { + this.yQty=yQty; + } + public float getQtyChange() + { + return qtyChange; + } + public void setQtyChange(float qtyChange) + { + this.qtyChange=qtyChange; + } + public float getHedgeClose() + { + return hedgeClose; + } + public void setHedgeClose(float hedgeClose) + { + this.hedgeClose=hedgeClose; + } + public float getHedgePerc() + { + return hedgePerc; + } + public void setHedgePerc(float hedgePerc) + { + this.hedgePerc=hedgePerc; + } + public float getAreaClose() + { + return areaClose; + } + public void setAreaClose(float areaClose) + { + this.areaClose=areaClose; + } + public float getAreaPerc() + { + return areaPerc; + } + public void setAreaPerc(float areaPerc) + { + this.areaPerc=areaPerc; + } + public float getSectorClose() + { + return sectorClose; + } + public void setSectorClose(float sectorClose) + { + this.sectorClose=sectorClose; + } + public float getSectorPerc() + { + return sectorPerc; + } + public void setSectorPerc(float sectorPerc) + { + this.sectorPerc=sectorPerc; + } + public float getMktValue() + { + return mktValue; + } + public void setMktValue(float mktValue) + { + this.mktValue=mktValue; + } + public float getYMktValue() + { + return yMktValue; + } + public void setYMktValue(float yMktValue) + { + this.yMktValue=yMktValue; + } + public float getPnl() + { + return pnl; + } + public void setPnl(float pnl) + { + this.pnl=pnl; + } + public float getExposure() + { + return exposure; + } + public void setExposure(float exposure) + { + this.exposure=exposure; + } + public float getYExposure() + { + return yExposure; + } + public void setYExposure(float yExposure) + { + this.yExposure=yExposure; + } + public float getHbExposure() + { + return hbExposure; + } + public void setHbExposure(float hbExposure) + { + this.hbExposure=hbExposure; + } + public float getYHbExposure() + { + return yHbExposure; + } + public void setYHbExposure(float yHbExposure) + { + this.yHbExposure=yHbExposure; + } + public float getAbExposure() + { + return abExposure; + } + public void setAbExposure(float abExposure) + { + this.abExposure=abExposure; + } + public float getYAbExposure() + { + return yAbExposure; + } + public void setYAbExposure(float yAbExposure) + { + this.yAbExposure=yAbExposure; + } + public float getSbExposure() + { + return sbExposure; + } + public void setSbExposure(float sbExposure) + { + this.sbExposure=sbExposure; + } + public float getYSbExposure() + { + return ySbExposure; + } + public void setYSbExposure(float ySbExposure) + { + this.ySbExposure=ySbExposure; + } + public float getAreaPnlAmt() + { + return areaPnlAmt; + } + public void setAreaPnlAmt(float areaPnlAmt) + { + this.areaPnlAmt=areaPnlAmt; + } + public float getSectorPnlAmt() + { + return sectorPnlAmt; + } + public void setSectorPnlAmt(float sectorPnlAmt) + { + this.sectorPnlAmt=sectorPnlAmt; + } + public float getPnlPerc() + { + return pnlPerc; + } + public void setPnlPerc(float pnlPerc) + { + this.pnlPerc=pnlPerc; + } + public float getPriceChange() + { + return priceChange; + } + public void setPriceChange(float priceChange) + { + this.priceChange=priceChange; + } + public float getPriceChangePerc() + { + return priceChangePerc; + } + public void setPriceChangePerc(float priceChangePerc) + { + this.priceChangePerc=priceChangePerc; + } + public float getPriceChangeAmt() + { + return priceChangeAmt; + } + public void setPriceChangeAmt(float priceChangeAmt) + { + this.priceChangeAmt=priceChangeAmt; + } + public float getSectorAlphaPerc() + { + return sectorAlphaPerc; + } + public void setSectorAlphaPerc(float sectorAlphaPerc) + { + this.sectorAlphaPerc=sectorAlphaPerc; + } + public float getGroupAlphaPerc() + { + return groupAlphaPerc; + } + public void setGroupAlphaPerc(float groupAlphaPerc) + { + this.groupAlphaPerc=groupAlphaPerc; + } + public float getAreaAlphaPerc() + { + return areaAlphaPerc; + } + public void setAreaAlphaPerc(float areaAlphaPerc) + { + this.areaAlphaPerc=areaAlphaPerc; + } + public float getSectorAlphaAmt() + { + return sectorAlphaAmt; + } + public void setSectorAlphaAmt(float sectorAlphaAmt) + { + this.sectorAlphaAmt=sectorAlphaAmt; + } + public float getGroupAlphaAmt() + { + return groupAlphaAmt; + } + public void setGroupAlphaAmt(float groupAlphaAmt) + { + this.groupAlphaAmt=groupAlphaAmt; + } + public float getAreaAlphaAmt() + { + return areaAlphaAmt; + } + public void setAreaAlphaAmt(float areaAlphaAmt) + { + this.areaAlphaAmt=areaAlphaAmt; + } + public float getAbReturnAmt() + { + return abReturnAmt; + } + public void setAbReturnAmt(float abReturnAmt) + { + this.abReturnAmt=abReturnAmt; + } + public float getAbReturnPerc() + { + return abReturnPerc; + } + public void setAbReturnPerc(float abReturnPerc) + { + this.abReturnPerc=abReturnPerc; + } + public float getIntradayPerc() + { + return intradayPerc; + } + public void setIntradayPerc(float intradayPerc) + { + this.intradayPerc=intradayPerc; + } + public float getIntradayAmt() + { + return intradayAmt; + } + public void setIntradayAmt(float intradayAmt) + { + this.intradayAmt=intradayAmt; + } + public float getOptionalityAmt() + { + return optionalityAmt; + } + public void setOptionalityAmt(float optionalityAmt) + { + this.optionalityAmt=optionalityAmt; + } + public float getOptionalityPerc() + { + return optionalityPerc; + } + public void setOptionalityPerc(float optionalityPerc) + { + this.optionalityPerc=optionalityPerc; + } + public String getCurrency() + { + return currency; + } + public void setCurrency(String currency) + { + this.currency=currency; + } + public float getBaseClose() + { + return baseClose; + } + public void setBaseClose(float baseClose) + { + this.baseClose=baseClose; + } + public float getYBaseClose() + { + return yBaseClose; + } + public void setYBaseClose(float yBaseClose) + { + this.yBaseClose=yBaseClose; + } + public float getFxPerc() + { + return fxPerc; + } + public void setFxPerc(float fxPerc) + { + this.fxPerc=fxPerc; + } + public float getFxAmt() + { + return fxAmt; + } + public void setFxAmt(float fxAmt) + { + this.fxAmt=fxAmt; + } + public float getFxRate() + { + return fxRate; + } + public void setFxRate(float fxRate) + { + this.fxRate=fxRate; + } + public float getYFxRate() + { + return yFxRate; + } + public void setYFxRate(float yFxRate) + { + this.yFxRate=yFxRate; + } + public float getAltIndexReturnPerc() + { + return altIndexReturnPerc; + } + public void setAltIndexReturnPerc(float altIndexReturnPerc) + { + this.altIndexReturnPerc=altIndexReturnPerc; + } + public float getAltIndexReturnAmt() + { + return altIndexReturnAmt; + } + public void setAltIndexReturnAmt(float altIndexReturnAmt) + { + this.altIndexReturnAmt=altIndexReturnAmt; + } + public float getIndexBetaAdjPerc() + { + return indexBetaAdjPerc; + } + public void setIndexBetaAdjPerc(float indexBetaAdjPerc) + { + this.indexBetaAdjPerc=indexBetaAdjPerc; + } + public float getIndexBetaAdjAmt() + { + return indexBetaAdjAmt; + } + public void setIndexBetaAdjAmt(float indexBetaAdjAmt) + { + this.indexBetaAdjAmt=indexBetaAdjAmt; + } + public float getVwap() + { + return vwap; + } + public void setVwap(float vwap) + { + this.vwap=vwap; + } + public float getVwapPnl() + { + return vwapPnl; + } + public void setVwapPnl(float vwapPnl) + { + this.vwapPnl=vwapPnl; + } + public float getHedgeAlphaAmt() + { + return hedgeAlphaAmt; + } + public void setHedgeAlphaAmt(float hedgeAlphaAmt) + { + this.hedgeAlphaAmt=hedgeAlphaAmt; + } + public String getExposureView() + { + return exposureView; + } + public void setExposureView(String exposureView) + { + this.exposureView=exposureView; + } + public String getMarketView() + { + return marketView; + } + public void setMarketView(String marketView) + { + this.marketView=marketView; + } + public String getCallPut() + { + return callPut; + } + public void setCallPut(String callPut) + { + this.callPut=callPut; + } + public String get[month]() + { + return [month]; + } + public void set[month](String [month]) + { + this.[month]=[month]; + } + public boolean getPrivate() + { + return private; + } + public void setPrivate(boolean private) + { + this.private=private; + } + public boolean getIpo() + { + return ipo; + } + public void setIpo(boolean ipo) + { + this.ipo=ipo; + } + public float getRatio() + { + return ratio; + } + public void setRatio(float ratio) + { + this.ratio=ratio; + } + public String getSource() + { + return source; + } + public void setSource(String source) + { + this.source=source; + } + public Timestamp getGoAround() + { + return goAround; + } + public void setGoAround(Timestamp goAround) + { + this.goAround=goAround; + } + public float getAdh() + { + return adh; + } + public void setAdh(float adh) + { + this.adh=adh; + } + public float getAac() + { + return aac; + } + public void setAac(float aac) + { + this.aac=aac; + } + public float getAzap() + { + return azap; + } + public void setAzap(float azap) + { + this.azap=azap; + } + public boolean getExported() + { + return exported; + } + public void setExported(boolean exported) + { + this.exported=exported; + } + public float getHedgeAlphaPerc() + { + return hedgeAlphaPerc; + } + public void setHedgeAlphaPerc(float hedgeAlphaPerc) + { + this.hedgeAlphaPerc=hedgeAlphaPerc; + } + public float getAlphaGoAround() + { + return alphaGoAround; + } + public void setAlphaGoAround(float alphaGoAround) + { + this.alphaGoAround=alphaGoAround; + } + public float getAlphaReal() + { + return alphaReal; + } + public void setAlphaReal(float alphaReal) + { + this.alphaReal=alphaReal; + } + public float getAlphaUnreal() + { + return alphaUnreal; + } + public void setAlphaUnreal(float alphaUnreal) + { + this.alphaUnreal=alphaUnreal; + } + public float getPnlReal() + { + return pnlReal; + } + public void setPnlReal(float pnlReal) + { + this.pnlReal=pnlReal; + } + public float getPnlUnreal() + { + return pnlUnreal; + } + public void setPnlUnreal(float pnlUnreal) + { + this.pnlUnreal=pnlUnreal; + } + public float getCashFlow() + { + return cashFlow; + } + public void setCashFlow(float cashFlow) + { + this.cashFlow=cashFlow; + } + public float getBetaCashFlow() + { + return betaCashFlow; + } + public void setBetaCashFlow(float betaCashFlow) + { + this.betaCashFlow=betaCashFlow; + } + public Timestamp getLastTradeDate() + { + return lastTradeDate; + } + public void setLastTradeDate(Timestamp lastTradeDate) + { + this.lastTradeDate=lastTradeDate; + } + public float getLastTradeQty() + { + return lastTradeQty; + } + public void setLastTradeQty(float lastTradeQty) + { + this.lastTradeQty=lastTradeQty; + } + public float getEnterpriseValue() + { + return enterpriseValue; + } + public void setEnterpriseValue(float enterpriseValue) + { + this.enterpriseValue=enterpriseValue; + } + public String getAssociate() + { + return associate; + } + public void setAssociate(String associate) + { + this.associate=associate; + } +}; diff --git a/ClassGen/HistoricDA.cs b/ClassGen/HistoricDA.cs new file mode 100644 index 0000000..856df25 --- /dev/null +++ b/ClassGen/HistoricDA.cs @@ -0,0 +1,153 @@ +using System; +using System.Collections; +using System.Data.SqlClient; + +namespace ZBI.Risk.Server.Mapped +{ + public class HistoricDA + { + public ArrayList readAll() + { + SqlConnection sqlConnection=null; + SqlDataReader sqlDataReader=null; + SqlCommand sqlCommand=null; + try + { + ArrayList arrayList=new ArrayList(); + string strQuery="select trade_date, trade_date_txt, portfolio, sub_portfolio, ticker, ticker_desc, uticker, instrument, contract_size, hedge_index, hedge_sector, area, area_sector, y_close, uticker_close, y_uticker_close, delta, y_delta, hedge_beta, area_beta, sector_beta, group_beta, qty, y_qty, qty_change, hedge_close, hedge_perc, area_close, area_perc, sector_close, sector_perc, mkt_value, y_mkt_value, exposure, y_exposure, hb_exposure, y_hb_exposure, ab_exposure, y_ab_exposure, sb_exposure, y_sb_exposure, pnl, pnl_perc, price_change, price_change_perc, price_change_amt, sector_alpha_perc, group_alpha_perc, area_alpha_perc, hedge_alpha_perc, area_pnl_amt, sector_pnl_amt, sector_alpha_amt, group_alpha_amt, area_alpha_amt, hedge_alpha_amt, ab_return_amt, ab_return_perc, alt_index_return_perc, alt_index_return_amt, index_beta_adj_perc, index_beta_adj_amt, intraday_perc, intraday_amt, optionality_perc, optionality_amt, currency, base_close, y_base_close, fx_perc, fx_amt, fx_rate, y_fx_rate, exposure_view, market_view, call_put, days_expire, strike_price, associate, ipo, ratio, exported, source, vwap, vwap_pnl, adh, aac, azap, go_around, alpha_go_around, alpha_real, alpha_unreal, pnl_real, pnl_unreal, cash_flow, beta_cash_flow, last_trade_date, last_trade_qty, enterprise_value, mkt_cap, wgt_ave, volume, RowID from dt_main_positions"; + sqlConnection=createSqlConnection(DRMS,dt_main_positions,"sa",""); + sqlCommand=new SqlCommand(strQuery,sqlConnection); + sqlDataReader=sqlCommand.ExecuteReader(); + while(sqlDataReader.Read()) + { + Historic historic=new Historic(); + historic.TradeDate=sqlDataReader.getDateTime(0); + historic.TradeDateTxt=sqlDataReader.getString(1); + historic.Portfolio=sqlDataReader.getString(2); + historic.SubPortfolio=sqlDataReader.getString(3); + historic.Ticker=sqlDataReader.getString(4); + historic.TickerDesc=sqlDataReader.getString(5); + historic.Uticker=sqlDataReader.getString(6); + historic.Instrument=sqlDataReader.getString(7); + historic.ContractSize=sqlDataReader.getDecimal(8); + historic.HedgeIndex=sqlDataReader.getString(9); + historic.HedgeSector=sqlDataReader.getString(10); + historic.Area=sqlDataReader.getString(11); + historic.AreaSector=sqlDataReader.getString(12); + historic.YClose=sqlDataReader.getDecimal(13); + historic.UtickerClose=sqlDataReader.getDecimal(14); + historic.YUtickerClose=sqlDataReader.getDecimal(15); + historic.Delta=sqlDataReader.getDecimal(16); + historic.YDelta=sqlDataReader.getDecimal(17); + historic.HedgeBeta=sqlDataReader.getDecimal(18); + historic.AreaBeta=sqlDataReader.getDecimal(19); + historic.SectorBeta=sqlDataReader.getDecimal(20); + historic.GroupBeta=sqlDataReader.getDecimal(21); + historic.Qty=sqlDataReader.getDecimal(22); + historic.YQty=sqlDataReader.getDecimal(23); + historic.QtyChange=sqlDataReader.getDecimal(24); + historic.HedgeClose=sqlDataReader.getDecimal(25); + historic.HedgePerc=sqlDataReader.getDecimal(26); + historic.AreaClose=sqlDataReader.getDecimal(27); + historic.AreaPerc=sqlDataReader.getDecimal(28); + historic.SectorClose=sqlDataReader.getDecimal(29); + historic.SectorPerc=sqlDataReader.getDecimal(30); + historic.MktValue=sqlDataReader.getDecimal(31); + historic.YMktValue=sqlDataReader.getDecimal(32); + historic.Exposure=sqlDataReader.getDecimal(33); + historic.YExposure=sqlDataReader.getDecimal(34); + historic.HbExposure=sqlDataReader.getDecimal(35); + historic.YHbExposure=sqlDataReader.getDecimal(36); + historic.AbExposure=sqlDataReader.getDecimal(37); + historic.YAbExposure=sqlDataReader.getDecimal(38); + historic.SbExposure=sqlDataReader.getDecimal(39); + historic.YSbExposure=sqlDataReader.getDecimal(40); + historic.Pnl=sqlDataReader.getDecimal(41); + historic.PnlPerc=sqlDataReader.getDecimal(42); + historic.PriceChange=sqlDataReader.getDecimal(43); + historic.PriceChangePerc=sqlDataReader.getDecimal(44); + historic.PriceChangeAmt=sqlDataReader.getDecimal(45); + historic.SectorAlphaPerc=sqlDataReader.getDecimal(46); + historic.GroupAlphaPerc=sqlDataReader.getDecimal(47); + historic.AreaAlphaPerc=sqlDataReader.getDecimal(48); + historic.HedgeAlphaPerc=sqlDataReader.getDecimal(49); + historic.AreaPnlAmt=sqlDataReader.getDecimal(50); + historic.SectorPnlAmt=sqlDataReader.getDecimal(51); + historic.SectorAlphaAmt=sqlDataReader.getDecimal(52); + historic.GroupAlphaAmt=sqlDataReader.getDecimal(53); + historic.AreaAlphaAmt=sqlDataReader.getDecimal(54); + historic.HedgeAlphaAmt=sqlDataReader.getDecimal(55); + historic.AbReturnAmt=sqlDataReader.getDecimal(56); + historic.AbReturnPerc=sqlDataReader.getDecimal(57); + historic.AltIndexReturnPerc=sqlDataReader.getDecimal(58); + historic.AltIndexReturnAmt=sqlDataReader.getDecimal(59); + historic.IndexBetaAdjPerc=sqlDataReader.getDecimal(60); + historic.IndexBetaAdjAmt=sqlDataReader.getDecimal(61); + historic.IntradayPerc=sqlDataReader.getDecimal(62); + historic.IntradayAmt=sqlDataReader.getDecimal(63); + historic.OptionalityPerc=sqlDataReader.getDecimal(64); + historic.OptionalityAmt=sqlDataReader.getDecimal(65); + historic.Currency=sqlDataReader.getString(66); + historic.BaseClose=sqlDataReader.getDecimal(67); + historic.YBaseClose=sqlDataReader.getDecimal(68); + historic.FxPerc=sqlDataReader.getDecimal(69); + historic.FxAmt=sqlDataReader.getDecimal(70); + historic.FxRate=sqlDataReader.getDecimal(71); + historic.YFxRate=sqlDataReader.getDecimal(72); + historic.ExposureView=sqlDataReader.getString(73); + historic.MarketView=sqlDataReader.getString(74); + historic.CallPut=sqlDataReader.getString(75); + historic.DaysExpire=sqlDataReader.getInt(76); + historic.StrikePrice=sqlDataReader.getDecimal(77); + historic.Associate=sqlDataReader.getString(78); + historic.Ipo=sqlDataReader.getBool(79); + historic.Ratio=sqlDataReader.getDecimal(80); + historic.Exported=sqlDataReader.getBool(81); + historic.Source=sqlDataReader.getString(82); + historic.Vwap=sqlDataReader.getDecimal(83); + historic.VwapPnl=sqlDataReader.getDecimal(84); + historic.Adh=sqlDataReader.getDecimal(85); + historic.Aac=sqlDataReader.getDecimal(86); + historic.Azap=sqlDataReader.getDecimal(87); + historic.GoAround=sqlDataReader.getDateTime(88); + historic.AlphaGoAround=sqlDataReader.getDecimal(89); + historic.AlphaReal=sqlDataReader.getDecimal(90); + historic.AlphaUnreal=sqlDataReader.getDecimal(91); + historic.PnlReal=sqlDataReader.getDecimal(92); + historic.PnlUnreal=sqlDataReader.getDecimal(93); + historic.CashFlow=sqlDataReader.getDecimal(94); + historic.BetaCashFlow=sqlDataReader.getDecimal(95); + historic.LastTradeDate=sqlDataReader.getDateTime(96); + historic.LastTradeQty=sqlDataReader.getDecimal(97); + historic.EnterpriseValue=sqlDataReader.getDecimal(98); + historic.MktCap=sqlDataReader.getDecimal(99); + historic.WgtAve=sqlDataReader.getDecimal(100); + historic.Volume=sqlDataReader.getDecimal(101); + historic.RowID=sqlDataReader.getLong(102); + arrayList.add(historic); + } + return arrayList; + } + finally + { + if(null!=sqlDataReader)sqlDataReader.Close(); + if(null!=sqlConnection)sqlConnection.Close(); + } + } + private static SqlConnection createSqlConnection(string datssource,string database,string username,string password) + { + try + { + string connectionString="Data Source=DRMS;User ID=sa;password="; + SqlConnection connection=new SqlConnection(connectionString); + connection.Open(); + return connection; + } + catch(SqlException exception) + { + Console.WriteLine(exception.ToString()); + return null; + } + } + } +} diff --git a/ClassGen/HistoricDA.java b/ClassGen/HistoricDA.java new file mode 100644 index 0000000..c54940a --- /dev/null +++ b/ClassGen/HistoricDA.java @@ -0,0 +1,154 @@ +package zbi.risk.server.vhi.mapped + + +public class HistoricDA +{ + public List readAll()throws SQLException + { + Statement statement=null; + ResultSet rs=null; + Connection connection=null; + String strQuery=null; + List list=null; + + try + { + Historic historic = new Historic(); + connection=getConnection(); + statement=connection.createStatement(); + list=new ArrayList(); + strQuery="select trade_date, trade_date_txt, portfolio, sub_portfolio, ticker, ticker_desc, uticker, instrument, mkt_cap, wgt_ave, volume, contract_size, hedge_index, hedge_sector, area, area_sector, [close], y_close, uticker_close, y_uticker_close, delta, y_delta, days_expire, strike_price, hedge_beta, area_beta, sector_beta, group_beta, qty, y_qty, qty_change, hedge_close, hedge_perc, area_close, area_perc, sector_close, sector_perc, mkt_value, y_mkt_value, pnl, exposure, y_exposure, hb_exposure, y_hb_exposure, ab_exposure, y_ab_exposure, sb_exposure, y_sb_exposure, area_pnl_amt, sector_pnl_amt, pnl_perc, price_change, price_change_perc, price_change_amt, sector_alpha_perc, group_alpha_perc, area_alpha_perc, sector_alpha_amt, group_alpha_amt, area_alpha_amt, ab_return_amt, ab_return_perc, intraday_perc, intraday_amt, optionality_amt, optionality_perc, currency, base_close, y_base_close, fx_perc, fx_amt, fx_rate, y_fx_rate, alt_index_return_perc, alt_index_return_amt, index_beta_adj_perc, index_beta_adj_amt, vwap, vwap_pnl, hedge_alpha_amt, exposure_view, market_view, call_put, [month], private, ipo, ratio, source, go_around, adh, aac, azap, exported, hedge_alpha_perc, alpha_go_around, alpha_real, alpha_unreal, pnl_real, pnl_unreal, cash_flow, beta_cash_flow, last_trade_date, last_trade_qty, enterprise_value, associate from dt_main_positions"; + rs=statement.executeQuery(strQuery); + while(rs.next()) + { + historic.setTradeDate(rs.getTimestamp("trade_date")); + historic.setTradeDateTxt(rs.getString("trade_date_txt")); + historic.setPortfolio(rs.getString("portfolio")); + historic.setSubPortfolio(rs.getString("sub_portfolio")); + historic.setTicker(rs.getString("ticker")); + historic.setTickerDesc(rs.getString("ticker_desc")); + historic.setUticker(rs.getString("uticker")); + historic.setInstrument(rs.getString("instrument")); + historic.setMktCap(rs.getFloat("mkt_cap")); + historic.setWgtAve(rs.getFloat("wgt_ave")); + historic.setVolume(rs.getFloat("volume")); + historic.setContractSize(rs.getFloat("contract_size")); + historic.setHedgeIndex(rs.getString("hedge_index")); + historic.setHedgeSector(rs.getString("hedge_sector")); + historic.setArea(rs.getString("area")); + historic.setAreaSector(rs.getString("area_sector")); + historic.set[close](rs.getFloat("[close]")); + historic.setYClose(rs.getFloat("y_close")); + historic.setUtickerClose(rs.getFloat("uticker_close")); + historic.setYUtickerClose(rs.getFloat("y_uticker_close")); + historic.setDelta(rs.getFloat("delta")); + historic.setYDelta(rs.getFloat("y_delta")); + historic.setDaysExpire(rs.getInt("days_expire")); + historic.setStrikePrice(rs.getFloat("strike_price")); + historic.setHedgeBeta(rs.getFloat("hedge_beta")); + historic.setAreaBeta(rs.getFloat("area_beta")); + historic.setSectorBeta(rs.getFloat("sector_beta")); + historic.setGroupBeta(rs.getFloat("group_beta")); + historic.setQty(rs.getFloat("qty")); + historic.setYQty(rs.getFloat("y_qty")); + historic.setQtyChange(rs.getFloat("qty_change")); + historic.setHedgeClose(rs.getFloat("hedge_close")); + historic.setHedgePerc(rs.getFloat("hedge_perc")); + historic.setAreaClose(rs.getFloat("area_close")); + historic.setAreaPerc(rs.getFloat("area_perc")); + historic.setSectorClose(rs.getFloat("sector_close")); + historic.setSectorPerc(rs.getFloat("sector_perc")); + historic.setMktValue(rs.getFloat("mkt_value")); + historic.setYMktValue(rs.getFloat("y_mkt_value")); + historic.setPnl(rs.getFloat("pnl")); + historic.setExposure(rs.getFloat("exposure")); + historic.setYExposure(rs.getFloat("y_exposure")); + historic.setHbExposure(rs.getFloat("hb_exposure")); + historic.setYHbExposure(rs.getFloat("y_hb_exposure")); + historic.setAbExposure(rs.getFloat("ab_exposure")); + historic.setYAbExposure(rs.getFloat("y_ab_exposure")); + historic.setSbExposure(rs.getFloat("sb_exposure")); + historic.setYSbExposure(rs.getFloat("y_sb_exposure")); + historic.setAreaPnlAmt(rs.getFloat("area_pnl_amt")); + historic.setSectorPnlAmt(rs.getFloat("sector_pnl_amt")); + historic.setPnlPerc(rs.getFloat("pnl_perc")); + historic.setPriceChange(rs.getFloat("price_change")); + historic.setPriceChangePerc(rs.getFloat("price_change_perc")); + historic.setPriceChangeAmt(rs.getFloat("price_change_amt")); + historic.setSectorAlphaPerc(rs.getFloat("sector_alpha_perc")); + historic.setGroupAlphaPerc(rs.getFloat("group_alpha_perc")); + historic.setAreaAlphaPerc(rs.getFloat("area_alpha_perc")); + historic.setSectorAlphaAmt(rs.getFloat("sector_alpha_amt")); + historic.setGroupAlphaAmt(rs.getFloat("group_alpha_amt")); + historic.setAreaAlphaAmt(rs.getFloat("area_alpha_amt")); + historic.setAbReturnAmt(rs.getFloat("ab_return_amt")); + historic.setAbReturnPerc(rs.getFloat("ab_return_perc")); + historic.setIntradayPerc(rs.getFloat("intraday_perc")); + historic.setIntradayAmt(rs.getFloat("intraday_amt")); + historic.setOptionalityAmt(rs.getFloat("optionality_amt")); + historic.setOptionalityPerc(rs.getFloat("optionality_perc")); + historic.setCurrency(rs.getString("currency")); + historic.setBaseClose(rs.getFloat("base_close")); + historic.setYBaseClose(rs.getFloat("y_base_close")); + historic.setFxPerc(rs.getFloat("fx_perc")); + historic.setFxAmt(rs.getFloat("fx_amt")); + historic.setFxRate(rs.getFloat("fx_rate")); + historic.setYFxRate(rs.getFloat("y_fx_rate")); + historic.setAltIndexReturnPerc(rs.getFloat("alt_index_return_perc")); + historic.setAltIndexReturnAmt(rs.getFloat("alt_index_return_amt")); + historic.setIndexBetaAdjPerc(rs.getFloat("index_beta_adj_perc")); + historic.setIndexBetaAdjAmt(rs.getFloat("index_beta_adj_amt")); + historic.setVwap(rs.getFloat("vwap")); + historic.setVwapPnl(rs.getFloat("vwap_pnl")); + historic.setHedgeAlphaAmt(rs.getFloat("hedge_alpha_amt")); + historic.setExposureView(rs.getString("exposure_view")); + historic.setMarketView(rs.getString("market_view")); + historic.setCallPut(rs.getString("call_put")); + historic.set[month](rs.getString("[month]")); + historic.setPrivate(rs.getBoolean("private")); + historic.setIpo(rs.getBoolean("ipo")); + historic.setRatio(rs.getFloat("ratio")); + historic.setSource(rs.getString("source")); + historic.setGoAround(rs.getTimestamp("go_around")); + historic.setAdh(rs.getFloat("adh")); + historic.setAac(rs.getFloat("aac")); + historic.setAzap(rs.getFloat("azap")); + historic.setExported(rs.getBoolean("exported")); + historic.setHedgeAlphaPerc(rs.getFloat("hedge_alpha_perc")); + historic.setAlphaGoAround(rs.getFloat("alpha_go_around")); + historic.setAlphaReal(rs.getFloat("alpha_real")); + historic.setAlphaUnreal(rs.getFloat("alpha_unreal")); + historic.setPnlReal(rs.getFloat("pnl_real")); + historic.setPnlUnreal(rs.getFloat("pnl_unreal")); + historic.setCashFlow(rs.getFloat("cash_flow")); + historic.setBetaCashFlow(rs.getFloat("beta_cash_flow")); + historic.setLastTradeDate(rs.getTimestamp("last_trade_date")); + historic.setLastTradeQty(rs.getFloat("last_trade_qty")); + historic.setEnterpriseValue(rs.getFloat("enterprise_value")); + historic.setAssociate(rs.getString("associate")); + list.add(historic); + } + return list; + } + finally + { + if(null!=rs)rs.close(); + if(null!=statement)statement.close(); + } + } + private Connection getConnection()throws SQLException + { + try + { + InitialContext jndiCntx=new InitialContext(); + DataSource ds=(DataSource)jndiCntx.lookup("java:DRMS") + jndiCntx.close(); + return ds.getConnection(); + } + catch(NamingException exception) + { + message("[getConnection] Object not found"); + throw new EJBException(exception); + } + } +}; diff --git a/ClassGen/Main.cpp b/ClassGen/Main.cpp new file mode 100644 index 0000000..786c61a --- /dev/null +++ b/ClassGen/Main.cpp @@ -0,0 +1,425 @@ +#include +#include +#include +#include +#include + +class ClassMapper +{ +public: + ClassMapper(); + virtual ~ClassMapper(); + bool createClass(const String &language,const String &packageName,String className,const String &databaseName,const String &tableName,const String &strPathMapFile,const String &strPathTable); +private: + bool loadMapping(const String &strPathMapFile); + bool mapType(const String &type,String &mapped); + bool createCSharpClass(const String &packageName,const String &className,Block &variables); + bool createCSharpDataAccess(const String &packageName,const String &className,const String &instanceName,const String &databaseName,const String &tableName,Block &variables,Block &originals); + bool createJAVAClass(const String &packageName,const String &className,Block &variables); + bool createJAVADataAccess(const String &packageName,const String &className,const String &instanceName,const String &databaseName,const String &tableName,Block &variables,Block &originals); + + String makeHungarian(const String &name); + String makeAccessor(const String &name); + String makeMutator(const String &name); + String makeFirstUpper(const String &name); + String makeFirstLower(const String &name); + Block mNameValuePairs; +}; + +ClassMapper::ClassMapper() +{ +} + +ClassMapper::~ClassMapper() +{ +} + +bool ClassMapper::createClass(const String &language,const String &packageName,String className,const String &databaseName,const String &tableName,const String &strPathMapFile,const String &strPathTable) +{ + File inFile; + String strLine; + String name; + String value; + String instanceName; + Block variables; + Block originals; + int errors=0; + + if(!loadMapping(strPathMapFile))return false; + if(!inFile.open(strPathTable,"rb"))return false; + while(true) + { + inFile.readLine(strLine); + if(strLine.isNull())break; + name=strLine.betweenString(0,' '); + value=strLine.betweenString(' ',' '); + if(!mapType(value,value)) + { + printf("Don't know how to map %s\n",value.str()); + errors++; + continue; + } + variables.insert(&NameValuePair(makeFirstLower(makeHungarian(name)),value)); + originals.insert(&NameValuePair(name,value)); + } + inFile.close(); + if(errors)return false; + if(!variables.size())return false; + instanceName=makeFirstLower(className); + className=makeFirstUpper(className); + if(language=="JAVA") + { + createJAVAClass(packageName,className,variables); + createJAVADataAccess(packageName,className,instanceName,databaseName,tableName,variables,originals);\ + } + else if(language=="C#") + { + createCSharpClass(packageName,className,variables); + createCSharpDataAccess(packageName,className,instanceName,databaseName,tableName,variables,originals);\ + } + printf("generation completed.\n"); + return true; +} + +bool ClassMapper::createCSharpClass(const String &packageName,const String &className,Block &variables) +{ + File outFile; + bool closeNameSpace=false; + + if(!outFile.open(className+String(".cs"),"wb"))return false; + outFile.writeLine("using System;"); + outFile.writeLine("\t"); + outFile.writeLine("\t"); + + if(!packageName.isNull()) + { + outFile.writeLine(String("namespace ")+packageName); + outFile.writeLine("{"); + closeNameSpace=true; + } + outFile.writeLine(" [Serializable]"); + outFile.writeLine(String(" public class ")+className); + outFile.writeLine(" {"); + for(int index=0;index &variables,Block &originals) +{ + File outFile; + String select; + bool closeNameSpace=false; + + if(!outFile.open(className+String("DA")+String(".cs"),"wb"))return false; + outFile.writeLine("using System;"); + outFile.writeLine("using System.Collections;"); + outFile.writeLine("using System.Data.SqlClient;"); + outFile.writeLine("\t"); + if(!packageName.isNull()) + { + outFile.writeLine(String("namespace ")+packageName); + outFile.writeLine("{"); + closeNameSpace=true; + } + outFile.writeLine(String(" public class ")+className+String("DA")); + outFile.writeLine(" {"); + outFile.writeLine(" public ArrayList readAll()"); + outFile.writeLine(" {"); + outFile.writeLine(" SqlConnection sqlConnection=null;"); + outFile.writeLine(" SqlDataReader sqlDataReader=null;"); + outFile.writeLine(" SqlCommand sqlCommand=null;"); + outFile.writeLine(" try"); + outFile.writeLine(" {"); + outFile.writeLine(" ArrayList arrayList=new ArrayList();"); + select=" string strQuery=\"select "; + for(int index=0;index &variables) +{ + File outFile; + + if(!outFile.open(className+String(".java"),"wb"))return false; + if(!packageName.isNull())outFile.writeLine(String("package ")+packageName); + outFile.writeLine("\t"); + outFile.writeLine("\t"); + outFile.writeLine(String("public class ")+className); + outFile.writeLine("{"); + for(int index=0;index &variables,Block &originals) +{ + File outFile; + String select; + + if(!outFile.open(className+String("DA")+String(".java"),"wb"))return false; + if(!packageName.isNull())outFile.writeLine(String("package ")+packageName); + outFile.writeLine("import java.util.*;"); + outFile.writeLine("import javax.naming.*;"); + outFile.writeLine("import java.sql.*;"); + outFile.writeLine("import javax.sql.*;"); + outFile.writeLine("import javax.ejb.*"); + + outFile.writeLine("\t"); + outFile.writeLine("\t"); + + outFile.writeLine(String("public class ")+className+String("DA")); + outFile.writeLine("{"); + outFile.writeLine(" public List readAll()throws SQLException"); + outFile.writeLine(" {"); + outFile.writeLine(" Statement statement=null;"); + outFile.writeLine(" ResultSet rs=null;"); + outFile.writeLine(" Connection connection=null;"); + outFile.writeLine(" String strQuery=null;"); + outFile.writeLine(" List list=null;"); + outFile.writeLine("\t"); + + outFile.writeLine(" try"); + outFile.writeLine(" {"); + outFile.writeLine(String(" ")+className+String(" ")+instanceName+String(" = new ")+className+String("();")); + outFile.writeLine(" connection=getConnection();"); + outFile.writeLine(" statement=connection.createStatement();"); + outFile.writeLine(" list=new ArrayList();"); + select=" strQuery=\"select "; + for(int index=0;index=length)break; + index++; + ch=toupper(name.charAt(index)); + hungarianName+=ch; + } + else hungarianName+=ch; + } + return hungarianName; +} + +String ClassMapper::makeAccessor(const String &name) +{ + String str; + + str+="get"; + str+=toupper(name.charAt(0)); + str+=name.substr(1); + return str; +} + +String ClassMapper::makeMutator(const String &name) +{ + String str; + + str+="set"; + str+=toupper(name.charAt(0)); + str+=name.substr(1); + return str; +} + +String ClassMapper::makeFirstUpper(const String &name) +{ + String str; + str+=toupper(name.charAt(0)); + str+=name.substr(1); + return str; +} + +String ClassMapper::makeFirstLower(const String &name) +{ + String str; + str+=tolower(name.charAt(0)); + str+=name.substr(1); + return str; +} + +int main(int argc,char **argv) +{ + if(8!=argc) + { + printf("USAGE: mapclass \n"); + printf("(ie) mapclass c# zbi.risk.server.vhi.mapped Historic DRMS dt_main_positions c:\\work\\classgen\\mapping.txt c:\\work\\classgen\\table.txt\n"); + printf("where 'table.txt' contains lines of pairs...\n"); + printf("trade_date smalldatetime 4 0\n\n"); + printf("and 'mapping.txt' contains lines of pairs...\n"); + printf("nvarchar=string\n"); + printf("decimal=decimal\n"); + return 0; + } + ClassMapper classMapper; + if(!classMapper.createClass(argv[1],argv[2],argv[3],argv[4],argv[5],argv[6],argv[7]))return 1; + return 0; +} + + diff --git a/ClassGen/NameValuePair.hpp b/ClassGen/NameValuePair.hpp new file mode 100644 index 0000000..226e712 --- /dev/null +++ b/ClassGen/NameValuePair.hpp @@ -0,0 +1,72 @@ +#ifndef _PROTO_NAMEVALUE_HPP_ +#define _PROTO_NAMEVALUE_HPP_ +#ifndef _COMMON_STRING_HPP_ +#include +#endif + +class NameValuePair +{ +public: + NameValuePair(); + NameValuePair(const String &name,const String &value); + const String &getName(void)const; + void setName(const String &name); + const String &getValue(void)const; + void setValue(const String &value); + bool fromString(const String &string); + String toString(void)const; +private: + String mName; + String mValue; +}; + +inline +NameValuePair::NameValuePair() +{ +} + +inline +NameValuePair::NameValuePair(const String &name,const String &value) +: mName(name), mValue(value) +{ +} + +inline +const String &NameValuePair::getName(void)const +{ + return mName; +} + +inline +void NameValuePair::setName(const String &name) +{ + mName=name; +} + +inline +const String &NameValuePair::getValue(void)const +{ + return mValue; +} + +inline +void NameValuePair::setValue(const String &value) +{ + mValue=value; +} + +inline +bool NameValuePair::fromString(const String &string) +{ + if(string.isNull())return false; + mName=string.betweenString(0,'='); + mValue=string.betweenString('=',0); + return true; +} + +inline +String NameValuePair::toString(void)const +{ + return mName+String("=")+mValue; +} +#endif diff --git a/ClassGen/classgen.dsp b/ClassGen/classgen.dsp new file mode 100644 index 0000000..4ab6f39 --- /dev/null +++ b/ClassGen/classgen.dsp @@ -0,0 +1,101 @@ +# Microsoft Developer Studio Project File - Name="classgen" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=classgen - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "classgen.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "classgen.mak" CFG="classgen - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "classgen - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "classgen - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "classgen - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "classgen - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /Gz /MTd /W1 /Gm /GX /ZI /Od /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "STRICT" /D "__FLAT__" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "classgen - Win32 Release" +# Name "classgen - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\Main.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/ClassGen/classgen.dsw b/ClassGen/classgen.dsw new file mode 100644 index 0000000..d7f2cea --- /dev/null +++ b/ClassGen/classgen.dsw @@ -0,0 +1,44 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "classgen"=.\classgen.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name common + End Project Dependency +}}} + +############################################################################### + +Project: "common"=..\common\common.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/ClassGen/classgen.opt b/ClassGen/classgen.opt new file mode 100644 index 0000000..8a15c1f Binary files /dev/null and b/ClassGen/classgen.opt differ diff --git a/ClassGen/classgen.plg b/ClassGen/classgen.plg new file mode 100644 index 0000000..b709e6f --- /dev/null +++ b/ClassGen/classgen.plg @@ -0,0 +1,33 @@ + + +
+

Build Log

+

+--------------------Configuration: classgen - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\WINNT\Profiles\sean\LOCALS~1\Temp\RSP17B.tmp" with contents +[ +/nologo /Gz /MTd /Gm /GX /ZI /Od /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "STRICT" /D "__FLAT__" /Fp"Debug/classgen.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"D:\work\ClassGen\Main.cpp" +] +Creating command line "cl.exe @C:\WINNT\Profiles\sean\LOCALS~1\Temp\RSP17B.tmp" +Creating temporary file "C:\WINNT\Profiles\sean\LOCALS~1\Temp\RSP17C.tmp" with contents +[ +kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/classgen.pdb" /debug /machine:I386 /out:"Debug/classgen.exe" /pdbtype:sept +.\Debug\Main.obj +\work\exe\mscommon.lib +] +Creating command line "link.exe @C:\WINNT\Profiles\sean\LOCALS~1\Temp\RSP17C.tmp" +

Output Window

+Compiling... +Main.cpp +Linking... + + + +

Results

+classgen.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/ClassGen/historic.txt b/ClassGen/historic.txt new file mode 100644 index 0000000..22dbfdd --- /dev/null +++ b/ClassGen/historic.txt @@ -0,0 +1,103 @@ +trade_date smalldatetime 4 0 +trade_date_txt varchar 10 1 +portfolio varchar 30 0 +sub_portfolio varchar 30 0 +ticker varchar 25 0 +ticker_desc varchar 60 1 +uticker varchar 25 0 +instrument varchar 3 0 +contract_size decimal 9 1 +hedge_index varchar 4 1 +hedge_sector varchar 4 1 +area varchar 6 1 +area_sector varchar 6 1 +y_close decimal 9 1 +uticker_close decimal 9 1 +y_uticker_close decimal 9 1 +delta decimal 9 1 +y_delta decimal 9 1 +hedge_beta decimal 5 1 +area_beta decimal 5 1 +sector_beta decimal 5 1 +group_beta decimal 5 1 +qty decimal 9 0 +y_qty decimal 9 0 +qty_change decimal 9 1 +hedge_close decimal 9 1 +hedge_perc decimal 9 1 +area_close decimal 9 1 +area_perc decimal 9 1 +sector_close decimal 9 1 +sector_perc decimal 9 1 +mkt_value decimal 13 1 +y_mkt_value decimal 13 1 +exposure decimal 13 1 +y_exposure decimal 13 1 +hb_exposure decimal 13 1 +y_hb_exposure decimal 13 1 +ab_exposure decimal 13 1 +y_ab_exposure decimal 13 1 +sb_exposure decimal 13 1 +y_sb_exposure decimal 13 1 +pnl decimal 13 1 +pnl_perc decimal 13 1 +price_change decimal 13 1 +price_change_perc decimal 13 1 +price_change_amt decimal 13 1 +sector_alpha_perc decimal 13 1 +group_alpha_perc decimal 13 1 +area_alpha_perc decimal 13 1 +hedge_alpha_perc decimal 13 1 +area_pnl_amt decimal 13 1 +sector_pnl_amt decimal 13 1 +sector_alpha_amt decimal 13 1 +group_alpha_amt decimal 13 1 +area_alpha_amt decimal 13 1 +hedge_alpha_amt decimal 13 1 +ab_return_amt decimal 13 1 +ab_return_perc decimal 13 1 +alt_index_return_perc decimal 13 1 +alt_index_return_amt decimal 13 1 +index_beta_adj_perc decimal 13 1 +index_beta_adj_amt decimal 13 1 +intraday_perc decimal 13 1 +intraday_amt decimal 13 1 +optionality_perc decimal 13 1 +optionality_amt decimal 13 1 +currency varchar 5 1 +base_close decimal 9 1 +y_base_close decimal 9 1 +fx_perc decimal 9 1 +fx_amt decimal 9 1 +fx_rate decimal 9 1 +y_fx_rate decimal 9 1 +exposure_view varchar 5 1 +market_view varchar 5 0 +call_put varchar 4 1 +days_expire int 4 1 +strike_price decimal 9 1 +associate nvarchar 30 1 +ipo bit 1 1 +ratio decimal 9 1 +exported bit 1 0 +source varchar 10 1 +vwap decimal 13 1 +vwap_pnl decimal 13 1 +adh decimal 13 1 +aac decimal 13 1 +azap decimal 13 1 +go_around smalldatetime 4 1 +alpha_go_around decimal 13 1 +alpha_real decimal 13 1 +alpha_unreal decimal 13 1 +pnl_real decimal 13 1 +pnl_unreal decimal 13 1 +cash_flow decimal 13 1 +beta_cash_flow decimal 13 1 +last_trade_date smalldatetime 4 1 +last_trade_qty decimal 9 1 +enterprise_value decimal 13 1 +mkt_cap decimal 13 1 +wgt_ave decimal 9 1 +volume decimal 13 1 +RowID bigint 8 0 \ No newline at end of file diff --git a/ClassGen/mapping.txt b/ClassGen/mapping.txt new file mode 100644 index 0000000..3e9ba4b --- /dev/null +++ b/ClassGen/mapping.txt @@ -0,0 +1,8 @@ +nvarchar=string +decimal=decimal +float=float +varchar=string +smalldatetime=DateTime +int=int +bit=bool +bigint=long diff --git a/ClassGen/scraps.txt b/ClassGen/scraps.txt new file mode 100644 index 0000000..c8a284a --- /dev/null +++ b/ClassGen/scraps.txt @@ -0,0 +1,25 @@ +/* +bool ClassMapper::createResultClass(const String &packageName,const String &className,const String &instanceName,Block &variables,Block &originals) +{ + File outFile; + + if(!outFile.open(className+String("RS")+String(".java"),"wb"))return false; + if(!packageName.isNull())outFile.writeLine(String("package ")+packageName); + outFile.writeLine("\t"); + outFile.writeLine("\t"); + outFile.writeLine("public void processResult()"); + outFile.writeLine("{"); + outFile.writeLine(String(" ")+className+String(" ")+instanceName+String(";")); + outFile.writeLine(" ResultSet rs;"); + outFile.writeLine("// fill in the blanks"); + for(int index=0;index +#include +#include +#include +#include + +int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow) +{ + SplashScreen splashScreen("SPLASH",String(STRING_SPLASHURL),String(STRING_APPNAME)+String(" ")+String(STRING_VERSION)); + splashScreen.perform(); + DiveDlg diveDlg; + diveDlg.perform(); + return false; +} diff --git a/aladin/RCa00848 b/aladin/RCa00848 new file mode 100644 index 0000000..6d8219d Binary files /dev/null and b/aladin/RCa00848 differ diff --git a/aladin/RDa00848 b/aladin/RDa00848 new file mode 100644 index 0000000..e69de29 diff --git a/aladin/aladin.aps b/aladin/aladin.aps new file mode 100644 index 0000000..6619f50 Binary files /dev/null and b/aladin/aladin.aps differ diff --git a/aladin/aladin.bmp b/aladin/aladin.bmp new file mode 100644 index 0000000..9010571 Binary files /dev/null and b/aladin/aladin.bmp differ diff --git a/aladin/aladin.cpp b/aladin/aladin.cpp new file mode 100644 index 0000000..8fffb0e --- /dev/null +++ b/aladin/aladin.cpp @@ -0,0 +1,293 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +Aladin::Aladin() +: mIsOkay(false) +{ + mRawData.size(2046); +} + +Aladin::~Aladin() +{ +} + +bool Aladin::openRaw(const String &strPathFileName) +{ + BYTE header[4]; + FileHandle inFile; + + if(!inFile.open(strPathFileName,FileHandle::Read,FileHandle::ShareRead,FileHandle::Open,FileHandle::Normal))return false; + if(inFile.size()!=mRawData.size()+sizeof(header))return false; + if(!inFile.read(header,sizeof(header)))return false; + if(::memcmp(header,"UUU\0",sizeof(header)))return false; + if(!inFile.read(&mRawData[0],mRawData.size()))return false; + mIsOkay=readRaw(mRawData); + return mIsOkay; +} + +bool Aladin::openLog(const String &strPathFileName) +{ + File inFile; + char header[]={'L','O','G','1'}; + char rdHeader[sizeof(header)]; + + if(!inFile.open(strPathFileName,"rb"))return false; + if(!inFile.read(&rdHeader,sizeof(rdHeader)))return false; + if(::memcmp(rdHeader,header,sizeof(rdHeader)))return false; + if(!mStatus.readFrom(inFile))return false; + if(!mInformation.readFrom(inFile))return false; + if(!mLogBook.readFrom(inFile))return false; + if(!mProfiles.readFrom(inFile))return false; + inFile.close(); + mIsOkay=true; + return true; +} + +bool Aladin::openDevice(const String &port,GUIWindow &parent) +{ + DeviceControlBlock dcb; + CommControl control; + String strCommState; + AppReg appReg; + Block iconNames; + + mIsOkay=false; + if(IDCANCEL==::MessageBox(parent,"Place computer in Log Book mode and press OK to continue.","Prompt",MB_OKCANCEL))return false; + if(port.isNull())return false; + if(!control.open(CommControl::stringToPort(port)))return false; + strCommState+=String("baud=")+appReg.getBaud()+String(" "); + strCommState+=String("parity=")+appReg.getParity()+String(" "); + strCommState+=String("data=")+appReg.getDataBits()+String(" "); + strCommState+=String("stop=")+appReg.getStopBits()+String(" "); + control.setDeviceControlBlock(strCommState); + control.getDeviceControlBlock(dcb); + dcb.dtrControl(DeviceControlBlock::DtrControlEnable); + dcb.rtsControl(DeviceControlBlock::RtsControlDisable); + control.setDeviceControlBlock(dcb); + + iconNames.insert(&String("ASM1")); + iconNames.insert(&String("ASM2")); + iconNames.insert(&String("ASM3")); + iconNames.insert(&String("ASM4")); + iconNames.insert(&String("ASM5")); + iconNames.insert(&String("ASM6")); + iconNames.insert(&String("ASM7")); + iconNames.insert(&String("ASM8")); + iconNames.insert(&String("ASM9")); + iconNames.insert(&String("ASM10")); + Progress progress(parent,"Sync..., (Press ESC to cancel)",iconNames); + progress.range(3); + progress.canCancel(true); + progress.show(true); + progress.setText("Performing sync-point on device..."); + progress++; + while(!(mIsOkay=getControlData(control,progress))) + { + progress.setText("Performing sync-point on device..."); + progress.yieldTask(); + parent.update(); + if(!progress.isOkay())break; + progress.reset(); + progress.range(3); + progress++; + } + progress.destroy(); + ::MessageBeep(0); + ::MessageBox(parent,"Please disconnect the device","Acquisition",MB_OK); + dcb.dtrControl(DeviceControlBlock::DtrControlDisable); + dcb.rtsControl(DeviceControlBlock::RtsControlDisable); + control.setDeviceControlBlock(dcb); + control.close(); + if(mIsOkay)return mIsOkay=readRaw(mRawData); + ::MessageBox(parent,"Capture Failed","Acquisition",MB_OK); + return mIsOkay; +} + +bool Aladin::saveRaw(const String &strPathFileName) +{ + char header[]={'U','U','U','\0'}; + File outFile; + if(!outFile.open(strPathFileName,"wb"))return false; + if(!outFile.write(header,sizeof(header)))return false; + if(!outFile.write(&mRawData[0],mRawData.size()))return false; + return true; +} + +bool Aladin::saveText(const String &strPathFileName) +{ + File outFile; + + if(!outFile.open(strPathFileName,"wb"))return false; + outFile.writeLine("Entry Time Max Depth Bottom Time Surface Time Temperature (C)"); + outFile.writeLine("-----------------------------------------------------------------------"); + for(int index=0;index&)mProfiles)[pIndex]; + outFile.writeLine(" "); + outFile.writeLine(" "); + outFile.writeLine(String("Profile_")+String().fromInt(pIndex+1)); + outFile.writeLine("Time Depth"); + for(int diveIndex=0;diveIndex &body) +{ + if(!mStatus.readFrom(body))return false; + if(!mInformation.readFrom(body))return false; + if(!mProfiles.readFrom(body,mInformation,mStatus))return false; + if(!mLogBook.readFrom(body,mStatus))return false; + return true; +} + +void Aladin::addDiveLog(Worksheet &worksheet,const LogBook &logBook,int startRow,int startCol) +{ + worksheet.setAt(startRow,startCol+(5/2),"DiveLog"); + worksheet.setAt(startRow,startCol,"Entry Time"); + worksheet.setAt(startRow,startCol+1,"Max Depth"); + worksheet.setAt(startRow,startCol+2,"Bottom Time"); + worksheet.setAt(startRow,startCol+3,"Surface Time"); + worksheet.setAt(startRow,startCol+4,"Temperature"); + for(int index=0;index&)profiles)[pIndex]; + sRow=startRow; + String strTitle(String("Profile_")+String().fromInt(pIndex+1)); + worksheet.setAt(sRow++,startCol,strTitle); + worksheet.setAt(sRow,startCol,"Time"); + worksheet.setAt(sRow++,startCol+1,"Depth"); + for(int diveIndex=0;diveIndex +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=aladin - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "aladin.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "aladin.mak" CFG="aladin - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "aladin - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "aladin - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "aladin - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "aladin - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "STRICT" /D "__FLAT__" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib comctl32.lib winmm.lib wsock32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# SUBTRACT LINK32 /incremental:no + +!ENDIF + +# Begin Target + +# Name "aladin - Win32 Release" +# Name "aladin - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\aladin.cpp +# End Source File +# Begin Source File + +SOURCE=.\appreg.cpp +# End Source File +# Begin Source File + +SOURCE=.\divedlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\divelog.cpp +# End Source File +# Begin Source File + +SOURCE=.\diveprofile.cpp +# End Source File +# Begin Source File + +SOURCE=.\graph.cpp +# End Source File +# Begin Source File + +SOURCE=.\information.cpp +# End Source File +# Begin Source File + +SOURCE=.\logbook.cpp +# End Source File +# Begin Source File + +SOURCE=.\Main.cpp +# End Source File +# Begin Source File + +SOURCE=.\profiles.cpp +# End Source File +# Begin Source File + +SOURCE=.\serdlg.cpp +# End Source File +# Begin Source File + +SOURCE=.\splash.cpp +# End Source File +# Begin Source File + +SOURCE=.\status.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\aladin.rc +# End Source File +# Begin Source File + +SOURCE=.\appicon.ico +# End Source File +# Begin Source File + +SOURCE=.\ASM1.ICO +# End Source File +# Begin Source File + +SOURCE=.\ASM10.ICO +# End Source File +# Begin Source File + +SOURCE=.\ASM2.ICO +# End Source File +# Begin Source File + +SOURCE=.\ASM3.ICO +# End Source File +# Begin Source File + +SOURCE=.\ASM4.ICO +# End Source File +# Begin Source File + +SOURCE=.\ASM5.ICO +# End Source File +# Begin Source File + +SOURCE=.\ASM6.ICO +# End Source File +# Begin Source File + +SOURCE=.\ASM7.ICO +# End Source File +# Begin Source File + +SOURCE=.\ASM8.ICO +# End Source File +# Begin Source File + +SOURCE=.\ASM9.ICO +# End Source File +# Begin Source File + +SOURCE=.\flag.ico +# End Source File +# End Group +# End Target +# End Project diff --git a/aladin/aladin.dsw b/aladin/aladin.dsw new file mode 100644 index 0000000..494a428 --- /dev/null +++ b/aladin/aladin.dsw @@ -0,0 +1,194 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "aladin"=.\aladin.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name common + End Project Dependency + Begin Project Dependency + Project_Dep_Name statbar + End Project Dependency + Begin Project Dependency + Project_Dep_Name commctrl + End Project Dependency + Begin Project Dependency + Project_Dep_Name thread + End Project Dependency + Begin Project Dependency + Project_Dep_Name worksht + End Project Dependency + Begin Project Dependency + Project_Dep_Name fileio + End Project Dependency + Begin Project Dependency + Project_Dep_Name engine + End Project Dependency + Begin Project Dependency + Project_Dep_Name bsptree + End Project Dependency + Begin Project Dependency + Project_Dep_Name jpgimg + End Project Dependency + Begin Project Dependency + Project_Dep_Name socket + End Project Dependency + Begin Project Dependency + Project_Dep_Name jpeg6b + End Project Dependency +}}} + +############################################################################### + +Project: "bsptree"=..\bsptree\bsptree.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "commctrl"=..\commctrl\commctrl.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "common"=..\common\common.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "engine"=..\engine\engine.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "fileio"=..\fileio\fileio.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "jpeg6b"="..\..\parts\jpeg-6b\jpeg6b.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "jpgimg"=..\jpgimg\jpgimg.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "socket"=..\socket\socket.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "statbar"=..\statbar\Statbar.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "thread"=..\thread\thread.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "worksht"=..\worksht\WORKSHT.DSP - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/aladin/aladin.h b/aladin/aladin.h new file mode 100644 index 0000000..b0051a6 --- /dev/null +++ b/aladin/aladin.h @@ -0,0 +1,90 @@ +#ifndef _ALADIN_ALADIN_H_ +#define _ALADIN_ALADIN_H_ +#endif + +#define IDC_STATIC -1 + +// MENU DEFINES +#define APPMENU_FILE_EXIT 10000 +#define APPMENU_FILE_OPENDEVICE 10001 +#define APPMENU_FILE_OPENLOG 10002 +#define APPMENU_FILE_IMPORT 10003 +#define APPMENU_FILE_NEW 10004 + +#define APPMENU_FILE_SAVEWORKSHEET 10010 +#define APPMENU_FILE_SAVERAW 10011 +#define APPMENU_FILE_SAVETEXT 10012 +#define APPMENU_FILE_SAVE 10013 +#define APPMENU_FILE_SAVEGRAPH 10014 + +#define APPMENU_SETTINGS_SERIAL 10020 + +#define APPMENU_HELP_ABOUT 10030 +#define APPMENU_HELP_REGISTER 10031 +#define APPMENU_HELP_HOME 10032 +#define APPMENU_HELP_HELP 10033 +#define APPMENU_HELP_INTERFACES 10034 + +// DIALOG DEFINES +#define DB_NITROX 1000 +#define DB_O2 1001 +#define DB_COMPUTER 1002 +#define DB_STANDARD 1006 +#define DB_BATTERY 1007 +#define DB_LOGLIST 1008 +#define DB_PFLIST 1009 +#define DB_IMPORT 1010 +#define DB_PROFILES 1011 +#define DB_GRAPH 1012 +#define DB_PFBOTTOMTIME 1013 +#define DB_PFMAXDEPTH 1014 + +#define STRING_ALADINKEYNAME 600 +#define STRING_HISTORYKEYNAME 601 +#define STRING_SETTINGSKEYNAME 602 +#define STRING_SERIALKEYNAME 603 +#define STRING_HISTORYKEYSHORTNAME 604 +#define STRING_SETTINGSEMAIL 605 +#define STRING_SERIALPORT 606 +#define STRING_SERIALBAUD 607 +#define STRING_SERIALDATA 608 +#define STRING_SERIALPARITY 609 +#define STRING_SERIALSTOP 610 +#define STRING_COM1 611 +#define STRING_COM2 612 +#define STRING_COM3 613 +#define STRING_COM4 614 +#define STRING_VERSION 615 +#define STRING_APPNAME 616 +#define STRING_HOMEPAGE 617 +#define STRING_REGISTERPAGE 618 +#define STRING_HELPPAGE 619 +#define STRING_BROWSERKEY 620 +#define STRING_BROWSERKEYALT 621 +#define STRING_BROWSERCOMMAND 622 +#define STRING_SPLASHURL 623 +#define STRING_HOST 624 +#define STRING_LINKURL 625 + +#define STRING_CURRENTVERSIONKEYNAME 700 +#define STRING_CURRENTVERSIONNTKEYNAME 701 +#define STRING_PRODUCTNAME 702 +#define STRING_REGISTEREDOWNER 703 +#define STRING_PRODUCTID 704 +#define STRING_VERSIONNUMBER 705 + + + + +// SERIAL DIALOG +#define SERIAL_STOP 104 +#define SERIAL_PARITY 105 +#define SERIAL_APPLY 106 +#define SERIAL_DATA 103 +#define SERIAL_BAUD 102 +#define SERIAL_PORT 101 +#define SERIAL_RESET 107 + + + + diff --git a/aladin/aladin.hpp b/aladin/aladin.hpp new file mode 100644 index 0000000..73390ba --- /dev/null +++ b/aladin/aladin.hpp @@ -0,0 +1,72 @@ +#ifndef _ALADIN_ALADIN_HPP_ +#define _ALADIN_ALADIN_HPP_ +#ifndef _PROTO_STATUS_HPP_ +#include +#endif +#ifndef _ALADIN_INFORMATION_HPP_ +#include +#endif +#ifndef _ALADIN_PROFILES_HPP_ +#include +#endif +#ifndef _ALADIN_PROFILEDATA_HPP_ +#include +#endif +#ifndef _ALADIN_LOGBOOK_HPP_ +#include +#endif +#ifndef _ALADIN_RAWDATA_HPP_ +#include +#endif + +class CommControl; +class GUIWindow; +class Progress; +class Worksheet; + +class Aladin +{ +public: + Aladin(); + virtual ~Aladin(); + bool openRaw(const String &strPathFileName); + bool openDevice(const String &port,GUIWindow &parent); + bool openLog(const String &pathFileName); + bool saveRaw(const String &strPathFileName); + bool saveWorksheet(const String &strPathFileName); + bool saveText(const String &strPathFileName); + bool saveLog(const String &strPathFileName); + const CurrentStatus &getStatus(void)const; + const Information &getInformation(void)const; + const Profiles &getProfile(void)const; + const LogBook &getLogBook(void)const; + void clear(void); + bool isOkay(void)const; +private: + bool readRaw(Array &body); + bool getControlData(CommControl &control,Progress &progress); + void addProfile(Worksheet &worksheet,const Profiles &profiles,int startRow,int startCol); + void addDiveLog(Worksheet &worksheet,const LogBook &logBook,int startRow,int startCol); + + CurrentStatus mStatus; + Information mInformation; + Profiles mProfiles; + LogBook mLogBook; + RawData mRawData; + bool mIsOkay; +}; + +inline +bool Aladin::isOkay(void)const +{ + return mIsOkay; +} + +inline +void Aladin::clear(void) +{ + mProfiles.remove(); + mLogBook.remove(); + mIsOkay=false; +} +#endif \ No newline at end of file diff --git a/aladin/aladin.ncb b/aladin/aladin.ncb new file mode 100644 index 0000000..d10336a Binary files /dev/null and b/aladin/aladin.ncb differ diff --git a/aladin/aladin.opt b/aladin/aladin.opt new file mode 100644 index 0000000..1213ee8 Binary files /dev/null and b/aladin/aladin.opt differ diff --git a/aladin/aladin.plg b/aladin/aladin.plg new file mode 100644 index 0000000..baad13d --- /dev/null +++ b/aladin/aladin.plg @@ -0,0 +1,101 @@ + + +
+

Build Log

+

+--------------------Configuration: aladin - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP23A.tmp" with contents +[ +/nologo /MTd /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "STRICT" /D "__FLAT__" /FR"Debug/" /Fp"Debug/aladin.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +"F:\work\aladin\aladin.cpp" +"F:\work\aladin\appreg.cpp" +"F:\work\aladin\divedlg.cpp" +"F:\work\aladin\divelog.cpp" +"F:\work\aladin\diveprofile.cpp" +"F:\work\aladin\graph.cpp" +"F:\work\aladin\information.cpp" +"F:\work\aladin\logbook.cpp" +"F:\work\aladin\Main.cpp" +"F:\work\aladin\profiles.cpp" +"F:\work\aladin\serdlg.cpp" +"F:\work\aladin\splash.cpp" +"F:\work\aladin\status.cpp" +] +Creating command line "cl.exe @C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP23A.tmp" +

Output Window

+Compiling... +aladin.cpp +appreg.cpp +divedlg.cpp +divelog.cpp +diveprofile.cpp +graph.cpp +information.cpp +logbook.cpp +Main.cpp +profiles.cpp +serdlg.cpp +splash.cpp +status.cpp +Creating temporary file "C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP23B.tmp" with contents +[ +kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib comctl32.lib winmm.lib wsock32.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/aladin.pdb" /debug /machine:I386 /out:"Debug/aladin.exe" /pdbtype:sept +.\Debug\aladin.obj +.\Debug\appreg.obj +.\Debug\divedlg.obj +.\Debug\divelog.obj +.\Debug\diveprofile.obj +.\Debug\graph.obj +.\Debug\information.obj +.\Debug\logbook.obj +.\Debug\Main.obj +.\Debug\profiles.obj +.\Debug\serdlg.obj +.\Debug\splash.obj +.\Debug\status.obj +.\Debug\aladin.res +\work\exe\mscommon.lib +\work\exe\statbar.lib +\work\commctrl\Debug\commctrl.lib +\work\exe\msthread.lib +\work\exe\worksht.lib +\work\exe\msfileio.lib +\work\exe\msengine.lib +\work\exe\msbsp.lib +\work\exe\jpgimg.lib +\work\exe\mssocket.lib +"\parts\jpeg-6b\lib\jpeg6b.lib" +] +Creating command line "link.exe @C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP23B.tmp" +

Output Window

+Linking... + Creating library Debug/aladin.lib and object Debug/aladin.exp +Creating temporary file "C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP23F.tmp" with contents +[ +/nologo /o"Debug/aladin.bsc" +.\Debug\aladin.sbr +.\Debug\appreg.sbr +.\Debug\divedlg.sbr +.\Debug\divelog.sbr +.\Debug\diveprofile.sbr +.\Debug\graph.sbr +.\Debug\information.sbr +.\Debug\logbook.sbr +.\Debug\Main.sbr +.\Debug\profiles.sbr +.\Debug\serdlg.sbr +.\Debug\splash.sbr +.\Debug\status.sbr] +Creating command line "bscmake.exe @C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP23F.tmp" +Creating browse info file... +

Output Window

+ + + +

Results

+aladin.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/aladin/aladin.rc b/aladin/aladin.rc new file mode 100644 index 0000000..1707ee8 --- /dev/null +++ b/aladin/aladin.rc @@ -0,0 +1,289 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +#include "aladin.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +APPICON ICON DISCARDABLE "APPICON.ICO" +ASM1 ICON DISCARDABLE "ASM1.ICO" +ASM2 ICON DISCARDABLE "ASM2.ICO" +ASM3 ICON DISCARDABLE "ASM3.ICO" +ASM4 ICON DISCARDABLE "ASM4.ICO" +ASM5 ICON DISCARDABLE "ASM5.ICO" +ASM6 ICON DISCARDABLE "ASM6.ICO" +ASM7 ICON DISCARDABLE "ASM7.ICO" +ASM8 ICON DISCARDABLE "ASM8.ICO" +ASM9 ICON DISCARDABLE "ASM9.ICO" +ASM10 ICON DISCARDABLE "ASM10.ICO" + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +SPLASH BITMAP MOVEABLE PURE "ALADIN2.BMP" + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +MAINMENU MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New...", APPMENU_FILE_NEW + MENUITEM "&Open Log", APPMENU_FILE_OPENLOG + MENUITEM "Open &Device", APPMENU_FILE_OPENDEVICE + MENUITEM SEPARATOR + MENUITEM "&Import Raw File...", APPMENU_FILE_IMPORT + MENUITEM SEPARATOR + MENUITEM "&Save...", APPMENU_FILE_SAVE + MENUITEM "Save As (.&wk1)...", APPMENU_FILE_SAVEWORKSHEET + MENUITEM "Save As &Raw...", APPMENU_FILE_SAVERAW + MENUITEM "Save As &Text...", APPMENU_FILE_SAVETEXT + MENUITEM SEPARATOR + MENUITEM "E&xit", APPMENU_FILE_EXIT + END + POPUP "&Settings" + BEGIN + MENUITEM "&Serial...", APPMENU_SETTINGS_SERIAL + END + POPUP "&Help" + BEGIN + MENUITEM "&Help...", APPMENU_HELP_HELP + MENUITEM "H&ome...", APPMENU_HELP_HOME + MENUITEM "&Registration...", APPMENU_HELP_REGISTER + MENUITEM SEPARATOR + MENUITEM "&About...", APPMENU_HELP_ABOUT + MENUITEM "About &interfaces...", APPMENU_HELP_INTERFACES + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +SERIAL DIALOG DISCARDABLE 6, 15, 207, 111 +STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | + WS_SYSMENU +CAPTION "Serial Setup" +FONT 6, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,153,3,50,14 + PUSHBUTTON "Cancel",IDCANCEL,153,18,50,14 + PUSHBUTTON "Reset",SERIAL_RESET,153,32,50,14 + COMBOBOX SERIAL_BAUD,30,24,49,50,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + COMBOBOX SERIAL_DATA,30,37,49,50,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + COMBOBOX SERIAL_PARITY,30,63,49,50,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + COMBOBOX SERIAL_PORT,30,11,49,50,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + LTEXT "Port:",-1,3,14,18,8 + LTEXT "Baud:",-1,3,27,21,8 + LTEXT "Data:",-1,3,40,20,8 + LTEXT "Stop:",-1,4,53,19,8 + LTEXT "Parity:",-1,3,65,19,8 + COMBOBOX SERIAL_STOP,30,50,49,50,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + PUSHBUTTON "Apply",SERIAL_APPLY,153,46,50,14 +END + +DIVEBOOK DIALOG DISCARDABLE 0, 0, 347, 226 +STYLE DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | + WS_CAPTION | WS_SYSMENU +CAPTION "DiveBook" +MENU MAINMENU +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,1,1,364,1 + LTEXT "Computer:",IDC_STATIC,5,7,33,8 + CONTROL "Nitrox",DB_NITROX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 215,6,34,10 + CONTROL "O2",DB_O2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,215,18, + 25,10 + EDITTEXT DB_COMPUTER,42,4,136,14,ES_AUTOHSCROLL | ES_READONLY + LISTBOX DB_LOGLIST,3,126,336,94,LBS_OWNERDRAWFIXED | + LBS_HASSTRINGS | LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | + WS_VSCROLL | WS_TABSTOP + LTEXT "Standard:",IDC_STATIC,116,24,32,8 + EDITTEXT DB_STANDARD,154,22,40,14,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Remaining Battery:",IDC_STATIC,5,24,60,8 + EDITTEXT DB_BATTERY,69,22,40,14,ES_AUTOHSCROLL | ES_READONLY + CTEXT "Date",IDC_STATIC,10,113,66,11,SS_CENTERIMAGE + CTEXT "Max Depth (ft.)",IDC_STATIC,110,113,55,11 + CTEXT "Bottom Time (mins.)",IDC_STATIC,172,113,63,11 + LTEXT "Interval (hh:mm)",IDC_STATIC,242,113,53,11 + COMBOBOX DB_PROFILES,4,60,61,48,CBS_DROPDOWNLIST | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + LISTBOX DB_PFLIST,69,60,108,48,LBS_OWNERDRAWFIXED | + LBS_HASSTRINGS | LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | + WS_VSCROLL | WS_TABSTOP + LTEXT "Dive Profiles",IDC_STATIC,12,47,48,8 + LTEXT "Time (secs.)",IDC_STATIC,75,50,39,8 + LTEXT "Depth (ft.)",IDC_STATIC,128,50,32,8 + LTEXT "Temp (C)",IDC_STATIC,297,113,30,8 + CONTROL "",DB_GRAPH,"Button",BS_OWNERDRAW | BS_BITMAP | + WS_TABSTOP,189,45,141,63 + LTEXT "Max Depth:",IDC_STATIC,3,76,38,8 + LTEXT "Bottom Time:",IDC_STATIC,3,90,42,8 + EDITTEXT DB_PFBOTTOMTIME,47,88,20,14,ES_AUTOHSCROLL | ES_READONLY + EDITTEXT DB_PFMAXDEPTH,47,74,19,14,ES_AUTOHSCROLL | ES_READONLY +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""aladin.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + "SERIAL", DIALOG + BEGIN + RIGHTMARGIN, 203 + END + + "DIVEBOOK", DIALOG + BEGIN + RIGHTMARGIN, 342 + BOTTOMMARGIN, 193 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + STRING_ALADINKEYNAME "Software\\Diversified\\Aladin" + STRING_HISTORYKEYNAME "Software\\Diversified\\Aladin\\History" + STRING_SERIALKEYNAME "Software\\Diversified\\Aladin\\Serial" + STRING_HISTORYKEYSHORTNAME "History" + STRING_SETTINGSEMAIL "EMAIL" + STRING_SERIALPORT "Port" + STRING_SERIALBAUD "Baud" +END + +STRINGTABLE DISCARDABLE +BEGIN + STRING_HOST "http://www.diversified-software.com" + STRING_LINKURL "http://www.tele.ucl.ac.be/PEOPLE/DOUXCHAMPS/aladin/english/home.html" +END + +STRINGTABLE DISCARDABLE +BEGIN + STRING_SERIALDATA "Data" + STRING_SERIALPARITY "Parity" + STRING_SERIALSTOP "Stop" + STRING_COM1 "COM1" + STRING_COM2 "COM2" + STRING_COM3 "COM3" + STRING_COM4 "COM4" + STRING_VERSION "v1.02" + STRING_APPNAME "Aladin" + STRING_HOMEPAGE "/DivePlanner/DivePlanner.html" + STRING_REGISTERPAGE "/DivePlanner/Aladin/Register.html" + STRING_HELPPAGE "/DivePlanner/Aladin/Help.html" + STRING_BROWSERKEY "Software\\Classes\\htmlfile\\shell\\opennew\\command" + STRING_BROWSERKEYALT "SOFTWARE\\Classes\\http\\shell\\open\\command" + STRING_BROWSERCOMMAND "command" + STRING_SPLASHURL "http://www.diversified-software.com" +END + +STRINGTABLE DISCARDABLE +BEGIN + STRING_CURRENTVERSIONKEYNAME + "Software\\Microsoft\\Windows\\CurrentVersion" + STRING_CURRENTVERSIONNTKEYNAME + "Software\\Microsoft\\Windows NT\\CurrentVersion" + STRING_PRODUCTNAME "ProductName" + STRING_REGISTEREDOWNER "RegisteredOwner" +END + +STRINGTABLE DISCARDABLE +BEGIN + STRING_PRODUCTID "ProductId" + STRING_VERSIONNUMBER "VersionNumber" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/aladin/aladin2.bmp b/aladin/aladin2.bmp new file mode 100644 index 0000000..1049613 Binary files /dev/null and b/aladin/aladin2.bmp differ diff --git a/aladin/aladinrc.hpp b/aladin/aladinrc.hpp new file mode 100644 index 0000000..c495d29 --- /dev/null +++ b/aladin/aladinrc.hpp @@ -0,0 +1,6 @@ +#ifndef _ALADIN_ALADINRC_HPP_ +#define _ALADIN_ALADINRC_HPP_ +#ifndef _ALADIN_ALADIN_H_ +#include +#endif +#endif diff --git a/aladin/appicon.ico b/aladin/appicon.ico new file mode 100644 index 0000000..ac6311c Binary files /dev/null and b/aladin/appicon.ico differ diff --git a/aladin/appreg.cpp b/aladin/appreg.cpp new file mode 100644 index 0000000..94fa338 --- /dev/null +++ b/aladin/appreg.cpp @@ -0,0 +1,195 @@ +#include +#include + +AppReg::AppReg(void) +: mAladinKeyName(STRING_ALADINKEYNAME), + mSerialKeyName(STRING_SERIALKEYNAME), + mSettingsEMAIL(STRING_SETTINGSEMAIL), + mSerialPort(STRING_SERIALPORT), + mSerialBaud(STRING_SERIALBAUD), + mSerialData(STRING_SERIALDATA), + mSerialParity(STRING_SERIALPARITY), + mSerialStop(STRING_SERIALSTOP), + mHistoryKeyName(STRING_HISTORYKEYNAME), + mHistoryKeyShortName(STRING_HISTORYKEYSHORTNAME), + mRegKeySerial(RegKey::CurrentUser) +{ + guarantee(); + cacheHistory(); +} + +AppReg::AppReg(const AppReg &someAppReg) +: mAladinKeyName(STRING_ALADINKEYNAME), + mSerialKeyName(STRING_SERIALKEYNAME), + mSettingsEMAIL(STRING_SETTINGSEMAIL), + mSerialPort(STRING_SERIALPORT), + mSerialBaud(STRING_SERIALBAUD), + mSerialData(STRING_SERIALDATA), + mSerialParity(STRING_SERIALPARITY), + mSerialStop(STRING_SERIALSTOP), + mRegKeySerial(RegKey::CurrentUser) +{ + *this=someAppReg; +} + +AppReg::~AppReg() +{ +} + +AppReg &AppReg::operator=(const AppReg &/*someAppReg*/) +{ + return *this; +} + +bool AppReg::getHistory(Block &nameList) +{ + nameList=mCachedNames; + return nameList.size()?true:false; +} + +bool AppReg::setHistory(Block &nameList) +{ + RegKey regKey(RegKey::CurrentUser); + mRegKeyHistory.closeKey(); + regKey.openKey(String(STRING_ALADINKEYNAME)); + regKey.deleteKey(mHistoryKeyShortName); + regKey.closeKey(); + mRegKeyHistory.createKey(mHistoryKeyName,""); + mRegKeyHistory.openKey(mHistoryKeyName); + for(int itemIndex=0;itemIndexMaxCachedNames) + { + Block mruCachedNames; + for(int itemIndex=0;itemIndex deviceList; + + commControl.enumerateDevices(deviceList); + mRegKeySerial.createKey(mSerialKeyName,""); + mRegKeySerial.openKey(mSerialKeyName); + setBaud("19200"); + setParity("N"); + setDataBits("8"); + setStopBits("1"); + setPort(deviceList.size()?deviceList[0]:"COM1"); + } + if(!mRegKeyHistory.openKey(mHistoryKeyName)) + { + mRegKeyHistory.createKey(mHistoryKeyName,""); + mRegKeyHistory.openKey(mHistoryKeyName); + } +} + +BOOL AppReg::isOkay(void)const +{ + return mRegKeySerial.isOkay(); +} + diff --git a/aladin/appreg.hpp b/aladin/appreg.hpp new file mode 100644 index 0000000..e3c90ef --- /dev/null +++ b/aladin/appreg.hpp @@ -0,0 +1,57 @@ +#ifndef _ALADIN_APPREG_HPP_ +#define _ALADIN_APPREG_HPP_ +#ifndef _COMMON_REGKEY_HPP_ +#include +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_BLOCK_HPP_ +#include +#endif +#ifndef _ALADIN_ALADINRC_HPP_ +#include +#endif + +class AppReg +{ +public: + AppReg(void); + AppReg(const AppReg &someAppReg); + virtual ~AppReg(); + AppReg &operator=(const AppReg &someAppReg); + bool getHistory(Block &nameList); + bool setHistory(Block &nameList); + bool insertHistory(const String &strName); + bool setBaud(const String &strBaud); + String getBaud(void); + bool setParity(const String &strParity); + String getParity(void); + bool setDataBits(const String &strDataBits); + String getDataBits(void); + bool setStopBits(const String &stopBits); + String getStopBits(void); + bool setPort(const String &strPort); + String getPort(void); + String getSerialSettings(void); + BOOL isOkay(void)const; +private: + enum{MaxCachedNames=7}; + void guarantee(void); + void cacheHistory(void); + + String mHistoryKeyName; + String mHistoryKeyShortName; + String mSerialKeyName; + String mSettingsEMAIL; + String mAladinKeyName; + String mSerialPort; + String mSerialBaud; + String mSerialData; + String mSerialParity; + String mSerialStop; + RegKey mRegKeySerial; + RegKey mRegKeyHistory; + Block mCachedNames; +}; +#endif diff --git a/aladin/bitmanip.hpp b/aladin/bitmanip.hpp new file mode 100644 index 0000000..035aee8 --- /dev/null +++ b/aladin/bitmanip.hpp @@ -0,0 +1,39 @@ +#ifndef _ALADIN_BITMANIP_HPP_ +#define _ALADIN_BITMANIP_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif + +class BitManip +{ +public: + static BYTE reverse(BYTE byte); + static WORD reverse(WORD word); +}; + +inline +BYTE BitManip::reverse(BYTE byte) +{ + BYTE temp=0; + + temp|=(byte&0x80)>>7; + temp|=(byte&0x40)>>5; + temp|=(byte&0x20)>>3; + temp|=(byte&0x10)>>1; + temp|=(byte&0x08)<<1; + temp|=(byte&0x04)<<3; + temp|=(byte&0x02)<<5; + temp|=(byte&0x01)<<7; + return temp; +} + +inline +WORD BitManip::reverse(WORD someData) +{ + WORD tempData(someData); + + someData>>=8; + someData+=tempData<<8; + return someData; +} +#endif \ No newline at end of file diff --git a/aladin/data/aladin.txt b/aladin/data/aladin.txt new file mode 100644 index 0000000..a1d1f2f --- /dev/null +++ b/aladin/data/aladin.txt @@ -0,0 +1,128 @@ +A0 09 64 02 A0 00 00 20 04 20 08 E0 10 09 A0 0A ..d.... . ...... +E0 0A 60 10 09 60 05 64 00 20 00 00 20 FF 52 5F ..`..`.d. .. .R_ +0B 67 0B 6B 0B E6 0B 67 0C 73 0C 0B 0C B8 0B 00 .g.k...g.s...... +00 00 1E 90 04 20 0A A0 10 20 10 13 E0 15 20 19 ..... ... .... . +A0 10 1B E0 1D A0 1E A0 10 1E E0 1D 60 1B 60 10 ............`.`. +1B 60 1D E0 1D E0 10 1F 20 1F 60 1F 20 10 1F 20 .`...... .`. .. +1E A0 1D A0 10 1D E0 1D E0 1D E0 10 1E A0 1E 60 ...............` +1E 60 10 1C E0 1B 60 1A 20 10 17 A0 16 A0 12 E4 .`....`. ....... +18 12 60 16 60 18 E0 10 1A 20 19 E0 17 E0 10 17 ..`.`.... ...... +20 15 60 13 E0 10 11 E0 0E 60 0D 60 10 0B A0 0A .`......`.`.... +A0 0C 20 10 0D E0 0E 20 0F 20 10 0F 60 0F A0 0E .. .... . ..`... +60 10 0D 60 0B A0 08 E0 10 07 24 04 60 03 A0 10 `..`......$.`... +00 60 00 20 00 20 00 00 20 00 20 00 20 00 00 E0 .`. . .. . . ... +00 20 00 20 00 FF 45 70 0B 70 0B 70 0B 70 0B 70 . . ..Ep.p.p.p.p +0B 70 0B 70 0B 70 0B 00 00 00 21 90 02 E0 03 20 .p.p.p....!.... +03 E0 10 04 20 04 60 04 60 10 05 E0 06 20 06 60 .... .`.`.... .` +10 06 60 06 E0 07 20 10 07 20 07 20 07 20 10 06 ..`... .. . . .. +E0 07 60 06 E0 10 06 60 06 E0 06 A0 10 05 E0 05 ..`....`........ +20 04 E0 10 04 A0 04 60 04 E0 10 04 60 04 A0 03 ......`....`... +E0 10 04 20 03 A0 02 E0 10 02 E0 00 20 00 20 00 ... ........ . . +02 60 03 60 04 60 10 04 E0 05 20 04 E0 10 05 20 .`.`.`.... .... +05 60 05 E0 10 06 60 06 20 04 A0 10 05 A0 05 60 .`....`. ......` +05 20 10 05 60 05 A0 05 20 10 05 20 05 A0 05 A0 . ..`... .. .... +10 05 A0 05 E0 05 E0 18 06 20 05 A0 05 E0 10 05 ......... ...... +A0 05 20 05 60 10 05 20 04 E0 04 A0 10 04 A0 04 .. .`.. ........ +20 04 20 10 03 E0 03 A0 03 A0 10 04 20 04 60 04 . ......... .`. +60 10 04 A0 04 A0 04 E0 10 04 E0 04 E0 03 E0 10 `............... +03 A0 02 E0 02 A0 10 01 E0 00 20 00 20 00 00 20 .......... . .. +00 E0 00 20 00 00 20 00 20 00 20 00 00 20 00 20 ... .. . . .. . +00 20 00 00 20 00 20 00 20 00 00 20 00 20 00 20 . .. . . .. . . +00 00 20 0B 70 0B 70 0B 70 0B 70 0B 70 0B 70 0B .. .p.p.p.p.p.p. +70 0B 00 00 00 40 90 0B A0 16 20 19 60 10 1A E0 p....@.... .`... +1B 20 19 20 10 1A E0 1C A0 1D A0 10 23 E0 29 20 . . ........#.) +2A A0 10 30 60 34 60 35 A0 10 32 60 2E A0 2D A0 *..0`4`5..2`..-. +10 2D 60 2C 60 2B E0 10 29 20 29 A0 2A 60 10 29 .-`,`+..) ).*`.) +E0 28 E0 29 20 10 2A 60 2B 20 2A A0 10 28 60 25 .(.) .*`+ *..(`% +A0 24 A0 10 22 20 1F 60 1F A0 10 1E A0 1B E0 19 .$.." .`........ +E0 10 1A A0 1C A0 1C 20 10 1A E0 1C E0 1C E0 10 ....... ........ +1C 20 1D E0 1D E0 10 1D 20 1C E0 1B A0 10 1C 60 . ...... ......` +1A E0 1A 60 10 1A 60 1A 60 19 A0 10 19 E0 1A 20 ...`..`.`...... +19 60 10 19 A0 1D 20 1E A0 10 1E A4 1C E0 1D 20 .`.... ........ +10 1B 20 19 60 1A 60 10 1B A0 1B A0 1C 60 10 1C .. .`.`......`.. +E0 1C 60 1D 20 10 1D E0 1D 20 1D A4 10 1B A0 18 ..`. .... ...... +E0 16 20 10 13 20 0F E0 0E 20 10 0C 60 0B E0 0A .. .. ... ..`... +64 10 07 20 08 60 0A A0 10 0B 20 0B 60 0A A0 10 d.. .`.... .`... +08 A0 08 A0 09 20 10 08 E4 01 E0 00 20 00 00 20 ..... ...... .. +FF 68 72 0B D4 0B 16 0E 62 10 4F 0F EA 0D C8 0C .hr.....b.O..... +1F 0C 06 00 49 A7 80 08 20 0F 60 15 E0 10 16 60 ....I... .`....` +15 E0 15 24 10 11 A0 13 60 13 E0 10 12 E0 13 60 ...$....`......` +13 E0 10 12 E0 11 E0 12 20 10 12 E0 12 A0 12 E0 ........ ....... +10 12 E0 14 A0 15 20 10 14 E0 14 20 13 A0 10 13 ...... .... .... +E0 13 E0 13 60 10 14 A0 14 60 13 E0 10 15 20 16 ....`....`.... . +60 16 A0 10 14 E0 13 20 15 A0 10 15 60 15 60 15 `...... ....`.`. +60 10 15 A0 15 60 15 60 10 12 20 12 E0 12 E0 10 `....`.`.. ..... +13 60 13 64 0F 60 10 10 20 11 60 0E E0 10 0E 60 .`.d.`.. .`....` +0E A0 0E E0 10 0E E0 0F 20 0E 60 10 0E A0 0D 60 ........ .`....` +0E 20 10 0E A0 0E 60 0E 60 10 0E 20 11 A0 11 A0 . ....`.`.. .... +10 12 A0 14 20 14 A0 10 16 20 16 E0 17 E0 10 17 .... .... ...... +E0 18 20 18 20 10 17 E0 18 20 17 E0 10 17 E0 17 .. . .... ...... +E0 17 E0 10 17 A0 17 A0 17 A0 10 16 20 16 E0 17 ............ ... +20 10 16 A0 16 60 15 E0 10 15 20 14 60 14 60 10 ....`.... .`.`. +15 60 13 A0 12 24 10 11 E0 15 E0 15 E0 10 15 60 .`...$.........` +14 E0 14 E0 10 13 60 12 20 12 60 10 10 20 11 60 ......`. .`.. .` +11 60 10 0E A0 0D 20 09 60 10 05 E4 04 60 04 A0 .`.... .`....`.. +10 07 A0 07 E0 07 60 10 08 E0 05 A4 00 E0 10 00 ......`......... +A0 00 20 00 20 00 FF 69 73 0B 71 0B 70 0B 70 0B .. . ..is.q.p.p. +70 0B 70 0B 90 0B 70 0B 00 00 00 40 90 07 60 07 p.p...p....@..`. +E0 06 E0 10 07 20 0B E0 0D E0 10 0D 60 0E 60 0F ..... ......`.`. +20 10 0E E0 0E E0 0E E0 10 0F 20 0F 60 0F A0 10 ......... .`... +11 20 12 60 12 A0 10 12 20 12 E0 13 20 10 12 E0 . .`.... ... ... +10 64 0D E0 10 10 60 13 A0 13 E0 10 13 E0 10 A0 .d....`......... +0D 60 10 10 A0 12 E0 13 E0 10 13 E0 12 20 10 A4 .`........... .. +10 0D 24 0A 20 0D E0 10 0F 60 0F E0 0F E0 10 0E ..$. ....`...... +E0 0D A4 08 E4 10 09 A0 0B A0 0D 20 10 0D A0 0D ........... .... +20 0A A0 10 07 E0 07 A0 06 E0 10 06 20 06 60 06 ........... .`. +60 10 05 A0 05 60 05 60 10 05 A0 05 20 04 60 10 `....`.`.... .`. +00 E0 02 20 00 20 00 00 20 00 20 00 E0 00 04 A0 ... . .. . ..... +05 20 05 60 10 05 E0 05 E0 06 20 10 06 60 07 60 . .`...... ..`.` +07 20 10 06 E0 07 20 07 20 10 07 E0 07 E0 08 20 . .... . ...... +10 08 60 06 20 08 A0 10 06 E4 01 60 05 A0 10 07 ..`. ......`.... +A0 06 E0 06 A0 10 06 60 05 60 05 A0 10 05 A4 04 .......`.`...... +A0 04 E0 10 05 20 04 A0 04 A0 10 04 60 04 60 04 ..... ......`.`. +20 10 03 E0 01 20 00 A0 00 00 20 00 E0 00 20 00 .... .... ... . +00 20 FF 4C 70 0B 70 0B 70 0B 70 0B 70 0B 70 0B . .Lp.p.p.p.p.p. +70 0B 70 0B 00 00 00 EA 80 08 20 0D 20 0D 20 10 p.p....... . . . +0C E0 0D A0 10 E0 10 12 20 11 A0 11 E0 10 12 60 ........ ......` +14 60 15 E0 10 17 20 1A 20 1C 60 10 1B 60 1B 20 .`.... . .`..`. +1D 60 10 1D E0 1D 20 1C 20 10 1D 20 1D 20 1D 60 .`.... . .. . .` +10 1D 60 1E A0 1F 20 10 1E 60 1E A0 1E A0 10 1D ..`... ..`...... +E0 1C E0 1C 60 18 1C 60 1C 20 1E 20 10 1D E0 1E ....`..`. . .... +60 1E 60 10 1E 20 1D A0 1C 60 10 1A 60 1C 20 1C `.`.. ...`..`. . +E0 10 1D 60 1D A0 1C 60 10 18 E0 15 E0 12 E0 10 ...`...`........ +10 60 10 20 0C E0 18 0A E0 0A 60 09 20 10 09 24 .`. ......`. ..$ +0B 20 0A E0 10 09 20 0A E0 0A 20 10 07 A0 07 20 . .... ... .... +05 A0 10 04 20 01 60 00 20 00 00 20 00 20 04 20 .... .`. .. . . +10 0A E0 0C 20 0C 60 10 0C E0 0C 20 0C A0 10 0A .... .`.... .... +03 32 13 DE 21 09 00 1B 52 3D 1A 67 01 27 1F 36 .2..!...R=.g.'.6 +03 01 00 1C 0D 72 C6 1C 03 19 1F 52 02 24 00 1C .....r.....R.$.. +0D C4 90 16 00 27 07 4E 17 39 00 1C 22 E3 7D 42 .....'.N.9..".}B +02 07 4F FB 00 05 00 0E F2 BC BC 4E 02 18 5F E9 ..O........N.._. +00 05 00 0E F2 C3 4C 4E 00 38 1A 27 02 55 00 18 ......LN.8.'.U.. +62 A5 21 6C 02 45 15 A5 00 54 00 18 62 D3 97 6C b.!l.E...T..b..l +00 38 1A 81 18 57 00 18 65 42 92 6B 02 38 15 AD .8...W..eB.k.8.. +00 32 00 18 65 65 D3 6C 00 27 15 41 18 34 00 18 .2..ee.l.'.A.4.. +68 1E E2 6D 01 33 1E 57 08 11 00 18 6A 77 5B 6B h..m.3.W....jw[k +02 46 11 98 00 56 00 18 6A A2 0C 6B 00 41 1A C3 .F...V..j..k.A.. +21 37 00 18 6D 39 EB 6B 02 45 14 91 01 02 00 18 !7..m9.k.E...... +6D 6D 19 6B 00 20 09 FD 02 48 00 18 99 F5 A1 4C mm.k. ...H.....L +01 02 1A 13 05 53 00 18 BC 54 D1 58 00 15 09 1C .....S...T.X.... +06 41 00 18 F4 97 2F 51 02 15 0D 48 00 12 00 18 .A..../Q...H.... +F4 A5 03 51 02 08 0A 62 00 11 00 18 F4 B1 8B 51 ...Q...b.......Q +00 39 16 4E 02 12 00 19 18 98 61 73 02 61 0B D2 .9.N......as.a.. +00 47 00 19 18 C2 E7 74 01 14 18 0D 21 01 00 19 .G.....t....!... +1B 3B F6 74 02 19 0F C7 00 20 00 19 1B 4D AA 75 .;.t..... ...M.u +02 56 0D 4E 00 53 00 19 1B 70 72 73 01 21 29 24 .V.N.S...prs.!)$ +01 52 00 19 62 71 12 47 02 20 2A 63 01 52 00 19 .R..bq.G. *c.R.. +62 B1 0A 48 00 30 32 90 03 09 00 1B 45 19 28 67 b..H.02.....E.(g +02 32 23 72 00 48 00 1B 45 3F 55 67 03 25 2D AF .2#r.H..E?Ug.%-. +22 07 00 1B 47 BE C8 66 02 40 1B 8E 00 43 00 1B "...G..f.@...C.. +47 DF E4 67 02 51 07 25 02 56 00 1B 48 45 CA 6C G..g.Q.%.V..HE.l +02 30 1D 7D 19 11 00 1B 4A 7B 6F 67 02 33 1F DB .0.}....J{og.3.. +01 07 00 1B 4A AB 9B 64 02 45 11 30 05 57 00 1B ....J..d.E.0.W.. +4B 64 77 67 00 32 35 8E 21 24 00 1B 4F AA F1 67 Kdwg.25.!$..O..g +02 39 18 13 00 42 00 1B 4F CF 37 68 3F 05 0C 06 .9...B..O.7h?... +E3 36 DE D0 04 DC 9B 95 E6 D6 E0 BF 72 63 EE E5 .6..........rc.. +33 10 03 06 58 94 54 94 5C 05 0E 00 D4 B9 28 9A 3...X.T.\.....(. +FF 64 1E 1E 09 1D 18 18 11 44 F6 01 0B 16 82 91 .d.......D...... +CA 00 00 29 04 05 C6 02 1C 8A CA 7F E2 FD ?? ?? ...)..........?? diff --git a/aladin/data/aladin1.dat b/aladin/data/aladin1.dat new file mode 100644 index 0000000..da95ad0 Binary files /dev/null and b/aladin/data/aladin1.dat differ diff --git a/aladin/data/aladin2.dat b/aladin/data/aladin2.dat new file mode 100644 index 0000000..112c5b5 Binary files /dev/null and b/aladin/data/aladin2.dat differ diff --git a/aladin/data/aladin2.txt b/aladin/data/aladin2.txt new file mode 100644 index 0000000..5c09528 --- /dev/null +++ b/aladin/data/aladin2.txt @@ -0,0 +1,128 @@ +A0 09 64 02 A0 00 00 20 04 20 08 E0 10 09 A0 0A ..d.... . ...... +E0 0A 60 10 09 60 05 64 00 20 00 00 20 FF 52 5F ..`..`.d. .. .R_ +0B 67 0B 6B 0B E6 0B 67 0C 73 0C 0B 0C B8 0B 00 .g.k...g.s...... +00 00 1E 90 04 20 0A A0 10 20 10 13 E0 15 20 19 ..... ... .... . +A0 10 1B E0 1D A0 1E A0 10 1E E0 1D 60 1B 60 10 ............`.`. +1B 60 1D E0 1D E0 10 1F 20 1F 60 1F 20 10 1F 20 .`...... .`. .. +1E A0 1D A0 10 1D E0 1D E0 1D E0 10 1E A0 1E 60 ...............` +1E 60 10 1C E0 1B 60 1A 20 10 17 A0 16 A0 12 E4 .`....`. ....... +18 12 60 16 60 18 E0 10 1A 20 19 E0 17 E0 10 17 ..`.`.... ...... +20 15 60 13 E0 10 11 E0 0E 60 0D 60 10 0B A0 0A .`......`.`.... +A0 0C 20 10 0D E0 0E 20 0F 20 10 0F 60 0F A0 0E .. .... . ..`... +60 10 0D 60 0B A0 08 E0 10 07 24 04 60 03 A0 10 `..`......$.`... +00 60 00 20 00 20 00 00 20 00 20 00 20 00 00 E0 .`. . .. . . ... +00 20 00 20 00 FF 45 70 0B 70 0B 70 0B 70 0B 70 . . ..Ep.p.p.p.p +0B 70 0B 70 0B 70 0B 00 00 00 21 90 02 E0 03 20 .p.p.p....!.... +03 E0 10 04 20 04 60 04 60 10 05 E0 06 20 06 60 .... .`.`.... .` +10 06 60 06 E0 07 20 10 07 20 07 20 07 20 10 06 ..`... .. . . .. +E0 07 60 06 E0 10 06 60 06 E0 06 A0 10 05 E0 05 ..`....`........ +20 04 E0 10 04 A0 04 60 04 E0 10 04 60 04 A0 03 ......`....`... +E0 10 04 20 03 A0 02 E0 10 02 E0 00 20 00 20 00 ... ........ . . +02 60 03 60 04 60 10 04 E0 05 20 04 E0 10 05 20 .`.`.`.... .... +05 60 05 E0 10 06 60 06 20 04 A0 10 05 A0 05 60 .`....`. ......` +05 20 10 05 60 05 A0 05 20 10 05 20 05 A0 05 A0 . ..`... .. .... +10 05 A0 05 E0 05 E0 18 06 20 05 A0 05 E0 10 05 ......... ...... +A0 05 20 05 60 10 05 20 04 E0 04 A0 10 04 A0 04 .. .`.. ........ +20 04 20 10 03 E0 03 A0 03 A0 10 04 20 04 60 04 . ......... .`. +60 10 04 A0 04 A0 04 E0 10 04 E0 04 E0 03 E0 10 `............... +03 A0 02 E0 02 A0 10 01 E0 00 20 00 20 00 00 20 .......... . .. +00 E0 00 20 00 00 20 00 20 00 20 00 00 20 00 20 ... .. . . .. . +00 20 00 00 20 00 20 00 20 00 00 20 00 20 00 20 . .. . . .. . . +00 00 20 0B 70 0B 70 0B 70 0B 70 0B 70 0B 70 0B .. .p.p.p.p.p.p. +70 0B 00 00 00 40 90 0B A0 16 20 19 60 10 1A E0 p....@.... .`... +1B 20 19 20 10 1A E0 1C A0 1D A0 10 23 E0 29 20 . . ........#.) +2A A0 10 30 60 34 60 35 A0 10 32 60 2E A0 2D A0 *..0`4`5..2`..-. +10 2D 60 2C 60 2B E0 10 29 20 29 A0 2A 60 10 29 .-`,`+..) ).*`.) +E0 28 E0 29 20 10 2A 60 2B 20 2A A0 10 28 60 25 .(.) .*`+ *..(`% +A0 24 A0 10 22 20 1F 60 1F A0 10 1E A0 1B E0 19 .$.." .`........ +E0 10 1A A0 1C A0 1C 20 10 1A E0 1C E0 1C E0 10 ....... ........ +1C 20 1D E0 1D E0 10 1D 20 1C E0 1B A0 10 1C 60 . ...... ......` +1A E0 1A 60 10 1A 60 1A 60 19 A0 10 19 E0 1A 20 ...`..`.`...... +19 60 10 19 A0 1D 20 1E A0 10 1E A4 1C E0 1D 20 .`.... ........ +10 1B 20 19 60 1A 60 10 1B A0 1B A0 1C 60 10 1C .. .`.`......`.. +E0 1C 60 1D 20 10 1D E0 1D 20 1D A4 10 1B A0 18 ..`. .... ...... +E0 16 20 10 13 20 0F E0 0E 20 10 0C 60 0B E0 0A .. .. ... ..`... +64 10 07 20 08 60 0A A0 10 0B 20 0B 60 0A A0 10 d.. .`.... .`... +08 A0 08 A0 09 20 10 08 E4 01 E0 00 20 00 00 20 ..... ...... .. +FF 68 72 0B D4 0B 16 0E 62 10 4F 0F EA 0D C8 0C .hr.....b.O..... +1F 0C 06 00 49 A7 80 08 20 0F 60 15 E0 10 16 60 ....I... .`....` +15 E0 15 24 10 11 A0 13 60 13 E0 10 12 E0 13 60 ...$....`......` +13 E0 10 12 E0 11 E0 12 20 10 12 E0 12 A0 12 E0 ........ ....... +10 12 E0 14 A0 15 20 10 14 E0 14 20 13 A0 10 13 ...... .... .... +E0 13 E0 13 60 10 14 A0 14 60 13 E0 10 15 20 16 ....`....`.... . +60 16 A0 10 14 E0 13 20 15 A0 10 15 60 15 60 15 `...... ....`.`. +60 10 15 A0 15 60 15 60 10 12 20 12 E0 12 E0 10 `....`.`.. ..... +13 60 13 64 0F 60 10 10 20 11 60 0E E0 10 0E 60 .`.d.`.. .`....` +0E A0 0E E0 10 0E E0 0F 20 0E 60 10 0E A0 0D 60 ........ .`....` +0E 20 10 0E A0 0E 60 0E 60 10 0E 20 11 A0 11 A0 . ....`.`.. .... +10 12 A0 14 20 14 A0 10 16 20 16 E0 17 E0 10 17 .... .... ...... +E0 18 20 18 20 10 17 E0 18 20 17 E0 10 17 E0 17 .. . .... ...... +E0 17 E0 10 17 A0 17 A0 17 A0 10 16 20 16 E0 17 ............ ... +20 10 16 A0 16 60 15 E0 10 15 20 14 60 14 60 10 ....`.... .`.`. +15 60 13 A0 12 24 10 11 E0 15 E0 15 E0 10 15 60 .`...$.........` +14 E0 14 E0 10 13 60 12 20 12 60 10 10 20 11 60 ......`. .`.. .` +11 60 10 0E A0 0D 20 09 60 10 05 E4 04 60 04 A0 .`.... .`....`.. +10 07 A0 07 E0 07 60 10 08 E0 05 A4 00 E0 10 00 ......`......... +A0 00 20 00 20 00 FF 69 73 0B 71 0B 70 0B 70 0B .. . ..is.q.p.p. +70 0B 70 0B 90 0B 70 0B 00 00 00 40 90 07 60 07 p.p...p....@..`. +E0 06 E0 10 07 20 0B E0 0D E0 10 0D 60 0E 60 0F ..... ......`.`. +20 10 0E E0 0E E0 0E E0 10 0F 20 0F 60 0F A0 10 ......... .`... +11 20 12 60 12 A0 10 12 20 12 E0 13 20 10 12 E0 . .`.... ... ... +10 64 0D E0 10 10 60 13 A0 13 E0 10 13 E0 10 A0 .d....`......... +0D 60 10 10 A0 12 E0 13 E0 10 13 E0 12 20 10 A4 .`........... .. +10 0D 24 0A 20 0D E0 10 0F 60 0F E0 0F E0 10 0E ..$. ....`...... +E0 0D A4 08 E4 10 09 A0 0B A0 0D 20 10 0D A0 0D ........... .... +20 0A A0 10 07 E0 07 A0 06 E0 10 06 20 06 60 06 ........... .`. +60 10 05 A0 05 60 05 60 10 05 A0 05 20 04 60 10 `....`.`.... .`. +00 E0 02 20 00 20 00 00 20 00 20 00 E0 00 04 A0 ... . .. . ..... +05 20 05 60 10 05 E0 05 E0 06 20 10 06 60 07 60 . .`...... ..`.` +07 20 10 06 E0 07 20 07 20 10 07 E0 07 E0 08 20 . .... . ...... +10 08 60 06 20 08 A0 10 06 E4 01 60 05 A0 10 07 ..`. ......`.... +A0 06 E0 06 A0 10 06 60 05 60 05 A0 10 05 A4 04 .......`.`...... +A0 04 E0 10 05 20 04 A0 04 A0 10 04 60 04 60 04 ..... ......`.`. +20 10 03 E0 01 20 00 A0 00 00 20 00 E0 00 20 00 .... .... ... . +00 20 FF 4C 70 0B 70 0B 70 0B 70 0B 70 0B 70 0B . .Lp.p.p.p.p.p. +70 0B 70 0B 00 00 00 EA 80 08 20 0D 20 0D 20 10 p.p....... . . . +0C E0 0D A0 10 E0 10 12 20 11 A0 11 E0 10 12 60 ........ ......` +14 60 15 E0 10 17 20 1A 20 1C 60 10 1B 60 1B 20 .`.... . .`..`. +1D 60 10 1D E0 1D 20 1C 20 10 1D 20 1D 20 1D 60 .`.... . .. . .` +10 1D 60 1E A0 1F 20 10 1E 60 1E A0 1E A0 10 1D ..`... ..`...... +E0 1C E0 1C 60 18 1C 60 1C 20 1E 20 10 1D E0 1E ....`..`. . .... +60 1E 60 10 1E 20 1D A0 1C 60 10 1A 60 1C 20 1C `.`.. ...`..`. . +E0 10 1D 60 1D A0 1C 60 10 18 E0 15 E0 12 E0 10 ...`...`........ +10 60 10 20 0C E0 18 0A E0 0A 60 09 20 10 09 24 .`. ......`. ..$ +0B 20 0A E0 10 09 20 0A E0 0A 20 10 07 A0 07 20 . .... ... .... +05 A0 10 04 20 01 60 00 20 00 00 20 00 20 04 20 .... .`. .. . . +10 0A E0 0C 20 0C 60 10 0C E0 0C 20 0C A0 10 0A .... .`.... .... +03 32 13 DE 21 09 00 1B 52 3D 1A 67 01 27 1F 36 .2..!...R=.g.'.6 +03 01 00 1C 0D 72 C6 1C 03 19 1F 52 02 24 00 1C .....r.....R.$.. +0D C4 90 16 00 27 07 4E 17 39 00 1C 22 E3 7D 42 .....'.N.9..".}B +02 07 4F FB 00 05 00 0E F2 BC BC 4E 02 18 5F E9 ..O........N.._. +00 05 00 0E F2 C3 4C 4E 00 38 1A 27 02 55 00 18 ......LN.8.'.U.. +62 A5 21 6C 02 45 15 A5 00 54 00 18 62 D3 97 6C b.!l.E...T..b..l +00 38 1A 81 18 57 00 18 65 42 92 6B 02 38 15 AD .8...W..eB.k.8.. +00 32 00 18 65 65 D3 6C 00 27 15 41 18 34 00 18 .2..ee.l.'.A.4.. +68 1E E2 6D 01 33 1E 57 08 11 00 18 6A 77 5B 6B h..m.3.W....jw[k +02 46 11 98 00 56 00 18 6A A2 0C 6B 00 41 1A C3 .F...V..j..k.A.. +21 37 00 18 6D 39 EB 6B 02 45 14 91 01 02 00 18 !7..m9.k.E...... +6D 6D 19 6B 00 20 09 FD 02 48 00 18 99 F5 A1 4C mm.k. ...H.....L +01 02 1A 13 05 53 00 18 BC 54 D1 58 00 15 09 1C .....S...T.X.... +06 41 00 18 F4 97 2F 51 02 15 0D 48 00 12 00 18 .A..../Q...H.... +F4 A5 03 51 02 08 0A 62 00 11 00 18 F4 B1 8B 51 ...Q...b.......Q +00 39 16 4E 02 12 00 19 18 98 61 73 02 61 0B D2 .9.N......as.a.. +00 47 00 19 18 C2 E7 74 01 14 18 0D 21 01 00 19 .G.....t....!... +1B 3B F6 74 02 19 0F C7 00 20 00 19 1B 4D AA 75 .;.t..... ...M.u +02 56 0D 4E 00 53 00 19 1B 70 72 73 01 21 29 24 .V.N.S...prs.!)$ +01 52 00 19 62 71 12 47 02 20 2A 63 01 52 00 19 .R..bq.G. *c.R.. +62 B1 0A 48 00 30 32 90 03 09 00 1B 45 19 28 67 b..H.02.....E.(g +02 32 23 72 00 48 00 1B 45 3F 55 67 03 25 2D AF .2#r.H..E?Ug.%-. +22 07 00 1B 47 BE C8 66 02 40 1B 8E 00 43 00 1B "...G..f.@...C.. +47 DF E4 67 02 51 07 25 02 56 00 1B 48 45 CA 6C G..g.Q.%.V..HE.l +02 30 1D 7D 19 11 00 1B 4A 7B 6F 67 02 33 1F DB .0.}....J{og.3.. +01 07 00 1B 4A AB 9B 64 02 45 11 30 05 57 00 1B ....J..d.E.0.W.. +4B 64 77 67 00 32 35 8E 21 24 00 1B 4F AA F1 67 Kdwg.25.!$..O..g +02 39 18 13 00 42 00 1B 4F CF 37 68 3F 05 0C 06 .9...B..O.7h?... +E3 36 DE D0 04 DC 9B 95 E6 D6 E0 BF 72 63 EE E5 .6..........rc.. +33 10 03 06 58 94 54 94 5C 05 0E 00 D4 B9 28 9A 3...X.T.\.....(. +FF 64 1E 1E 09 1D 18 18 11 44 F6 01 0B 16 82 91 .d.......D...... +CA 00 00 29 04 05 C6 02 1C A3 DD E4 73 FE ?? ?? ...)........s.?? diff --git a/aladin/data/aladin3.dat b/aladin/data/aladin3.dat new file mode 100644 index 0000000..7f174a9 Binary files /dev/null and b/aladin/data/aladin3.dat differ diff --git a/aladin/data/dives.123 b/aladin/data/dives.123 new file mode 100644 index 0000000..29b0792 Binary files /dev/null and b/aladin/data/dives.123 differ diff --git a/aladin/data/sean.log b/aladin/data/sean.log new file mode 100644 index 0000000..e701578 Binary files /dev/null and b/aladin/data/sean.log differ diff --git a/aladin/data/sean2.log b/aladin/data/sean2.log new file mode 100644 index 0000000..c73fc7b Binary files /dev/null and b/aladin/data/sean2.log differ diff --git a/aladin/data/seans.log b/aladin/data/seans.log new file mode 100644 index 0000000..0d40622 Binary files /dev/null and b/aladin/data/seans.log differ diff --git a/aladin/data/seans.log.saf b/aladin/data/seans.log.saf new file mode 100644 index 0000000..4eaa2f9 Binary files /dev/null and b/aladin/data/seans.log.saf differ diff --git a/aladin/divedlg.cpp b/aladin/divedlg.cpp new file mode 100644 index 0000000..fc7555f --- /dev/null +++ b/aladin/divedlg.cpp @@ -0,0 +1,540 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DiveDlg::DiveDlg(void) +{ + mInitHandler.setCallback(this,&DiveDlg::initHandler); + mCreateHandler.setCallback(this,&DiveDlg::createHandler); + mCloseHandler.setCallback(this,&DiveDlg::closeHandler); + mDestroyHandler.setCallback(this,&DiveDlg::destroyHandler); + mCommandHandler.setCallback(this,&DiveDlg::commandHandler); + insertHandler(VectorHandler::InitDialogHandler,&mInitHandler); + insertHandler(VectorHandler::CreateHandler,&mCreateHandler); + insertHandler(VectorHandler::CloseHandler,&mCloseHandler); + insertHandler(VectorHandler::CommandHandler,&mCommandHandler); + insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler); +} + +DiveDlg::DiveDlg(const DiveDlg &someDiveDlg) +{ // private implementation + *this=someDiveDlg; +} + +DiveDlg::~DiveDlg() +{ + removeHandler(VectorHandler::InitDialogHandler,&mInitHandler); + removeHandler(VectorHandler::CreateHandler,&mCreateHandler); + removeHandler(VectorHandler::CloseHandler,&mCloseHandler); + removeHandler(VectorHandler::CommandHandler,&mCommandHandler); + removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler); +} + +DiveDlg &DiveDlg::operator=(const DiveDlg &someDiveDlg) +{ + return *this; +} + +bool DiveDlg::perform(void) +{ + return ::DialogBoxParam(processInstance(),(LPSTR)"DIVEBOOK",(HWND)0,DWindow::DlgProc,(LPARAM)(DWindow*)this); +} + +CallbackData::ReturnType DiveDlg::initHandler(CallbackData &someCallbackData) +{ + String strClass; + + applyHistory(); + ::GetClassName(*this,strClass,String::MaxString); + ::SetClassLong(*this,GCL_HICON,(LONG)::LoadIcon(processInstance(),"APPICON")); + enableMenuItems(false); + mOwnerDrawGraph=new OwnerDrawGraph(*this,getItem(DB_GRAPH),DB_GRAPH); + mOwnerDrawGraph.disposition(PointerDisposition::Delete); + setCaption(String(STRING_APPNAME)+String(" ")+String(STRING_VERSION)); + Block logStopArray; + Block profileStopArray; + mLogList=new OwnerDrawListAltColor(*this,getItem(DB_LOGLIST),DB_LOGLIST); + mLogList.disposition(PointerDisposition::Delete); + mProfileList=new OwnerDrawListAltColor(*this,getItem(DB_PFLIST),DB_PFLIST); + mProfileList.disposition(PointerDisposition::Delete); + logStopArray.insert(&PureDWORD(50)); + logStopArray.insert(&PureDWORD(70)); + logStopArray.insert(&PureDWORD(92)); + logStopArray.insert(&PureDWORD(112)); + logStopArray.insert(&PureDWORD(130)); + mLogList->setTabStops(logStopArray); + profileStopArray.insert(&PureDWORD(5)); + profileStopArray.insert(&PureDWORD(25)); + profileStopArray.insert(&PureDWORD(50)); + mProfileList->setTabStops(profileStopArray); + ::EnableWindow(getItem(DB_NITROX),false); + ::EnableWindow(getItem(DB_O2),false); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType DiveDlg::createHandler(CallbackData &someCallbackData) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType DiveDlg::closeHandler(CallbackData &someCallbackData) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType DiveDlg::destroyHandler(CallbackData &someCallbackData) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType DiveDlg::commandHandler(CallbackData &someCallbackData) +{ + switch(someCallbackData.wmCommandID()) + { + case APPMENU_FILE_EXIT : + case IDCANCEL : + handleCancel(); + break; + case APPMENU_FILE_OPENDEVICE : + handleFileOpenDevice(); + break; + case APPMENU_FILE_OPENLOG : + handleFileOpenLog(); + break; + case APPMENU_FILE_IMPORT : + handleImport(); + break; + case APPMENU_FILE_SAVEWORKSHEET : + handleSaveAsWorksheet(); + break; + case APPMENU_FILE_SAVERAW : + handleSaveAsRaw(); + break; + case APPMENU_FILE_SAVETEXT : + handleSaveAsText(); + break; + case APPMENU_FILE_SAVEGRAPH : + handleSaveGraph(); + break; + case APPMENU_FILE_SAVE : + handleFileSaveLog(); + break; + case APPMENU_FILE_NEW : + handleFileNew(); + break; + case APPMENU_SETTINGS_SERIAL : + handleSerialSettings(); + break; + case APPMENU_HELP_ABOUT : + handleHelpAbout(); + break; + case APPMENU_HELP_REGISTER : + handleHelpRegister(); + break; + case APPMENU_HELP_HELP : + handleHelpHelp(); + break; + case APPMENU_HELP_HOME : + handleHelpHome(); + break; + case APPMENU_HELP_INTERFACES : + handleHelpInterfaces(); + break; + case DB_PROFILES : + if(CBN_SELCHANGE==someCallbackData.wmCommandCommand()) + handleProfileChange(); + break; + case DB_GRAPH : + handleGraph(); + break; + } + if(someCallbackData.wParam()>=StartDynamicID)handleFileOpen(someCallbackData); + return (CallbackData::ReturnType)FALSE; +} + +void DiveDlg::handleGraph() +{ + GDIPoint cursorPos; + + if(!mOwnerDrawGraph->hasData())return; + cursorPos.x(0); + cursorPos.y(0); + PureMenu popupMenu(PureMenu::PopupMenu); + popupMenu.insertMenu(0,PureMenu::ItemString,APPMENU_FILE_SAVEGRAPH,"&Save Bitmap..."); + popupMenu.trackPopupMenu(*this,cursorPos,PureMenu::CenterAlign|PureMenu::TopAlign); +} + +void DiveDlg::handleSaveGraph() +{ + OpenDialog openDialog; + String strPathFileName; + String strSaveAs; + + sendMessage(DB_PROFILES,WM_GETTEXT,String::MaxString,(LPARAM)(LPSTR)strSaveAs.str()); + strSaveAs+=".bmp"; + if(!openDialog.getSaveFileName(".bmp","Save Bitmap",strSaveAs,strPathFileName))return; + mOwnerDrawGraph->saveBitmap(strPathFileName); +} + +void DiveDlg::handleCancel() +{ + endDialog(false); +} + +void DiveDlg::handleOk() +{ + endDialog(true); +} + +void DiveDlg::handleSerialSettings() +{ + SerialDlg serialDlg; + serialDlg.perform(*this); +} + +void DiveDlg::handleFileOpen(CallbackData &someCallbackData) +{ + PureMenu pureMenu(getMenu()); + PureMenu fileMenu; + String menuItemString; + + pureMenu.getSubMenu(0,fileMenu); + menuItemString=fileMenu.menuItemString(someCallbackData.wParam(),PureMenu::ByCommand); + if(menuItemString.isNull())return; + menuItemString=menuItemString.betweenString(')',0); + menuItemString.trimLeft(); + if(menuItemString.strstr(".log"))handleFileOpenLog(menuItemString); + else if(menuItemString.strstr(".dat"))handleFileOpenRaw(menuItemString); + else ::MessageBox(*this,"Unknown data format","Error",MB_OK); +} + +void DiveDlg::handleFileOpenDevice() +{ + AppReg appReg; + LRESULT result; + + if(mDiveProfile.isOkay()) + { + result=::MessageBox(*this,"Merge into currently loaded log?","Confirm",MB_YESNOCANCEL); + if(IDCANCEL==result)return; + if(IDNO==result)mDiveProfile.clear(); + } + if(!mDiveProfile.openDevice(appReg.getPort(),*this))return; + enableMenuItems(true,IDYES==result?false:true); + setCaption(String(STRING_APPNAME)+String(" ")+String(STRING_VERSION)+String(" (Device:")+appReg.getPort()+String(")")); + setData(mDiveProfile); +} + +void DiveDlg::handleImport() +{ + String strPathFileName; + OpenDialog openDialog; + + if(!openDialog.getOpenFileName(*this,"*.dat","Open File","*.dat",strPathFileName))return; + handleFileOpenRaw(strPathFileName); +} + +void DiveDlg::handleFileOpenLog(void) +{ + OpenDialog openDialog; + String strPathFileName; + + if(!openDialog.getOpenFileName(*this,"*.log","Open Log","*.log",strPathFileName))return; + handleFileOpenLog(strPathFileName); +} + +void DiveDlg::handleFileOpenLog(const String &strPathFileName) +{ + AppReg appReg; + LRESULT result; + + if(mDiveProfile.isOkay()) + { + result=::MessageBox(*this,"Merge into currently loaded log?","Confirm",MB_YESNOCANCEL); + if(IDCANCEL==result)return; + if(IDNO==result)mDiveProfile.clear(); + } + if(!mDiveProfile.openLog(strPathFileName)) + { + ::MessageBox(*this,"Not a valid log file","Error",MB_OK); + return; + } + appReg.insertHistory(strPathFileName); + setCaption(String(STRING_APPNAME)+String(" ")+String(STRING_VERSION)+String(" (")+strPathFileName+String(")")); + enableMenuItems(true,false); + setData(mDiveProfile); +} + +void DiveDlg::handleFileOpenRaw(const String &strPathFileName) +{ + AppReg appReg; + LRESULT result; + + if(mDiveProfile.isOkay()) + { + result=::MessageBox(*this,"Merge into currently loaded log?","Confirm",MB_YESNOCANCEL); + if(IDCANCEL==result)return; + if(IDNO==result)mDiveProfile.clear(); + } + if(!mDiveProfile.openRaw(strPathFileName)) + { + ::MessageBox(*this,"File is not in Aladin data format","Error",MB_OK); + return; + } + setCaption(String(STRING_APPNAME)+String(" ")+String(STRING_VERSION)+String(" (")+strPathFileName+String(")")); + enableMenuItems(true,IDYES==result?false:true); + setData(mDiveProfile); + appReg.insertHistory(strPathFileName); +} + +void DiveDlg::clearData() +{ + mDiveProfile.clear(); + sendMessage(DB_PROFILES,CB_RESETCONTENT,0,0L); + setText(DB_COMPUTER,""); + setText(DB_BATTERY,""); + setText(DB_STANDARD,""); + sendMessage(DB_NITROX,BM_SETCHECK,0,0L); + sendMessage(DB_O2,BM_SETCHECK,0,0L); + mLogList->resetContent(); + mProfileList->resetContent(); + mOwnerDrawGraph->clearData(); + mOwnerDrawGraph->invalidate(); +} + +void DiveDlg::setData(Aladin &diveInfo) +{ + const Information &information=diveInfo.getInformation(); + const CurrentStatus &status=diveInfo.getStatus(); + const LogBook &logBook=diveInfo.getLogBook(); + const Profiles &profiles=diveInfo.getProfile(); + int index; + + mLogList->resetContent(); + mProfileList->resetContent(); + sendMessage(DB_PROFILES,CB_RESETCONTENT,0,0L); + setText(DB_COMPUTER,information.getComputerTypeString()); + setText(DB_BATTERY,String().fromDouble(status.getRemainingBattery())); + setText(DB_STANDARD,information.getStandardString()); + sendMessage(DB_NITROX,BM_SETCHECK,information.isNitrox(),0L); + sendMessage(DB_O2,BM_SETCHECK,information.isO2(),0L); + sendMessage(DB_NITROX,WM_ENABLE,FALSE,0); + sendMessage(DB_O2,WM_ENABLE,FALSE,0); + for(index=0;indexaddString(str); + } + for(index=0;indexresetContent(); + DiveProfile &diveProfile=((Block&)profiles)[index]; + for(index=0;indexaddString(str); + } + sendMessage(DB_PFMAXDEPTH,WM_SETTEXT,0,(LONG)(LPSTR)String().fromInt(diveProfile.getMaxDepth())); + sendMessage(DB_PFBOTTOMTIME,WM_SETTEXT,0,(LONG)(LPSTR)String().fromInt(diveProfile.getBottomTime())); + mOwnerDrawGraph->setData(diveProfile); + mOwnerDrawGraph->invalidate(); +} + +void DiveDlg::handleSaveAsWorksheet() +{ + OpenDialog openDialog; + String strPathFileName; + + if(!openDialog.getSaveFileName(".123","Save As Lotus Worksheet","",strPathFileName))return; + if(!mDiveProfile.saveWorksheet(strPathFileName)) + { + ::MessageBox(*this,"Error saving file.","Error",MB_OK); + return; + } +} + +void DiveDlg::handleSaveAsRaw() +{ + OpenDialog openDialog; + String strPathFileName; + + if(!openDialog.getSaveFileName(".dat","Save As Raw Data","",strPathFileName))return; + if(!mDiveProfile.saveRaw(strPathFileName)) + { + ::MessageBox(*this,"Error saving file.","Error",MB_OK); + return; + } +} + +void DiveDlg::handleSaveAsText() +{ + OpenDialog openDialog; + String strPathFileName; + + if(!openDialog.getSaveFileName(".txt","Save As Text","",strPathFileName))return; + if(!mDiveProfile.saveText(strPathFileName)) + { + ::MessageBox(*this,"Error saving file.","Error",MB_OK); + return; + } +} + +void DiveDlg::handleFileSaveLog(void) +{ + OpenDialog openDialog; + String strPathFileName; + + if(!openDialog.getSaveFileName(".log","Save Log","",strPathFileName))return; + if(!mDiveProfile.saveLog(strPathFileName)) + { + ::MessageBox(*this,"Error saving file.","Error",MB_OK); + return; + } +} + +void DiveDlg::handleFileNew() +{ + if(IDCANCEL==::MessageBox(*this,"Clear contents?","Confirm",MB_OKCANCEL))return; + clearData(); +} + +void DiveDlg::handleHelpAbout() +{ + SplashScreen splashScreen("SPLASH",String(STRING_SPLASHURL),String(STRING_APPNAME)); + splashScreen.perform(); +} + +void DiveDlg::handleHelpHelp() +{ + String strCommand; + Process process; + + if(!getBrowser(strCommand))return; + process.createProcess(strCommand,String(" ")+String(STRING_HOST)+String(STRING_HELPPAGE),false); +} + +void DiveDlg::handleHelpRegister() +{ + String strCommand; + Process process; + + if(!getBrowser(strCommand))return; + process.createProcess(strCommand,String(" ")+String(STRING_HOST)+String(STRING_REGISTERPAGE),false); +} + +void DiveDlg::handleHelpHome() +{ + String strCommand; + Process process; + + if(!getBrowser(strCommand))return; + process.createProcess(strCommand,String(" ")+String(STRING_HOST)+String(STRING_HOMEPAGE),false); +} + +void DiveDlg::handleHelpInterfaces(void) +{ + String strCommand; + Process process; + + if(!getBrowser(strCommand))return; + process.createProcess(strCommand,String(" ")+String(STRING_LINKURL),false); +} + +void DiveDlg::enableMenuItems(bool enable,bool enableSaveRaw) +{ + PureMenu windowMenu(::GetMenu(*this)); + windowMenu.getSubMenu(0,windowMenu); + if(enable) + { + windowMenu.getSubMenu(0,windowMenu); + windowMenu.enableMenuItem(APPMENU_FILE_SAVEWORKSHEET,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemEnabled)); + if(!enableSaveRaw)windowMenu.enableMenuItem(APPMENU_FILE_SAVERAW,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemDisabled|PureMenu::ItemGrayed)); + else windowMenu.enableMenuItem(APPMENU_FILE_SAVERAW,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemEnabled)); + windowMenu.enableMenuItem(APPMENU_FILE_SAVETEXT,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemEnabled)); + windowMenu.enableMenuItem(APPMENU_FILE_SAVE,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemEnabled)); + windowMenu.enableMenuItem(APPMENU_FILE_NEW,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemEnabled)); + } + else + { + windowMenu.getSubMenu(0,windowMenu); + windowMenu.enableMenuItem(APPMENU_FILE_SAVEWORKSHEET,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemDisabled|PureMenu::ItemGrayed)); + windowMenu.enableMenuItem(APPMENU_FILE_SAVERAW,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemDisabled|PureMenu::ItemGrayed)); + windowMenu.enableMenuItem(APPMENU_FILE_SAVETEXT,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemDisabled|PureMenu::ItemGrayed)); + windowMenu.enableMenuItem(APPMENU_FILE_SAVE,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemDisabled|PureMenu::ItemGrayed)); + windowMenu.enableMenuItem(APPMENU_FILE_NEW,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemDisabled|PureMenu::ItemGrayed)); + } +} + +bool DiveDlg::getBrowser(String &strBrowser) +{ + RegKey regKey(RegKey::LocalMachine); + String strCommand; + int argPos; + + if(!regKey.openKey(String(STRING_BROWSERKEY))) + { + if(!regKey.openKey(String(STRING_BROWSERKEYALT))) + { + ::MessageBox(*this,"Unable to launch browser.","Error",MB_OK); + return false; + } + } + if(!regKey.enumValue(0,String(STRING_BROWSERCOMMAND),strCommand)||strCommand.isNull()||!strCommand.length()) + { + ::MessageBox(*this,"Unable to launch browser.","Error",MB_OK); + return false; + } + strCommand.removeTokens("'\""); + if(-1!=(argPos=strCommand.strpos("-")))strCommand=strCommand.substr(0,argPos-1); + strBrowser=strCommand; + return true; +} + +void DiveDlg::applyHistory(void) +{ + AppReg appReg; + Block nameList; + PureMenu fileMenu; + String strItem; + PureMenu pureMenu(getMenu()); + + appReg.getHistory(nameList); + if(!nameList.size())return; + pureMenu.getSubMenu(0,fileMenu); + fileMenu.appendSeparator(); + for(int itemIndex=0;itemIndex +#endif +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif +#ifndef _COMMON_GLOBALDATA_HPP_ +#include +#endif +#ifndef _COMMON_CONTROL_HPP_ +#include +#endif +#ifndef _ALADIN_ALADIN_HPP_ +#include +#endif + +class OwnerDrawListAltColor; +class OwnerDrawGraph; +class Worksheet; +class Profile; +class LogBook; + +class DiveDlg : public DWindow +{ +public: + DiveDlg(void); + virtual ~DiveDlg(); + bool perform(void); +private: + enum{StatusBarID=101,StartDynamicID=20001}; + DiveDlg(const DiveDlg &someDiveDlg); + DiveDlg &operator=(const DiveDlg &someDiveDlg); + CallbackData::ReturnType initHandler(CallbackData &someCallbackData); + CallbackData::ReturnType createHandler(CallbackData &someCallbackData); + CallbackData::ReturnType closeHandler(CallbackData &someCallbackData); + CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData); + CallbackData::ReturnType commandHandler(CallbackData &someCallbackData); + void handleCancel(void); + void handleOk(void); + void setData(Aladin &diveInfo); + void clearData(void); + void handleImport(void); + void handleFileOpen(CallbackData &someCallbackData); + void handleFileOpenDevice(void); + void handleFileOpenLog(void); + void handleProfileChange(void); + void handleSaveAsWorksheet(void); + void handleSaveAsRaw(void); + void handleSaveAsText(void); + void handleSaveGraph(void); + void handleFileSaveLog(void); + void handleFileNew(void); + void handleSerialSettings(void); + void handleHelpAbout(void); + void handleHelpRegister(void); + void handleHelpHome(void); + void handleHelpHelp(void); + void handleHelpInterfaces(void); + void handleGraph(void); + void handleFileOpenLog(const String &strPathFileName); + void handleFileOpenRaw(const String &strPathFileName); + void applyHistory(void); + bool getBrowser(String &strBrowser); + void enableMenuItems(bool enable,bool enableSaveRaw=true); + void addDiveLog(Worksheet &worksheet,const LogBook &logBook,int startRow,int startCol); + void addProfile(Worksheet &worksheet,const Profile &profile,int startRow,int startCol); + + Callback mInitHandler; + Callback mCreateHandler; + Callback mCloseHandler; + Callback mDestroyHandler; + Callback mCommandHandler; + SmartPointer mLogList; + SmartPointer mProfileList; + SmartPointer mOwnerDrawGraph; + Aladin mDiveProfile; +}; +#endif diff --git a/aladin/divelog.cpp b/aladin/divelog.cpp new file mode 100644 index 0000000..a886bbd --- /dev/null +++ b/aladin/divelog.cpp @@ -0,0 +1,154 @@ +#include +#include +#include +#include + +DiveLog::DiveLog() +{ + mExtraInfo=0; + mBottomTime=0; + mMaxDepthHi=0; + mMaxDepthLo=0; + mSurfaceTimeHi=0; + mSurfaceTimeLo=0; + mTotalAirConsumption=0; + mEntryTime1=0; + mEntryTime2=0; + mEntryTime3=0; + mEntryTime4=0; + mWaterTemperature=0; +} + +DiveLog::~DiveLog() +{ +} + +bool DiveLog::operator<(const DiveLog &diveLog)const +{ + return getEntryTime()(const DiveLog &diveLog)const +{ + return getEntryTime()>diveLog.getEntryTime(); +} + +bool DiveLog::operator==(const DiveLog &diveLog)const +{ + SystemTime srcEntryTime(getEntryTime()); + SystemTime dstEntryTime(diveLog.getEntryTime()); + + if(srcEntryTime.year()!=dstEntryTime.year())return false; + if(srcEntryTime.month()!=dstEntryTime.month())return false; + if(srcEntryTime.day()!=dstEntryTime.day())return false; + if(srcEntryTime.hour()!=dstEntryTime.hour())return false; + if(srcEntryTime.minute()!=dstEntryTime.minute())return false; + if(srcEntryTime.second()!=dstEntryTime.second())return false; + return true; +} + +int DiveLog::getBottomTime(void)const +{ + int bottomTime=(((mBottomTime>>4)*10))+(mBottomTime&0x0F); + if(mExtraInfo&0x04)bottomTime+=100; + return bottomTime; +} + +int DiveLog::getMaxDepth(void)const +{ + double maxDepth(((double)((mMaxDepthHi*256)+mMaxDepthLo)*10.00)/4096.00); + return int((maxDepth*3.281)+.5); +} + +int DiveLog::getAltitude(void)const +{ + return 0; +} + +int DiveLog::getWaterTemperature(void)const +{ + return mWaterTemperature/4; +} + +SystemTime DiveLog::getEntryTime(void)const +{ + return DiveTime(mEntryTime1,mEntryTime2,mEntryTime3,mEntryTime4).getTime(); +} + +Time DiveLog::getSurfaceTime(void)const +{ + return Time(mSurfaceTimeHi,mSurfaceTimeLo); +} + +String DiveLog::toString(void)const +{ + String str; + + str+=String("Depth:")+String().fromInt(getMaxDepth())+String(" "); + str+=String("Entry:")+getEntryTime().toString()+String(" "); + str+=String("Temp:")+String().fromInt(getWaterTemperature())+String(" "); + str+=String("Bottom")+String().fromInt(getBottomTime())+String(" "); + str+=String("Surface:")+getSurfaceTime().toString(); + return str; +} + +bool DiveLog::readFrom(RawData &array,int &index) +{ + try + { + mExtraInfo=array[index++]; + mBottomTime=array[index++]; + mMaxDepthHi=array[index++]; + mMaxDepthLo=array[index++]; + mSurfaceTimeHi=array[index++]; + mSurfaceTimeLo=array[index++]; + mTotalAirConsumption=array[index++]; + mEntryTime1=array[index++]; + mEntryTime2=array[index++]; + mEntryTime3=array[index++]; + mEntryTime4=array[index++]; + mWaterTemperature=array[index++]; + } + catch(ArrayIndexOutOfBoundsException exception) + { + ::OutputDebugString(exception.toString()+String("\n")); + return false; + } + return true; +} + +bool DiveLog::readFrom(File &inFile) +{ + if(!inFile.isOkay())return false; + if(!inFile.read(&mExtraInfo,sizeof(mExtraInfo)))return false; + if(!inFile.read(&mBottomTime,sizeof(mBottomTime)))return false; + if(!inFile.read(&mMaxDepthHi,sizeof(mMaxDepthHi)))return false; + if(!inFile.read(&mMaxDepthLo,sizeof(mMaxDepthLo)))return false; + if(!inFile.read(&mSurfaceTimeHi,sizeof(mSurfaceTimeHi)))return false; + if(!inFile.read(&mSurfaceTimeLo,sizeof(mSurfaceTimeLo)))return false; + if(!inFile.read(&mTotalAirConsumption,sizeof(mTotalAirConsumption)))return false; + if(!inFile.read(&mEntryTime1,sizeof(mEntryTime1)))return false; + if(!inFile.read(&mEntryTime2,sizeof(mEntryTime2)))return false; + if(!inFile.read(&mEntryTime3,sizeof(mEntryTime3)))return false; + if(!inFile.read(&mEntryTime4,sizeof(mEntryTime4)))return false; + if(!inFile.read(&mWaterTemperature,sizeof(mWaterTemperature)))return false; + return true; +} + +bool DiveLog::writeTo(File &outFile) +{ + if(!outFile.isOkay())return false; + if(!outFile.write(&mExtraInfo,sizeof(mExtraInfo)))return false; + if(!outFile.write(&mBottomTime,sizeof(mBottomTime)))return false; + if(!outFile.write(&mMaxDepthHi,sizeof(mMaxDepthHi)))return false; + if(!outFile.write(&mMaxDepthLo,sizeof(mMaxDepthLo)))return false; + if(!outFile.write(&mSurfaceTimeHi,sizeof(mSurfaceTimeHi)))return false; + if(!outFile.write(&mSurfaceTimeLo,sizeof(mSurfaceTimeLo)))return false; + if(!outFile.write(&mTotalAirConsumption,sizeof(mTotalAirConsumption)))return false; + if(!outFile.write(&mEntryTime1,sizeof(mEntryTime1)))return false; + if(!outFile.write(&mEntryTime2,sizeof(mEntryTime2)))return false; + if(!outFile.write(&mEntryTime3,sizeof(mEntryTime3)))return false; + if(!outFile.write(&mEntryTime4,sizeof(mEntryTime4)))return false; + if(!outFile.write(&mWaterTemperature,sizeof(mWaterTemperature)))return false; + return true; +} diff --git a/aladin/divelog.hpp b/aladin/divelog.hpp new file mode 100644 index 0000000..0b99678 --- /dev/null +++ b/aladin/divelog.hpp @@ -0,0 +1,62 @@ +#ifndef _ALADIN_DIVELOG_HPP_ +#define _ALADIN_DIVELOG_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_ARRAY_HPP_ +#include +#endif +#ifndef _COMMON_STDIO_HPP_ +#include +#endif +#ifndef _COMMON_MATH_HPP_ +#include +#endif +#ifndef _COMMON_SYSTEMTIME_HPP_ +#include +#endif +#ifndef _ALADIN_STATUS_HPP_ +#include +#endif +#ifndef _ALADIN_TIME_HPP_ +#include +#endif +#ifndef _ALADIN_RAWDATA_HPP_ +#include +#endif + +class File; + +class DiveLog +{ +public: + DiveLog(); + virtual ~DiveLog(); + int getAltitude(void)const; + int getMaxDepth(void)const; + SystemTime getEntryTime(void)const; + int getWaterTemperature(void)const; + int getBottomTime(void)const; + Time getSurfaceTime(void)const; + bool operator<(const DiveLog &diveLog)const; + bool operator>(const DiveLog &diveLog)const; + bool operator==(const DiveLog &diveLog)const; + String toString(void)const; + bool writeTo(File &outFile); + bool readFrom(File &inFile); + bool readFrom(RawData &array,int &index); +private: + BYTE mExtraInfo; + BYTE mBottomTime; + BYTE mMaxDepthHi; + BYTE mMaxDepthLo; + BYTE mSurfaceTimeHi; + BYTE mSurfaceTimeLo; + BYTE mTotalAirConsumption; + BYTE mEntryTime1; + BYTE mEntryTime2; + BYTE mEntryTime3; + BYTE mEntryTime4; + BYTE mWaterTemperature; +}; +#endif diff --git a/aladin/diveprofile.cpp b/aladin/diveprofile.cpp new file mode 100644 index 0000000..399a2e1 --- /dev/null +++ b/aladin/diveprofile.cpp @@ -0,0 +1,95 @@ +#include +#include + +DiveProfile::DiveProfile(void) +{ +} + +DiveProfile::DiveProfile(const DiveProfile &diveProfile) +{ + *this=diveProfile; +} + +DiveProfile::~DiveProfile() +{ +} + +DiveProfile &DiveProfile::operator=(const DiveProfile &diveProfile) +{ + remove(); + for(int index=0;index&)diveProfile)[index]; + insert(&ProfileData(profileData.getDepth(),profileData.getStageTime(),profileData.getWarning())); + } + return *this; +} + +bool DiveProfile::operator==(const DiveProfile &diveProfile)const +{ + if(size()!=diveProfile.size())return false; + for(int index=0;index&)diveProfile)[index]; + ProfileData &profileDataDst=((Block&)*this)[index]; + if(!(profileDataSrc==profileDataDst))return false; + } + return true; +} + +bool DiveProfile::readFrom(File &inFile) +{ + int count; + + if(!inFile.isOkay())return false; + if(!inFile.read(&count,sizeof(count)))return false; + for(int index=0;index&)*this).operator[](index).getDepth()>maxDepth)maxDepth=((Block&)*this).operator[](index).getDepth(); + } + return maxDepth; +} + +int DiveProfile::getBottomTime(void)const +{ + return ((Block&)*this).operator[](size()-1).getStageTime()/60; +} diff --git a/aladin/diveprofile.hpp b/aladin/diveprofile.hpp new file mode 100644 index 0000000..4eaee4c --- /dev/null +++ b/aladin/diveprofile.hpp @@ -0,0 +1,26 @@ +#ifndef _ALADIN_DIVEPROFILE_HPP_ +#define _ALADIN_DIVEPROFILE_HPP_ +#ifndef _COMMON_BLOCK_HPP_ +#include +#endif +#ifndef _ALADIN_PROFILEDATA_HPP_ +#include +#endif + +class File; + +class DiveProfile : public Block +{ +public: + DiveProfile(void); + DiveProfile(const DiveProfile &diveProfile); + virtual ~DiveProfile(); + DiveProfile &operator=(const DiveProfile &diveProfile); + bool operator==(const DiveProfile &diveProfile)const; + bool readFrom(File &inFile); + bool writeTo(File &outFile); + int getMaxDepth(void)const; + int getBottomTime(void)const; +private: +}; +#endif \ No newline at end of file diff --git a/aladin/dives.123 b/aladin/dives.123 new file mode 100644 index 0000000..eda34f1 Binary files /dev/null and b/aladin/dives.123 differ diff --git a/aladin/divetime.hpp b/aladin/divetime.hpp new file mode 100644 index 0000000..212fe7b --- /dev/null +++ b/aladin/divetime.hpp @@ -0,0 +1,62 @@ +#ifndef _ALADIN_DIVETIME_HPP_ +#define _ALADIN_DIVETIME_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_SYSTEMTIME_HPP_ +#include +#endif +#ifndef _COMMON_MATH_HPP_ +#include +#endif +#ifndef _COMMON_SDATE_HPP_ +#include +#endif + +class DiveTime +{ +public: + DiveTime(); + DiveTime(BYTE b1,BYTE b2,BYTE b3,BYTE b4); + virtual ~DiveTime(); + const SystemTime &setTime(BYTE b1,BYTE b2,BYTE b3,BYTE b4); + const SystemTime &getTime(void)const; +private: + SystemTime mDiveTime; +}; + +inline +DiveTime::DiveTime() +{ +} + +inline +DiveTime::DiveTime(BYTE b1,BYTE b2,BYTE b3,BYTE b4) +{ + setTime(b1,b2,b3,b4); +} + +inline +DiveTime::~DiveTime() +{ +} + +inline +const SystemTime &DiveTime::setTime(BYTE b1,BYTE b2,BYTE b3,BYTE b4) +{ + int entryTime=b1*Math::power(2,24)+b2*Math::power(2,16)+b3*Math::power(2,8)+b4; + int divisor=entryTime/172800; + int remainder=entryTime%172800; + int hours=remainder/7200; + int minutes=(remainder/120)%60; + SDate entryDate=SDate().daysAddActual(SDate(1,1,1994),divisor); + mDiveTime.makeTime(entryDate.year(),entryDate.month(),entryDate.day(),hours,minutes,0); + return mDiveTime; +} + +inline +const SystemTime &DiveTime::getTime(void)const +{ + return mDiveTime; +} +#endif diff --git a/aladin/flag.ico b/aladin/flag.ico new file mode 100644 index 0000000..79c30ad Binary files /dev/null and b/aladin/flag.ico differ diff --git a/aladin/graph.cpp b/aladin/graph.cpp new file mode 100644 index 0000000..4ec3cb3 --- /dev/null +++ b/aladin/graph.cpp @@ -0,0 +1,199 @@ +#include +#include +#include +#include +#include +#include +#include + +OwnerDrawGraph::OwnerDrawGraph(GUIWindow &parentWnd,HWND hControlWnd,UINT controlID) +: mParentWnd(parentWnd), Control(hControlWnd,controlID), mHasData(false) +{ + PureDevice pureDevice(*this); + mBkGndBrush.createHatchBrush(Brush::HDiag,RGBColor(255,0,0)); + + mDIBitmap=new DIB24(); + mDIBitmap.disposition(PointerDisposition::Delete); + mDIBitmap->create(width(),height(),pureDevice); + + mDrawItemHandler.setCallback(this,&OwnerDrawGraph::drawItemHandler); + mControlColorHandler.setCallback(this,&OwnerDrawGraph::controlColorHandler); + mParentWnd.insertHandler(VectorHandler::DrawItemHandler,&mDrawItemHandler); + mParentWnd.insertHandler(VectorHandler::ControlColorHandler,&mControlColorHandler); +} + +OwnerDrawGraph::~OwnerDrawGraph() +{ + mParentWnd.removeHandler(VectorHandler::DrawItemHandler,&mDrawItemHandler); + mParentWnd.removeHandler(VectorHandler::ControlColorHandler,&mControlColorHandler); +} + +CallbackData::ReturnType OwnerDrawGraph::drawItemHandler(CallbackData &someCallbackData) +{ + DrawItem drawItem(*((LPDRAWITEMSTRUCT)someCallbackData.lParam())); + if(drawItem.controlID()!=controlID())return (CallbackData::ReturnType)TRUE; + return handleDraw(drawItem); +} + +CallbackData::ReturnType OwnerDrawGraph::controlColorHandler(CallbackData &someCallbackData) +{ + Control wndButton((HWND)someCallbackData.lParam(),::GetDlgCtrlID((HWND)someCallbackData.lParam()),FALSE); + if(!(*this==wndButton))return (CallbackData::ReturnType)FALSE; + PureDevice pureDevice((HDC)someCallbackData.wParam()); + return handleControlColor(pureDevice,wndButton); +} + +void OwnerDrawGraph::drawBitmap(const DrawItem &drawItem) +{ + PureDevice displayDevice(drawItem.deviceContext()); + mDIBitmap->bitBlt(displayDevice,Rect(0,0,width(),height()),Point(0,0)); +} + +// *************** virtuals + +WORD OwnerDrawGraph::handleDraw(const DrawItem &drawItem) +{ + WORD retCode(TRUE); + + switch(drawItem.itemAction()) + { + case ODA_DRAWENTIRE : + drawEntire(drawItem); + break; + case ODA_SELECT : + retCode=drawSelect(drawItem); + break; + case ODA_FOCUS : + drawFocus(drawItem); + break; + } + return retCode; +} + +WORD OwnerDrawGraph::handleMeasureItem(MeasureItem &/*measureItem*/) +{ + return TRUE; +} + +LPARAM OwnerDrawGraph::handleControlColor(PureDevice &/*pureDevice*/,Control &/*wndButton*/) +{ + return (CallbackData::ReturnType)mBkGndBrush.getBrush(); +} + +void OwnerDrawGraph::drawEntire(const DrawItem &drawItem) +{ + if(drawItem.itemState()&ODS_SELECTED)drawBitmap(drawItem); + else if(drawItem.itemState()&ODS_FOCUS)drawBitmap(drawItem); + else if(drawItem.itemState()&ODS_DISABLED)drawBitmap(drawItem); + else drawBitmap(drawItem); + drawButtonText(drawItem); + drawButtonLines(drawItem); + return; +} + +WORD OwnerDrawGraph::drawSelect(const DrawItem &drawItem) +{ + WORD retCode(TRUE); + if(drawItem.itemState()&ODS_SELECTED)drawBitmap(drawItem); + else {drawBitmap(drawItem);retCode=FALSE;} + drawButtonText(drawItem); + drawButtonLines(drawItem); + return retCode; +} + +void OwnerDrawGraph::drawFocus(const DrawItem &drawItem) +{ + if(drawItem.itemState()&ODS_FOCUS)drawBitmap(drawItem); + else drawBitmap(drawItem); + drawButtonText(drawItem); + drawButtonLines(drawItem); + return; +} + +void OwnerDrawGraph::drawButtonText(const DrawItem &drawItem) +{ +/* TEXTMETRIC textMetric; + Rect drawRect; + String strText; + PureDevice controlDevice(drawItem.deviceContext()); + + windowText(strText); + if(strText.isNull())return; + controlDevice.setBkMode(PureDevice::Transparent); + controlDevice.select((GDIObj)mTextFont,TRUE); + controlDevice.setTextColor(textColor()); + ::GetTextMetrics(drawItem.deviceContext(),&textMetric); + drawRect=drawItem.rectItem(); + controlDevice.textOut(0,(drawRect.bottom()+drawRect.top()-textMetric.tmHeight)/2,strText); + controlDevice.select((GDIObj)mTextFont,FALSE); */ +} + +void OwnerDrawGraph::drawButtonLines(const DrawItem &drawItem) +{ + PureDevice controlDevice(drawItem.deviceContext()); + controlDevice.line(Point(0,0),Point(width(),0),RGBColor(0,0,0)); + controlDevice.line(Point(0,0),Point(0,height()),RGBColor(0,0,0)); + controlDevice.line(Point(0,height()-1),Point(width(),height()-1),RGBColor(255,255,255)); + controlDevice.line(Point(width(),height()-1),Point(width()-1,0),RGBColor(255,255,255)); +} + +void OwnerDrawGraph::clearData(void) +{ + mDIBitmap->setBits(0); + mHasData=false; +} + +void OwnerDrawGraph::setData(DiveProfile &diveProfile) +{ + Block &profileData=(Block &)diveProfile; + int maxDepth(getMaxDepth(profileData)); + double wRatio=(double)width()/(double)profileData.size(); + double hRatio=((double)height()/maxDepth)-.05; + double x=wRatio; + + mDIBitmap->setBits(0); + for(int index=0;indexline(Point(x,height()-(int)(double)pData.getDepth()*(double)hRatio),Point(x+wRatio,height()-(int)(double)pNextData.getDepth()*(double)hRatio),RGB888(0,255,0)); + x+=wRatio; + } + mHasData=true; +} + +int OwnerDrawGraph::getMaxDepth(Block &profileData) +{ + int maxDepth(0); + + for(int index=0;indexmaxDepth)maxDepth=pData.getDepth(); + } + return maxDepth; +} + +bool OwnerDrawGraph::saveBitmap(const String &strPathFileName) +{ + JPGImage jpgImage; + RGB888 rgb888; + + BitmapInfo &bmInfo=jpgImage.getBitmapInfo(); + bmInfo.bitCount(BitmapInfo::Bit24); + bmInfo.width(mDIBitmap->width()); + bmInfo.height(mDIBitmap->height()); + bmInfo.colorUsed(0); + bmInfo.colorImportant(0); + jpgImage.getRGBArray().size(mDIBitmap->extent()); + for(int row=0;rowheight();row++) + { + for(int col=0;colwidth();col++) + { + mDIBitmap->getAt(row,col,rgb888); + jpgImage.setAt(row,col,rgb888); + } + } + jpgImage.saveBitmap(strPathFileName); + return true; +} diff --git a/aladin/graph.hpp b/aladin/graph.hpp new file mode 100644 index 0000000..891b5c8 --- /dev/null +++ b/aladin/graph.hpp @@ -0,0 +1,62 @@ +#ifndef _ALADIN_OWNERDRAWGRAPH_HPP_ +#define _ALADIN_OWNERDRAWGRAPH_HPP_ +#ifndef _COMMON_CONTROL_HPP_ +#include +#endif +#ifndef _COMMON_BRUSH_HPP_ +#include +#endif +#ifndef _COMMON_ARRAY_HPP_ +#include +#endif +#ifndef _ALADIN_DIVEPROFILE_HPP_ +#include +#endif + +class DrawItem; +class MeasureItem; +class PureDevice; +class DIB24; +class FloatPairs; + +class OwnerDrawGraph : public Control +{ +public: + OwnerDrawGraph(GUIWindow &parentWnd,HWND hControlWnd,UINT controlID); + virtual ~OwnerDrawGraph(); + void setData(DiveProfile &diveProfile); + void clearData(void); + bool hasData(void)const; + bool saveBitmap(const String &strPathFileName); +protected: + virtual WORD handleDraw(const DrawItem &drawItem); + virtual WORD handleMeasureItem(MeasureItem &measureItem); + virtual LPARAM handleControlColor(PureDevice &pureDevice,Control &wndButton); + virtual void drawEntire(const DrawItem &drawItem); + virtual WORD drawSelect(const DrawItem &drawItem); + virtual void drawFocus(const DrawItem &drawItem); + virtual void drawButtonText(const DrawItem &drawItem); + virtual void drawButtonLines(const DrawItem &drawItem); +private: + OwnerDrawGraph &operator=(const OwnerDrawGraph &someOwnerDrawGraph); + void drawBitmap(const DrawItem &drawItem); + CallbackData::ReturnType drawItemHandler(CallbackData &someCallbackData); + CallbackData::ReturnType controlColorHandler(CallbackData &someCallbackData); + int getMaxDepth(Block &profileData); + + Callback mDrawItemHandler; + Callback mMeasureItemHandler; + Callback mControlColorHandler; + SmartPointer mDiveProfile; + SmartPointer mDIBitmap; + Brush mBkGndBrush; + GUIWindow &mParentWnd; + bool mHasData; +}; + +inline +bool OwnerDrawGraph::hasData(void)const +{ + return mHasData; +} +#endif diff --git a/aladin/hold/Main.cpp b/aladin/hold/Main.cpp new file mode 100644 index 0000000..1615053 --- /dev/null +++ b/aladin/hold/Main.cpp @@ -0,0 +1,15 @@ +#include +#include +#include +#include +#include +#include + +int PASCAL WinMain(HINSTANCE /*hInstance*/,HINSTANCE /*hPrevInstance*/,LPSTR lpszCmdLine,int /*nCmdShow*/) +{ + SplashScreen splashScreen("SPLASH",String(STRING_SPLASHURL),String(STRING_APPNAME)); + splashScreen.perform(); + DiveDlg diveDlg; + diveDlg.perform(); + return false; +} diff --git a/aladin/hold/aladin.cpp b/aladin/hold/aladin.cpp new file mode 100644 index 0000000..b6674d7 --- /dev/null +++ b/aladin/hold/aladin.cpp @@ -0,0 +1,259 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +Aladin::Aladin() +: mIsOkay(false) +{ + mRawData.size(2046); +} + +Aladin::~Aladin() +{ +} + +bool Aladin::openFile(const String &strPathFileName) +{ + BYTE header[4]; + + mIsOkay=false; + File inFile; + if(!inFile.open(strPathFileName,"rb"))return false; + if(!inFile.read(header,sizeof(header)))return false; + if(::memcmp(header,"UUU\0",sizeof(header)))return false; + if(!inFile.read(&mRawData[0],mRawData.size()))return false; + mIsOkay=readRaw(mRawData); + return mIsOkay; +} + +bool Aladin::saveRaw(const String &strPathFileName) +{ + char header[]={'U','U','U','\0'}; + File outFile; + if(!outFile.open(strPathFileName,"wb"))return false; + if(!outFile.write(header,sizeof(header)))return false; + if(!outFile.write(&mRawData[0],mRawData.size()))return false; + return true; +} + +bool Aladin::saveText(const String &strPathFileName) +{ + File outFile; + + if(!outFile.open(strPathFileName,"wb"))return false; + outFile.writeLine("Entry Time Max Depth Bottom Time Surface Time Temperature (C)"); + outFile.writeLine("-----------------------------------------------------------------------"); + for(int index=0;index&)mProfiles)[pIndex]; + outFile.writeLine(" "); + outFile.writeLine(" "); + outFile.writeLine(String("Profile_")+String().fromInt(pIndex+1)); + outFile.writeLine("Time Depth"); + for(int diveIndex=0;diveIndex iconNames; + + mIsOkay=false; + if(IDCANCEL==::MessageBox(parent,"Place computer in Log Book mode and press OK to continue.","Prompt",MB_OKCANCEL))return false; + if(port.isNull())return false; + if(!control.open(CommControl::stringToPort(port)))return false; + strCommState+=String("baud=")+appReg.getBaud()+String(" "); + strCommState+=String("parity=")+appReg.getParity()+String(" "); + strCommState+=String("data=")+appReg.getDataBits()+String(" "); + strCommState+=String("stop=")+appReg.getStopBits()+String(" "); + control.setDeviceControlBlock(strCommState); + control.getDeviceControlBlock(dcb); + dcb.dtrControl(DeviceControlBlock::DtrControlEnable); + dcb.rtsControl(DeviceControlBlock::RtsControlDisable); + control.setDeviceControlBlock(dcb); + + iconNames.insert(&String("ASM1")); + iconNames.insert(&String("ASM2")); + iconNames.insert(&String("ASM3")); + iconNames.insert(&String("ASM4")); + iconNames.insert(&String("ASM5")); + iconNames.insert(&String("ASM6")); + iconNames.insert(&String("ASM7")); + iconNames.insert(&String("ASM8")); + iconNames.insert(&String("ASM9")); + iconNames.insert(&String("ASM10")); + Progress progress(parent,"Sync..., (Press ESC to cancel)",iconNames); + progress.range(3); + progress.canCancel(true); + progress.show(true); + progress.setText("Performing sync-point on device..."); + progress++; + while(!(mIsOkay=getControlData(control,progress))) + { + progress.setText("Performing sync-point on device..."); + progress.yieldTask(); + parent.update(); + if(!progress.isOkay())break; + progress.reset(); + progress.range(3); + progress++; + } + progress.destroy(); + ::MessageBeep(0); + ::MessageBox(parent,"Please disconnect the device","Acquisition",MB_OK); + dcb.dtrControl(DeviceControlBlock::DtrControlDisable); + dcb.rtsControl(DeviceControlBlock::RtsControlDisable); + control.setDeviceControlBlock(dcb); + control.close(); + if(mIsOkay)return mIsOkay=readRaw(mRawData); + ::MessageBox(parent,"Capture Failed","Acquisition",MB_OK); + return mIsOkay; +} + +const CurrentStatus &Aladin::getStatus(void)const +{ + return mStatus; +} + +const Information &Aladin::getInformation(void)const +{ + return mInformation; +} + +const Profiles &Aladin::getProfile(void)const +{ + return mProfiles; +} + +const LogBook &Aladin::getLogBook(void)const +{ + return mLogBook; +} + +bool Aladin::getControlData(CommControl &control,Progress &progress) +{ + char rcvChar; + char syncBuff[]={'U','U','U','\0'}; + int index=0; + int skipped=0; + int waitTime=0; + + while(!control.hasData()&&waitTime<500) + { + progress.yieldTask(); + ::Sleep(100); + waitTime+=100; + } + if(!control.hasData())return false; + ::memset(&mRawData[0],0,mRawData.size()); + while((sizeof(syncBuff)!=index)&&(skipped &body) +{ + if(!mStatus.readFrom(body))return false; + if(!mInformation.readFrom(body))return false; + if(!mProfiles.readFrom(body,mInformation,mStatus))return false; + if(!mLogBook.readFrom(body,mStatus))return false; + return true; +} + +void Aladin::addDiveLog(Worksheet &worksheet,const LogBook &logBook,int startRow,int startCol) +{ + worksheet.setAt(startRow,startCol+(5/2),"DiveLog"); + worksheet.setAt(startRow,startCol,"Entry Time"); + worksheet.setAt(startRow,startCol+1,"Max Depth"); + worksheet.setAt(startRow,startCol+2,"Bottom Time"); + worksheet.setAt(startRow,startCol+3,"Surface Time"); + worksheet.setAt(startRow,startCol+4,"Temperature"); + for(int index=0;index&)profiles)[pIndex]; + sRow=startRow; + String strTitle(String("Profile_")+String().fromInt(pIndex+1)); + worksheet.setAt(sRow++,startCol,strTitle); + worksheet.setAt(sRow,startCol,"Time"); + worksheet.setAt(sRow++,startCol+1,"Depth"); + for(int diveIndex=0;diveIndex +#endif +#ifndef _ALADIN_INFORMATION_HPP_ +#include +#endif +#ifndef _ALADIN_PROFILES_HPP_ +#include +#endif +#ifndef _ALADIN_PROFILEDATA_HPP_ +#include +#endif +#ifndef _ALADIN_LOGBOOK_HPP_ +#include +#endif + +class CommControl; +class GUIWindow; +class Progress; +class Worksheet; + +class Aladin +{ +public: + Aladin(); + virtual ~Aladin(); + bool openFile(const String &strPathFileName); + bool openDevice(const String &port,GUIWindow &parent); + bool saveRaw(const String &strPathFileName); + bool saveWorksheet(const String &strPathFileName); + bool saveText(const String &strPathFileName); + const CurrentStatus &getStatus(void)const; + const Information &getInformation(void)const; + const Profiles &getProfile(void)const; + const LogBook &getLogBook(void)const; + bool isMerged(void)const; + void isMerged(bool bMerged); + void clear(void); + bool isOkay(void)const; +private: + bool readRaw(Array &body); + bool getControlData(CommControl &control,Progress &progress); + void addProfile(Worksheet &worksheet,const Profiles &profiles,int startRow,int startCol); + void addDiveLog(Worksheet &worksheet,const LogBook &logBook,int startRow,int startCol); + + CurrentStatus mStatus; + Information mInformation; + Profiles mProfiles; + LogBook mLogBook; + Array mRawData; + bool mIsMerged; + bool mIsOkay; +}; + +inline +bool Aladin::isOkay(void)const +{ + return mIsOkay; +} + +inline +bool Aladin::isMerged(void)const +{ + return mIsMerged; +} + +inline +void Aladin::isMerged(bool bMerged) +{ + mIsMerged=bMerged; +} + +inline +void Aladin::clear(void) +{ + mIsMerged=false; + mProfiles.remove(); + mLogBook.remove(); +} +#endif \ No newline at end of file diff --git a/aladin/hold/aladinrc.hpp b/aladin/hold/aladinrc.hpp new file mode 100644 index 0000000..c495d29 --- /dev/null +++ b/aladin/hold/aladinrc.hpp @@ -0,0 +1,6 @@ +#ifndef _ALADIN_ALADINRC_HPP_ +#define _ALADIN_ALADINRC_HPP_ +#ifndef _ALADIN_ALADIN_H_ +#include +#endif +#endif diff --git a/aladin/hold/appreg.cpp b/aladin/hold/appreg.cpp new file mode 100644 index 0000000..3fa48d9 --- /dev/null +++ b/aladin/hold/appreg.cpp @@ -0,0 +1,142 @@ +#include +#include + +AppReg::AppReg(void) +: mAladinKeyName(STRING_ALADINKEYNAME), + mSerialKeyName(STRING_SERIALKEYNAME), + mSettingsEMAIL(STRING_SETTINGSEMAIL), + mSerialPort(STRING_SERIALPORT), + mSerialBaud(STRING_SERIALBAUD), + mSerialData(STRING_SERIALDATA), + mSerialParity(STRING_SERIALPARITY), + mSerialStop(STRING_SERIALSTOP), + mRegKeySerial(RegKey::CurrentUser) +{ + guarantee(); +} + +AppReg::AppReg(const AppReg &someAppReg) +: mAladinKeyName(STRING_ALADINKEYNAME), + mSerialKeyName(STRING_SERIALKEYNAME), + mSettingsEMAIL(STRING_SETTINGSEMAIL), + mSerialPort(STRING_SERIALPORT), + mSerialBaud(STRING_SERIALBAUD), + mSerialData(STRING_SERIALDATA), + mSerialParity(STRING_SERIALPARITY), + mSerialStop(STRING_SERIALSTOP), + mRegKeySerial(RegKey::CurrentUser) +{ + *this=someAppReg; +} + +AppReg::~AppReg() +{ +} + +AppReg &AppReg::operator=(const AppReg &/*someAppReg*/) +{ + return *this; +} + +bool AppReg::setBaud(const String &strBaud) +{ + return mRegKeySerial.setValue(mSerialBaud,strBaud); +} + +String AppReg::getBaud(void) +{ + String strBaud; + mRegKeySerial.queryValue(mSerialBaud,strBaud); + return strBaud; +} + +bool AppReg::setParity(const String &strParity) +{ + return mRegKeySerial.setValue(mSerialParity,strParity); +} + +String AppReg::getParity(void) +{ + String strParity; + mRegKeySerial.queryValue(mSerialParity,strParity); + return strParity; +} + +bool AppReg::setDataBits(const String &strDataBits) +{ + return mRegKeySerial.setValue(mSerialData,strDataBits); +} + +String AppReg::getDataBits(void) +{ + String strData; + mRegKeySerial.queryValue(mSerialData,strData); + return strData; +} + +bool AppReg::setStopBits(const String &stopBits) +{ + return mRegKeySerial.setValue(mSerialStop,stopBits); +} + +String AppReg::getStopBits(void) +{ + String strStop; + + mRegKeySerial.queryValue(mSerialStop,strStop); + return strStop; +} + +bool AppReg::setPort(const String &strPort) +{ + return mRegKeySerial.setValue(mSerialPort,strPort); +} + +String AppReg::getPort(void) +{ + String strPort; + mRegKeySerial.queryValue(mSerialPort,strPort); + return strPort; +} + +String AppReg::getSerialSettings(void) +{ + String serialSettings; + + serialSettings+="baud="; + serialSettings+=getBaud(); + serialSettings+=" "; + serialSettings+="parity="; + serialSettings+=getParity(); + serialSettings+=" "; + serialSettings+="data="; + serialSettings+=getDataBits(); + serialSettings+=" "; + serialSettings+="stop="; + serialSettings+=getStopBits(); + return serialSettings; +} + +void AppReg::guarantee(void) +{ + if(!mRegKeySerial.openKey(mSerialKeyName)) + { + CommControl commControl; + Block deviceList; + + commControl.enumerateDevices(deviceList); + mRegKeySerial.createKey(mSerialKeyName,""); + mRegKeySerial.openKey(mSerialKeyName); + setBaud("19200"); + setParity("N"); + setDataBits("8"); + setStopBits("1"); + setPort(deviceList.size()?deviceList[0]:"COM1"); + } +} + +BOOL AppReg::isOkay(void)const +{ + return mRegKeySerial.isOkay(); +} + diff --git a/aladin/hold/appreg.hpp b/aladin/hold/appreg.hpp new file mode 100644 index 0000000..f77fd8c --- /dev/null +++ b/aladin/hold/appreg.hpp @@ -0,0 +1,45 @@ +#ifndef _ALADIN_APPREG_HPP_ +#define _ALADIN_APPREG_HPP_ +#ifndef _COMMON_REGKEY_HPP_ +#include +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _ALADIN_ALADINRC_HPP_ +#include +#endif + +class AppReg +{ +public: + AppReg(void); + AppReg(const AppReg &someAppReg); + virtual ~AppReg(); + AppReg &operator=(const AppReg &someAppReg); + bool setBaud(const String &strBaud); + String getBaud(void); + bool setParity(const String &strParity); + String getParity(void); + bool setDataBits(const String &strDataBits); + String getDataBits(void); + bool setStopBits(const String &stopBits); + String getStopBits(void); + bool setPort(const String &strPort); + String getPort(void); + String getSerialSettings(void); + BOOL isOkay(void)const; +private: + void guarantee(void); + + String mSerialKeyName; + String mSettingsEMAIL; + String mAladinKeyName; + String mSerialPort; + String mSerialBaud; + String mSerialData; + String mSerialParity; + String mSerialStop; + RegKey mRegKeySerial; +}; +#endif diff --git a/aladin/hold/bitmanip.hpp b/aladin/hold/bitmanip.hpp new file mode 100644 index 0000000..035aee8 --- /dev/null +++ b/aladin/hold/bitmanip.hpp @@ -0,0 +1,39 @@ +#ifndef _ALADIN_BITMANIP_HPP_ +#define _ALADIN_BITMANIP_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif + +class BitManip +{ +public: + static BYTE reverse(BYTE byte); + static WORD reverse(WORD word); +}; + +inline +BYTE BitManip::reverse(BYTE byte) +{ + BYTE temp=0; + + temp|=(byte&0x80)>>7; + temp|=(byte&0x40)>>5; + temp|=(byte&0x20)>>3; + temp|=(byte&0x10)>>1; + temp|=(byte&0x08)<<1; + temp|=(byte&0x04)<<3; + temp|=(byte&0x02)<<5; + temp|=(byte&0x01)<<7; + return temp; +} + +inline +WORD BitManip::reverse(WORD someData) +{ + WORD tempData(someData); + + someData>>=8; + someData+=tempData<<8; + return someData; +} +#endif \ No newline at end of file diff --git a/aladin/hold/divedlg.cpp b/aladin/hold/divedlg.cpp new file mode 100644 index 0000000..ba881c5 --- /dev/null +++ b/aladin/hold/divedlg.cpp @@ -0,0 +1,351 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DiveDlg::DiveDlg(void) +{ + mInitHandler.setCallback(this,&DiveDlg::initHandler); + mCreateHandler.setCallback(this,&DiveDlg::createHandler); + mCloseHandler.setCallback(this,&DiveDlg::closeHandler); + mDestroyHandler.setCallback(this,&DiveDlg::destroyHandler); + mCommandHandler.setCallback(this,&DiveDlg::commandHandler); + insertHandler(VectorHandler::InitDialogHandler,&mInitHandler); + insertHandler(VectorHandler::CreateHandler,&mCreateHandler); + insertHandler(VectorHandler::CloseHandler,&mCloseHandler); + insertHandler(VectorHandler::CommandHandler,&mCommandHandler); + insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler); +} + +DiveDlg::DiveDlg(const DiveDlg &someDiveDlg) +{ // private implementation + *this=someDiveDlg; +} + +DiveDlg::~DiveDlg() +{ + removeHandler(VectorHandler::InitDialogHandler,&mInitHandler); + removeHandler(VectorHandler::CreateHandler,&mCreateHandler); + removeHandler(VectorHandler::CloseHandler,&mCloseHandler); + removeHandler(VectorHandler::CommandHandler,&mCommandHandler); + removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler); +} + +DiveDlg &DiveDlg::operator=(const DiveDlg &someDiveDlg) +{ + return *this; +} + +bool DiveDlg::perform(void) +{ + return ::DialogBoxParam(processInstance(),(LPSTR)"DIVEBOOK",(HWND)0,DWindow::DlgProc,(LPARAM)(DWindow*)this); +} + +CallbackData::ReturnType DiveDlg::initHandler(CallbackData &someCallbackData) +{ + String strClass; + + ::GetClassName(*this,strClass,String::MaxString); + ::SetClassLong(*this,GCL_HICON,(LONG)::LoadIcon(processInstance(),"APPICON")); + PureMenu windowMenu(::GetMenu(*this)); + windowMenu.getSubMenu(0,windowMenu); + windowMenu.enableMenuItem(APPMENU_FILE_SAVEWORKSHEET,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemDisabled|PureMenu::ItemGrayed)); + windowMenu.enableMenuItem(APPMENU_FILE_SAVERAW,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemDisabled|PureMenu::ItemGrayed)); + windowMenu.enableMenuItem(APPMENU_FILE_SAVETEXT,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemDisabled|PureMenu::ItemGrayed)); + mOwnerDrawGraph=new OwnerDrawGraph(*this,getItem(DB_GRAPH),DB_GRAPH); + mOwnerDrawGraph.disposition(PointerDisposition::Delete); + setCaption(String(STRING_APPNAME)+String(" ")+String(STRING_VERSION)); + Block logStopArray; + Block profileStopArray; + mLogList=new OwnerDrawListAltColor(*this,getItem(DB_LOGLIST),DB_LOGLIST); + mLogList.disposition(PointerDisposition::Delete); + mProfileList=new OwnerDrawListAltColor(*this,getItem(DB_PFLIST),DB_PFLIST); + mProfileList.disposition(PointerDisposition::Delete); + logStopArray.insert(&PureDWORD(50)); + logStopArray.insert(&PureDWORD(70)); + logStopArray.insert(&PureDWORD(92)); + logStopArray.insert(&PureDWORD(112)); + logStopArray.insert(&PureDWORD(130)); + mLogList->setTabStops(logStopArray); + profileStopArray.insert(&PureDWORD(5)); + profileStopArray.insert(&PureDWORD(25)); + profileStopArray.insert(&PureDWORD(50)); + mProfileList->setTabStops(profileStopArray); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType DiveDlg::createHandler(CallbackData &someCallbackData) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType DiveDlg::closeHandler(CallbackData &someCallbackData) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType DiveDlg::destroyHandler(CallbackData &someCallbackData) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType DiveDlg::commandHandler(CallbackData &someCallbackData) +{ + switch(someCallbackData.wmCommandID()) + { + case APPMENU_FILE_EXIT : + case IDCANCEL : + handleCancel(); + break; + case APPMENU_FILE_OPEN : + handleFileOpen(); + break; + case APPMENU_FILE_IMPORT : + handleImport(); + break; + case APPMENU_FILE_SAVEWORKSHEET : + handleSaveAsWorksheet(); + break; + case APPMENU_FILE_SAVERAW : + handleSaveAsRaw(); + break; + case APPMENU_FILE_SAVETEXT : + handleSaveAsText(); + break; + case APPMENU_SETTINGS_SERIAL : + handleSerialSettings(); + break; + case APPMENU_HELP_ABOUT : + handleHelpAbout(); + break; + case APPMENU_HELP_REGISTER : + handleHelpRegister(); + break; + case APPMENU_HELP_HELP : + handleHelpHelp(); + break; + case APPMENU_HELP_HOME : + handleHelpHome(); + break; + case DB_PROFILES : + if(CBN_SELCHANGE==someCallbackData.wmCommandCommand()) + handleProfileChange(); + break; + } + return (CallbackData::ReturnType)FALSE; +} + +void DiveDlg::handleCancel() +{ + endDialog(false); +} + +void DiveDlg::handleOk() +{ + endDialog(true); +} + +void DiveDlg::handleSerialSettings() +{ + SerialDlg serialDlg; + serialDlg.perform(*this); +} + +void DiveDlg::handleFileOpen() +{ + PureMenu windowMenu(::GetMenu(*this)); + AppReg appReg; + + if(!mDiveProfile.openDevice(appReg.getPort(),*this))return; +// if(mDiveProfile.isOkay()) +// { +// ::MessageBox(*this,"Merge into currently loaded log?","Confirm",MB_YESNOCANCEL); +// } + windowMenu.getSubMenu(0,windowMenu); + windowMenu.enableMenuItem(APPMENU_FILE_SAVEWORKSHEET,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemEnabled)); + windowMenu.enableMenuItem(APPMENU_FILE_SAVERAW,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemEnabled)); + windowMenu.enableMenuItem(APPMENU_FILE_SAVETEXT,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemEnabled)); + setCaption(String(STRING_APPNAME)+String(" ")+String(STRING_VERSION)+String(" (Device:")+appReg.getPort()+String(")")); + setData(mDiveProfile); +} + +void DiveDlg::handleImport() +{ + PureMenu windowMenu(::GetMenu(*this)); + OpenDialog openDialog; + String strPathFileName; + LRESULT result; + + if(!openDialog.getOpenFileName(*this,"*.dat","Open File","*.dat",strPathFileName))return; + if(mDiveProfile.isOkay()) + { + result=::MessageBox(*this,"Merge into currently loaded log?","Confirm",MB_YESNOCANCEL); + } + if(!mDiveProfile.openFile(strPathFileName)) + { + ::MessageBox(*this,"File is not in Aladin data format","Error",MB_OK); + return; + } + setCaption(String(STRING_APPNAME)+String(" ")+String(STRING_VERSION)+String(" (")+strPathFileName+String(")")); + windowMenu.getSubMenu(0,windowMenu); + windowMenu.enableMenuItem(APPMENU_FILE_SAVEWORKSHEET,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemEnabled)); + windowMenu.enableMenuItem(APPMENU_FILE_SAVERAW,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemEnabled)); + windowMenu.enableMenuItem(APPMENU_FILE_SAVETEXT,PureMenu::ByCommand,PureMenu::InsertFlags(PureMenu::ItemEnabled)); + setData(mDiveProfile); +} + +void DiveDlg::setData(Aladin &diveInfo) +{ + const Information &information=diveInfo.getInformation(); + const CurrentStatus &status=diveInfo.getStatus(); + const LogBook &logBook=diveInfo.getLogBook(); + const Profiles &profiles=diveInfo.getProfile(); + int index; + + mLogList->resetContent(); + mProfileList->resetContent(); + sendMessage(DB_PROFILES,CB_RESETCONTENT,0,0L); + setText(DB_COMPUTER,information.getComputerTypeString()); + setText(DB_BATTERY,String().fromDouble(status.getRemainingBattery())); + setText(DB_STANDARD,information.getStandardString()); + sendMessage(DB_NITROX,BM_SETCHECK,information.isNitrox(),0L); + sendMessage(DB_O2,BM_SETCHECK,information.isO2(),0L); + for(index=0;indexaddString(str); + } + for(index=0;indexresetContent(); + DiveProfile &diveProfile=((Block&)profiles)[index]; + for(index=0;indexaddString(str); + } + mOwnerDrawGraph->setData(diveProfile); + mOwnerDrawGraph->invalidate(); +} + +void DiveDlg::handleSaveAsWorksheet() +{ + OpenDialog openDialog; + String strPathFileName; + + if(!openDialog.getSaveFileName(".123","Save As Lotus Worksheet","",strPathFileName))return; + if(!mDiveProfile.saveWorksheet(strPathFileName)) + { + ::MessageBox(*this,"Error saving file.","Error",MB_OK); + return; + } +} + +void DiveDlg::handleSaveAsRaw() +{ + OpenDialog openDialog; + String strPathFileName; + + if(!openDialog.getSaveFileName(".dat","Save As Raw Data","",strPathFileName))return; + if(!mDiveProfile.saveRaw(strPathFileName)) + { + ::MessageBox(*this,"Error saving file.","Error",MB_OK); + return; + } +} + +void DiveDlg::handleSaveAsText() +{ + OpenDialog openDialog; + String strPathFileName; + + if(!openDialog.getSaveFileName(".txt","Save As Text","",strPathFileName))return; + if(!mDiveProfile.saveText(strPathFileName)) + { + ::MessageBox(*this,"Error saving file.","Error",MB_OK); + return; + } +} + +void DiveDlg::handleHelpAbout() +{ + SplashScreen splashScreen("SPLASH",String(STRING_SPLASHURL),String(STRING_APPNAME)); + splashScreen.perform(); +} + +void DiveDlg::handleHelpHelp() +{ + RegKey regKey(RegKey::LocalMachine); + String strCommand; + Process process; + + if(!regKey.openKey(String(STRING_BROWSERKEY)))return; + if(!regKey.enumValue(0,String(STRING_BROWSERCOMMAND),strCommand)||strCommand.isNull()) + { + ::MessageBox(*this,"Cannot locate default browser","Help->Home",MB_OK); + return; + } + strCommand.removeTokens("'\""); + process.createProcess(strCommand,String(" ")+String(STRING_HOST)+String(STRING_HELPPAGE),false); +} + +void DiveDlg::handleHelpRegister() +{ + RegKey regKey(RegKey::LocalMachine); + String strCommand; + Process process; + + if(!regKey.openKey(String(STRING_BROWSERKEY)))return; + if(!regKey.enumValue(0,String(STRING_BROWSERCOMMAND),strCommand)||strCommand.isNull()) + { + ::MessageBox(*this,"Cannot locate default browser","Help->Home",MB_OK); + return; + } + strCommand.removeTokens("'\""); + process.createProcess(strCommand,String(" ")+String(STRING_HOST)+String(STRING_REGISTERPAGE),false); +} + +void DiveDlg::handleHelpHome() +{ + RegKey regKey(RegKey::LocalMachine); + String strCommand; + Process process; + + if(!regKey.openKey(String(STRING_BROWSERKEY)))return; + if(!regKey.enumValue(0,String(STRING_BROWSERCOMMAND),strCommand)||strCommand.isNull()) + { + ::MessageBox(*this,"Cannot locate default browser","Help->Home",MB_OK); + return; + } + strCommand.removeTokens("'\""); + process.createProcess(strCommand,String(" ")+String(STRING_HOST)+String(STRING_HOMEPAGE),false); +} + + diff --git a/aladin/hold/divedlg.hpp b/aladin/hold/divedlg.hpp new file mode 100644 index 0000000..ddd2043 --- /dev/null +++ b/aladin/hold/divedlg.hpp @@ -0,0 +1,67 @@ +#ifndef _ALADIN_DIVEDLG_HPP_ +#define _ALADIN_DIVEDLG_HPP_ +#ifndef _COMMON_DWINDOW_HPP_ +#include +#endif +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif +#ifndef _COMMON_GLOBALDATA_HPP_ +#include +#endif +#ifndef _COMMON_CONTROL_HPP_ +#include +#endif +#ifndef _ALADIN_ALADIN_HPP_ +#include +#endif + +class OwnerDrawListAltColor; +class OwnerDrawGraph; +class Worksheet; +class Profile; +class LogBook; + +class DiveDlg : public DWindow +{ +public: + DiveDlg(void); + virtual ~DiveDlg(); + bool perform(void); +private: + enum{StatusBarID=101}; + DiveDlg(const DiveDlg &someDiveDlg); + DiveDlg &operator=(const DiveDlg &someDiveDlg); + CallbackData::ReturnType initHandler(CallbackData &someCallbackData); + CallbackData::ReturnType createHandler(CallbackData &someCallbackData); + CallbackData::ReturnType closeHandler(CallbackData &someCallbackData); + CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData); + CallbackData::ReturnType commandHandler(CallbackData &someCallbackData); + void handleCancel(void); + void handleOk(void); + void setData(Aladin &diveInfo); + void handleImport(void); + void handleFileOpen(); + void handleProfileChange(void); + void handleSaveAsWorksheet(void); + void handleSaveAsRaw(void); + void handleSaveAsText(void); + void handleSerialSettings(void); + void handleHelpAbout(void); + void handleHelpRegister(void); + void handleHelpHome(void); + void handleHelpHelp(void); + void addDiveLog(Worksheet &worksheet,const LogBook &logBook,int startRow,int startCol); + void addProfile(Worksheet &worksheet,const Profile &profile,int startRow,int startCol); + + Callback mInitHandler; + Callback mCreateHandler; + Callback mCloseHandler; + Callback mDestroyHandler; + Callback mCommandHandler; + SmartPointer mLogList; + SmartPointer mProfileList; + SmartPointer mOwnerDrawGraph; + Aladin mDiveProfile; +}; +#endif diff --git a/aladin/hold/divelog.cpp b/aladin/hold/divelog.cpp new file mode 100644 index 0000000..0eed436 --- /dev/null +++ b/aladin/hold/divelog.cpp @@ -0,0 +1,95 @@ +#include +#include + +DiveLog::DiveLog() +{ + mExtraInfo=0; + mBottomTime=0; + mMaxDepthHi=0; + mMaxDepthLo=0; + mSurfaceTimeHi=0; + mSurfaceTimeLo=0; + mTotalAirConsumption=0; + mEntryTime1=0; + mEntryTime2=0; + mEntryTime3=0; + mEntryTime4=0; + mWaterTemperature=0; +} + +DiveLog::~DiveLog() +{ +} + +bool DiveLog::operator<(const DiveLog &diveLog)const +{ + return getEntryTime()(const DiveLog &diveLog)const +{ + return getEntryTime()>diveLog.getEntryTime(); +} + +int DiveLog::getBottomTime(void)const +{ + int bottomTime=(((mBottomTime>>4)*10))+(mBottomTime&0x0F); + if(mExtraInfo&0x04)bottomTime+=100; + return bottomTime; +} + +int DiveLog::getMaxDepth(void)const +{ + double maxDepth(((double)((mMaxDepthHi*256)+mMaxDepthLo)*10.00)/4096.00); + return int((maxDepth*3.281)+.5); +} + +int DiveLog::getAltitude(void)const +{ + return 0; +} + +int DiveLog::getWaterTemperature(void)const +{ + return mWaterTemperature/4; +} + +SystemTime DiveLog::getEntryTime(void)const +{ + return DiveTime(mEntryTime1,mEntryTime2,mEntryTime3,mEntryTime4).getTime(); +} + +Time DiveLog::getSurfaceTime(void)const +{ + return Time(mSurfaceTimeHi,mSurfaceTimeLo); +} + +bool DiveLog::readFrom(Array &array,int &index) +{ + try + { + mExtraInfo=array[index++]; + mBottomTime=array[index++]; + mMaxDepthHi=array[index++]; + mMaxDepthLo=array[index++]; + mSurfaceTimeHi=array[index++]; + mSurfaceTimeLo=array[index++]; + mTotalAirConsumption=array[index++]; + mEntryTime1=array[index++]; + mEntryTime2=array[index++]; + mEntryTime3=array[index++]; + mEntryTime4=array[index++]; + mWaterTemperature=array[index++]; + } + catch(ArrayIndexOutOfBoundsException exception) + { + ::OutputDebugString(exception.toString()+String("\n")); + return false; + } + return true; +} diff --git a/aladin/hold/divelog.hpp b/aladin/hold/divelog.hpp new file mode 100644 index 0000000..bd02ce9 --- /dev/null +++ b/aladin/hold/divelog.hpp @@ -0,0 +1,54 @@ +#ifndef _ALADIN_DIVELOG_HPP_ +#define _ALADIN_DIVELOG_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_ARRAY_HPP_ +#include +#endif +#ifndef _COMMON_STDIO_HPP_ +#include +#endif +#ifndef _COMMON_MATH_HPP_ +#include +#endif +#ifndef _COMMON_SYSTEMTIME_HPP_ +#include +#endif +#ifndef _ALADIN_STATUS_HPP_ +#include +#endif +#ifndef _ALADIN_TIME_HPP_ +#include +#endif + +class DiveLog +{ +public: + DiveLog(); + virtual ~DiveLog(); + bool readFrom(Array &array,int &index); + int getAltitude(void)const; + int getMaxDepth(void)const; + SystemTime getEntryTime(void)const; + int getWaterTemperature(void)const; + int getBottomTime(void)const; + Time getSurfaceTime(void)const; + bool operator<(const DiveLog &diveLog)const; + bool operator>(const DiveLog &diveLog)const; + bool operator==(const DiveLog &diveLog)const; +private: + BYTE mExtraInfo; + BYTE mBottomTime; + BYTE mMaxDepthHi; + BYTE mMaxDepthLo; + BYTE mSurfaceTimeHi; + BYTE mSurfaceTimeLo; + BYTE mTotalAirConsumption; + BYTE mEntryTime1; + BYTE mEntryTime2; + BYTE mEntryTime3; + BYTE mEntryTime4; + BYTE mWaterTemperature; +}; +#endif diff --git a/aladin/hold/diveprofile.cpp b/aladin/hold/diveprofile.cpp new file mode 100644 index 0000000..4d6823b --- /dev/null +++ b/aladin/hold/diveprofile.cpp @@ -0,0 +1,10 @@ +#include + +DiveProfile::DiveProfile() +{ +} + +DiveProfile::~DiveProfile() +{ +} + diff --git a/aladin/hold/diveprofile.hpp b/aladin/hold/diveprofile.hpp new file mode 100644 index 0000000..01425e1 --- /dev/null +++ b/aladin/hold/diveprofile.hpp @@ -0,0 +1,17 @@ +#ifndef _ALADIN_DIVEPROFILE_HPP_ +#define _ALADIN_DIVEPROFILE_HPP_ +#ifndef _COMMON_BLOCK_HPP_ +#include +#endif +#ifndef _ALADIN_PROFILEDATA_HPP_ +#include +#endif + +class DiveProfile : public Block +{ +public: + DiveProfile(); + virtual ~DiveProfile(); +private: +}; +#endif \ No newline at end of file diff --git a/aladin/hold/divetime.hpp b/aladin/hold/divetime.hpp new file mode 100644 index 0000000..212fe7b --- /dev/null +++ b/aladin/hold/divetime.hpp @@ -0,0 +1,62 @@ +#ifndef _ALADIN_DIVETIME_HPP_ +#define _ALADIN_DIVETIME_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_SYSTEMTIME_HPP_ +#include +#endif +#ifndef _COMMON_MATH_HPP_ +#include +#endif +#ifndef _COMMON_SDATE_HPP_ +#include +#endif + +class DiveTime +{ +public: + DiveTime(); + DiveTime(BYTE b1,BYTE b2,BYTE b3,BYTE b4); + virtual ~DiveTime(); + const SystemTime &setTime(BYTE b1,BYTE b2,BYTE b3,BYTE b4); + const SystemTime &getTime(void)const; +private: + SystemTime mDiveTime; +}; + +inline +DiveTime::DiveTime() +{ +} + +inline +DiveTime::DiveTime(BYTE b1,BYTE b2,BYTE b3,BYTE b4) +{ + setTime(b1,b2,b3,b4); +} + +inline +DiveTime::~DiveTime() +{ +} + +inline +const SystemTime &DiveTime::setTime(BYTE b1,BYTE b2,BYTE b3,BYTE b4) +{ + int entryTime=b1*Math::power(2,24)+b2*Math::power(2,16)+b3*Math::power(2,8)+b4; + int divisor=entryTime/172800; + int remainder=entryTime%172800; + int hours=remainder/7200; + int minutes=(remainder/120)%60; + SDate entryDate=SDate().daysAddActual(SDate(1,1,1994),divisor); + mDiveTime.makeTime(entryDate.year(),entryDate.month(),entryDate.day(),hours,minutes,0); + return mDiveTime; +} + +inline +const SystemTime &DiveTime::getTime(void)const +{ + return mDiveTime; +} +#endif diff --git a/aladin/hold/graph.cpp b/aladin/hold/graph.cpp new file mode 100644 index 0000000..e08e028 --- /dev/null +++ b/aladin/hold/graph.cpp @@ -0,0 +1,167 @@ +#include +#include +#include +#include +#include +#include + +OwnerDrawGraph::OwnerDrawGraph(GUIWindow &parentWnd,HWND hControlWnd,UINT controlID) +: mParentWnd(parentWnd), Control(hControlWnd,controlID) +{ + PureDevice pureDevice(*this); + mBkGndBrush.createHatchBrush(Brush::HDiag,RGBColor(255,0,0)); + + mDIBitmap=new DIB24(); + mDIBitmap.disposition(PointerDisposition::Delete); + mDIBitmap->create(width(),height(),pureDevice); + + mDrawItemHandler.setCallback(this,&OwnerDrawGraph::drawItemHandler); + mControlColorHandler.setCallback(this,&OwnerDrawGraph::controlColorHandler); + mParentWnd.insertHandler(VectorHandler::DrawItemHandler,&mDrawItemHandler); + mParentWnd.insertHandler(VectorHandler::ControlColorHandler,&mControlColorHandler); +} + +OwnerDrawGraph::~OwnerDrawGraph() +{ + mParentWnd.removeHandler(VectorHandler::DrawItemHandler,&mDrawItemHandler); + mParentWnd.removeHandler(VectorHandler::ControlColorHandler,&mControlColorHandler); +} + +CallbackData::ReturnType OwnerDrawGraph::drawItemHandler(CallbackData &someCallbackData) +{ + DrawItem drawItem(*((LPDRAWITEMSTRUCT)someCallbackData.lParam())); + if(drawItem.controlID()!=controlID())return (CallbackData::ReturnType)TRUE; + return handleDraw(drawItem); +} + +CallbackData::ReturnType OwnerDrawGraph::controlColorHandler(CallbackData &someCallbackData) +{ + Control wndButton((HWND)someCallbackData.lParam(),::GetDlgCtrlID((HWND)someCallbackData.lParam()),FALSE); + if(!(*this==wndButton))return (CallbackData::ReturnType)FALSE; + PureDevice pureDevice((HDC)someCallbackData.wParam()); + return handleControlColor(pureDevice,wndButton); +} + +void OwnerDrawGraph::drawBitmap(const DrawItem &drawItem) +{ + PureDevice displayDevice(drawItem.deviceContext()); + mDIBitmap->bitBlt(displayDevice,Rect(0,0,width(),height()),Point(0,0)); +} + +// *************** virtuals + +WORD OwnerDrawGraph::handleDraw(const DrawItem &drawItem) +{ + WORD retCode(TRUE); + + switch(drawItem.itemAction()) + { + case ODA_DRAWENTIRE : + drawEntire(drawItem); + break; + case ODA_SELECT : + retCode=drawSelect(drawItem); + break; + case ODA_FOCUS : + drawFocus(drawItem); + break; + } + return retCode; +} + +WORD OwnerDrawGraph::handleMeasureItem(MeasureItem &/*measureItem*/) +{ + return TRUE; +} + +LPARAM OwnerDrawGraph::handleControlColor(PureDevice &/*pureDevice*/,Control &/*wndButton*/) +{ + return (CallbackData::ReturnType)mBkGndBrush.getBrush(); +} + +void OwnerDrawGraph::drawEntire(const DrawItem &drawItem) +{ + if(drawItem.itemState()&ODS_SELECTED)drawBitmap(drawItem); + else if(drawItem.itemState()&ODS_FOCUS)drawBitmap(drawItem); + else if(drawItem.itemState()&ODS_DISABLED)drawBitmap(drawItem); + else drawBitmap(drawItem); + drawButtonText(drawItem); + drawButtonLines(drawItem); + return; +} + +WORD OwnerDrawGraph::drawSelect(const DrawItem &drawItem) +{ + WORD retCode(TRUE); + if(drawItem.itemState()&ODS_SELECTED)drawBitmap(drawItem); + else {drawBitmap(drawItem);retCode=FALSE;} + drawButtonText(drawItem); + drawButtonLines(drawItem); + return retCode; +} + +void OwnerDrawGraph::drawFocus(const DrawItem &drawItem) +{ + if(drawItem.itemState()&ODS_FOCUS)drawBitmap(drawItem); + else drawBitmap(drawItem); + drawButtonText(drawItem); + drawButtonLines(drawItem); + return; +} + +void OwnerDrawGraph::drawButtonText(const DrawItem &drawItem) +{ + +/* TEXTMETRIC textMetric; + Rect drawRect; + String strText; + PureDevice controlDevice(drawItem.deviceContext()); + + windowText(strText); + if(strText.isNull())return; + controlDevice.setBkMode(PureDevice::Transparent); + controlDevice.select((GDIObj)mTextFont,TRUE); + controlDevice.setTextColor(textColor()); + ::GetTextMetrics(drawItem.deviceContext(),&textMetric); + drawRect=drawItem.rectItem(); + controlDevice.textOut(0,(drawRect.bottom()+drawRect.top()-textMetric.tmHeight)/2,strText); + controlDevice.select((GDIObj)mTextFont,FALSE); */ +} + +void OwnerDrawGraph::drawButtonLines(const DrawItem &drawItem) +{ + PureDevice controlDevice(drawItem.deviceContext()); + controlDevice.line(Point(0,0),Point(width(),0),RGBColor(0,0,0)); + controlDevice.line(Point(0,0),Point(0,height()),RGBColor(0,0,0)); + controlDevice.line(Point(0,height()-1),Point(width(),height()-1),RGBColor(255,255,255)); + controlDevice.line(Point(width(),height()-1),Point(width()-1,0),RGBColor(255,255,255)); +} + +void OwnerDrawGraph::setData(DiveProfile &diveProfile) +{ + Block &profileData=(Block &)diveProfile; + + double wRatio=(double)width()/(double)profileData.size(); + double hRatio=(double)height()/getMaxDepth(profileData); + double x=wRatio; + + mDIBitmap->setBits(0); + for(int index=0;indexline(Point(x,0),Point(x,(int)(double)pData.getDepth()*(double)hRatio),RGB888(0,255,0)); + x+=wRatio; + } +} + +int OwnerDrawGraph::getMaxDepth(Block &profileData) +{ + int maxDepth(0); + + for(int index=0;indexmaxDepth)maxDepth=pData.getDepth(); + } + return maxDepth; +} diff --git a/aladin/hold/graph.hpp b/aladin/hold/graph.hpp new file mode 100644 index 0000000..25e179a --- /dev/null +++ b/aladin/hold/graph.hpp @@ -0,0 +1,48 @@ +#ifndef _ALADIN_OWNERDRAWGRAPH_HPP_ +#define _ALADIN_OWNERDRAWGRAPH_HPP_ +#ifndef _COMMON_CONTROL_HPP_ +#include +#endif +#ifndef _COMMON_BRUSH_HPP_ +#include +#endif +#ifndef _ALADIN_DIVEPROFILE_HPP_ +#include +#endif + +class DrawItem; +class MeasureItem; +class PureDevice; +class DIB24; + +class OwnerDrawGraph : public Control +{ +public: + OwnerDrawGraph(GUIWindow &parentWnd,HWND hControlWnd,UINT controlID); + virtual ~OwnerDrawGraph(); + void setData(DiveProfile &diveProfile); +protected: + virtual WORD handleDraw(const DrawItem &drawItem); + virtual WORD handleMeasureItem(MeasureItem &measureItem); + virtual LPARAM handleControlColor(PureDevice &pureDevice,Control &wndButton); + virtual void drawEntire(const DrawItem &drawItem); + virtual WORD drawSelect(const DrawItem &drawItem); + virtual void drawFocus(const DrawItem &drawItem); + virtual void drawButtonText(const DrawItem &drawItem); + virtual void drawButtonLines(const DrawItem &drawItem); +private: + OwnerDrawGraph &operator=(const OwnerDrawGraph &someOwnerDrawGraph); + void drawBitmap(const DrawItem &drawItem); + CallbackData::ReturnType drawItemHandler(CallbackData &someCallbackData); + CallbackData::ReturnType controlColorHandler(CallbackData &someCallbackData); + int getMaxDepth(Block &profileData); + + Callback mDrawItemHandler; + Callback mMeasureItemHandler; + Callback mControlColorHandler; + SmartPointer mDiveProfile; + SmartPointer mDIBitmap; + Brush mBkGndBrush; + GUIWindow &mParentWnd; +}; +#endif diff --git a/aladin/hold/information.cpp b/aladin/hold/information.cpp new file mode 100644 index 0000000..bef3c48 --- /dev/null +++ b/aladin/hold/information.cpp @@ -0,0 +1,90 @@ +#include + +Information::Information() +{ + mComputerType=0; + mExtraInfo1=0; +} + +Information::~Information() +{ +} + +bool Information::readFrom(Array &array) +{ + try + { + mComputerType=array[0x7BC]; + mExtraInfo1=array[0x7D2]; + } + catch(ArrayIndexOutOfBoundsException exception) + { + ::OutputDebugString(exception.toString()+String("\n")); + return false; + } + return true; +} + +Information::Model Information::getComputerType(void)const +{ + switch(mComputerType) + { + case 0x40 : + return MaresGenius; + case 0x34 : + return AladinAirZ; + case 0x44 : + return AladinAirZ; + case 0xA4 : + return AladinAirZO2; + case 0xF4 : + return AladinAirXNitrox; + case 0x48 : + return SpiroMonitor3Air; + case 0x1C : + return AladinAirTwin; + case 0x1D : + case 0x3D : + return SpiroMonitor2Plus; + case 0x1E : + case 0x3E : + return AladinSportPlus; + case 0x1F : + case 0x3F : + return AladinPro; + case 0xFF : + return AladinProUltra; + default : + return Unknown; + } +} + +String Information::getComputerTypeString(void)const +{ + switch(getComputerType()) + { + case MaresGenius : + return "Mares Genius"; + case AladinAirZ : + return "Aladin Air Z/Aladin Air X"; + case AladinAirZO2 : + return "Aladin Air Z O2/Aladin Air X O2"; + case AladinAirXNitrox : + return "Aladin Air X Nitrox"; + case SpiroMonitor3Air : + return "Spiro Monitor 3 Air"; + case AladinAirTwin : + return "Aladin Air Twin/Aladin Air"; + case SpiroMonitor2Plus : + return "Spiro Monitor 2 Plus"; + case AladinSportPlus : + return "Aladin Sport Plus/Aladin Sport"; + case AladinPro : + return "Aladin Pro"; + case AladinProUltra : + return "Aladin Pro Ultra/Aladin Pro Nitrox"; + case Unknown : + default : + return "Unknown"; + } +} diff --git a/aladin/hold/information.hpp b/aladin/hold/information.hpp new file mode 100644 index 0000000..c8827fa --- /dev/null +++ b/aladin/hold/information.hpp @@ -0,0 +1,75 @@ +#ifndef _ALADIN_INFORMATION_HPP_ +#define _ALADIN_INFORMATION_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_ARRAY_HPP_ +#include +#endif + +class Information +{ +public: + typedef enum Model{MaresGenius=0x40,AladinAirZ,AladinAirZO2,AladinAirXNitrox,SpiroMonitor3Air, + AladinAirTwin,SpiroMonitor2Plus,AladinSportPlus,AladinPro,AladinProUltra,Unknown}; + typedef enum Standard{Imperial,Metric}; + Information(); + virtual ~Information(); + Model getComputerType(void)const; + String getComputerTypeString(void)const; + bool isNitrox(void)const; + bool isO2(void)const; + bool isNitroxOnly(void)const; + bool readFrom(Array &array); + Standard getStandard(void)const; + String getStandardString(void)const; + bool getBeep(void)const; +private: + BYTE mComputerType; + BYTE mExtraInfo1; +}; + + +inline +bool Information::isNitrox(void)const +{ + Model model(getComputerType()); + if(AladinAirXNitrox==model||AladinAirZO2==model||AladinProUltra==model)return true; + return false; +} + + +inline +bool Information::isO2(void)const +{ + Model model(getComputerType()); + if(AladinAirZO2==model)return true; + return false; +} + +inline +bool Information::isNitroxOnly(void)const +{ + if(isNitrox()&&!isO2())return true; + return false; +} + +inline +Information::Standard Information::getStandard(void)const +{ + return (mExtraInfo1&0x01)?Imperial:Metric; +} + +inline +String Information::getStandardString(void)const +{ + if(Metric==getStandard())return "Metric"; + return "Imperial"; +} + +inline +bool Information::getBeep(void)const +{ + return (mExtraInfo1&0x01)?true:false; +} +#endif \ No newline at end of file diff --git a/aladin/hold/logbook.cpp b/aladin/hold/logbook.cpp new file mode 100644 index 0000000..1e58960 --- /dev/null +++ b/aladin/hold/logbook.cpp @@ -0,0 +1,35 @@ +#include +#include + +LogBook::LogBook() +{ +} + +LogBook::~LogBook() +{ +} + +bool LogBook::readFrom(Array &array,CurrentStatus &status) +{ + QuickSort quickSort; + int index=0x600; + + remove(); + for(int logIndex=0;logIndex<37;logIndex++) + { + DiveLog diveLog; + if(diveLog.readFrom(array,index))insert(&diveLog); + } + quickSort.sortItems(*this,SortOptions::Descending); +/* for(index=0;index +#endif +#ifndef _COMMON_BLOCK_HPP_ +#include +#endif +#ifndef _ALADIN_DIVELOG_HPP_ +#include +#endif + +class LogBook : public Block +{ +public: + LogBook(); + virtual ~LogBook(); + bool readFrom(Array &array,CurrentStatus &status); +private: +}; +#endif \ No newline at end of file diff --git a/aladin/hold/mainfrm.cpp b/aladin/hold/mainfrm.cpp new file mode 100644 index 0000000..8758a48 --- /dev/null +++ b/aladin/hold/mainfrm.cpp @@ -0,0 +1,490 @@ +//#include +//#include +//#include +//#include +//#include +//#include +#include +#include +#include +#include +#include +#include + +char MainFrame::szClassName[]="Aladin"; +char MainFrame::szMenuName[]="mainMenu"; + +MainFrame::MainFrame(void) +{ + mQueryEndSessionHandler.setCallback(this,&MainFrame::queryEndSessionHandler); + mPaintHandler.setCallback(this,&MainFrame::paintHandler); + mDestroyHandler.setCallback(this,&MainFrame::destroyHandler); + mCommandHandler.setCallback(this,&MainFrame::commandHandler); + mSizeHandler.setCallback(this,&MainFrame::sizeHandler); + mCreateHandler.setCallback(this,&MainFrame::createHandler); + insertHandlers(); +} + +MainFrame::~MainFrame() +{ + destroy(); +} + +void MainFrame::insertHandlers(void) +{ + insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + insertHandler(VectorHandler::PaintHandler,&mPaintHandler); + insertHandler(VectorHandler::CommandHandler,&mCommandHandler); + insertHandler(VectorHandler::SizeHandler,&mSizeHandler); + insertHandler(VectorHandler::CreateHandler,&mCreateHandler); + insertHandler(VectorHandler::QueryEndSessionHandler,&mQueryEndSessionHandler); +} + +void MainFrame::removeHandlers(void) +{ + removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + removeHandler(VectorHandler::PaintHandler,&mPaintHandler); + removeHandler(VectorHandler::CommandHandler,&mCommandHandler); + removeHandler(VectorHandler::SizeHandler,&mSizeHandler); + removeHandler(VectorHandler::CreateHandler,&mCreateHandler); + removeHandler(VectorHandler::QueryEndSessionHandler,&mQueryEndSessionHandler); +} + +CallbackData::ReturnType MainFrame::createHandler(CallbackData &/*someCallbackData*/) +{ + GlobalData statParts; + + createToolBar(); + mStatusBar=::new StatusBarEx(*this,StatusBarID); + mStatusBar.disposition(PointerDisposition::Delete); + statParts.size(2); + *((int*)&statParts[0])=300; + *((int*)&statParts[1])=400; + mStatusBar->setParts(statParts); + mStatusBar->setText("Ready"); + applyHistory(getFrameMenu()); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainFrame::destroyHandler(CallbackData &/*someCallbackData*/) +{ + removeHandlers(); + ::PostQuitMessage(0); + ::WinHelp(*this,0,HELP_QUIT,0); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainFrame::queryEndSessionHandler(CallbackData &someCallbackData) +{ + if(getClient().hasChildren())return (CallbackData::ReturnType)FALSE; + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainFrame::sizeHandler(CallbackData &someCallbackData) +{ + Rect statusRect; + Rect toolRect; + Rect cRect; + + mToolBar.windowRect(toolRect); + mStatusBar->windowRect(statusRect); + cRect.right(someCallbackData.loWord()); + cRect.bottom(someCallbackData.hiWord()); + getClient().moveWindow(0,toolRect.bottom()-toolRect.top(),cRect.right(),cRect.bottom()-((statusRect.bottom()-statusRect.top())+(toolRect.bottom()-toolRect.top()))); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainFrame::paintHandler(CallbackData &/*someCallbackData*/) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainFrame::commandHandler(CallbackData &someCallbackData) +{ + switch(someCallbackData.wmCommandID()) + { + case MenuCodeCompile : + handleCodeCompile(); + break; + case MenuCodeCompileAndLoad : + handleCodeCompileAndLoad(); + break; + case MenuEditCut : + handleEditCut(); + break; + case MenuEditCopy : + handleEditCopy(); + break; + case MenuEditPaste : + handleEditPaste(); + break; + case MenuEditFind : + handleEditFind(); + break; + case MenuCascade : + cascade(); + break; + case MenuTile : + tile(); + break; + case MenuArrange : + arrange(); + break; + case MenuCloseAll : + closeAll(); + break; + case MenuMinimizeAll : + minimizeAll(); + break; + case MenuRestoreAll : + restoreAll(); + break; + case MenuFileNew : + handleFileNew(); + break; + case MenuFileOpen : + handleFileOpen(); + break; + case MenuFileSave : + handleFileSave(); + break; + case MenuFilePrint : + handleFilePrint(); + break; + case MenuFileSaveAs : + handleFileSaveAs(); + break; + case MenuFileClose : + handleFileClose(); + break; + case MenuFileQuit : + break; + case MenuSettingsSerial : + handleCommunications(); + break; + case MenuHelpContents : + handleHelp(); + break; + case MenuHelpSearch : + handleHelp(); + break; + case MenuRegistration : + break; + case MenuHelpAbout : + break; + } + if(someCallbackData.wParam()>=StartDynamicID)handleFileOpen(someCallbackData); + return (CallbackData::ReturnType)FALSE; +} + +// handlers + +void MainFrame::handleCodeCompile(void) +{ + CursorControl cursorControl; + SmartPointer mdiWindow; + String strMessage; + + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + CodeView &codeView=(CodeView&)*mdiWindow; + if(codeView.isDirty()&&IDYES==::MessageBox(*this,(LPSTR)"Save Changes?",(LPSTR)"M68HC11",MB_YESNO))if(!handleFileSave())return; + mStatusBar->setText("compiling..."); + cursorControl.waitCursor(TRUE); + m68Assembler.assemble(codeView.getTitle()); + cursorControl.waitCursor(FALSE); + strMessage=m68Assembler.strLastMessage()+String(", code size is ")+String().fromInt(m68Assembler.codeSize())+String(" byte(s)."); + mStatusBar->setText(strMessage); +} + +void MainFrame::handleCodeCompileAndLoad(void) +{ + CursorControl cursorControl; + BOOL assembleResult; + String strPathBinary; + String strMessage; + + SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + CodeView &codeView=(CodeView&)*mdiWindow; + if(codeView.isDirty()&&IDYES==::MessageBox(*this,(LPSTR)"Save Changes?",(LPSTR)"M68HC11",MB_YESNO))if(!handleFileSave())return; + mStatusBar->setText("compiling..."); + cursorControl.waitCursor(TRUE); + assembleResult=m68Assembler.assemble(codeView.getTitle()); + cursorControl.waitCursor(FALSE); + strMessage=m68Assembler.strLastMessage()+String(", code size is ")+String().fromInt(m68Assembler.codeSize())+String(" byte(s)."); + mStatusBar->setText(strMessage); + if(!assembleResult)return; + strPathBinary=codeView.getTitle().betweenString(0,'.'); + strPathBinary+=".bin"; + codeLoad(strPathBinary); +} + +void MainFrame::handleEditCut(void) +{ + SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + ((CodeView&)*mdiWindow).cut(); +} + +void MainFrame::handleEditCopy(void) +{ + SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + ((CodeView&)*mdiWindow).copy(); +} + +void MainFrame::handleEditPaste(void) +{ + SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + ((CodeView&)*mdiWindow).paste(); +} + +void MainFrame::handleEditFind(void) +{ + SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + ((CodeView&)*mdiWindow).find(); +} + +void MainFrame::handleFileNew(void) +{ +// CodeView *pCodeView; +// +// pCodeView=::new CodeView; +// pCodeView->setLineHandler(&mLineHandler); +// pCodeView->createWindow(*this,STRING_CODEVIEWCLASSNAME,STRING_CODEVIEWCLASSNAME,"codeMenu","Doc"); +// insert(*pCodeView); +} + +void MainFrame::handleFileOpen(CallbackData &someCallbackData) +{ +/* PureMenu fileMenu; + String menuItemString; + + getFrameMenu().getSubMenu(0,fileMenu); + menuItemString=fileMenu.menuItemString(someCallbackData.wParam(),PureMenu::ByCommand); + if(menuItemString.isNull())return; + menuItemString=menuItemString.betweenString(')',0); + menuItemString.trimLeft(); + handleFileOpen(menuItemString); */ +} + +void MainFrame::handleFileOpen(void) +{ +/* OpenDialog openDialog; + String strPathFileName; + + if(!openDialog.getOpenFileName(*this,"*.asm","Open File","*.asm",strPathFileName))return; + handleFileOpen(strPathFileName); */ +} + +void MainFrame::handleFileOpen(const String &strPathFileName) +{ +/* CodeView *pCodeView; + CursorControl cursorControl; + + if(bringDocumentToFront(strPathFileName))return; + mStatusBar->setText("Loading..."); + cursorControl.waitCursor(TRUE); + + pCodeView=::new CodeView; + insert(*pCodeView); // insert the pointer before creating/activating the window + pCodeView->createWindow(*this,STRING_CODEVIEWCLASSNAME,STRING_CODEVIEWCLASSNAME,"codeMenu","Doc"); + pCodeView->setLineHandler(&mLineHandler); + pCodeView->open(strPathFileName); + mStatusBar->setText("Ready"); + cursorControl.waitCursor(FALSE); + updateHistory(strPathFileName); */ +} + +void MainFrame::handleFileClose(void) +{ + SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + mdiWindow->close(); +} + +void MainFrame::handleFilePrint(void) +{ +/* SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + ((CodeView&)*mdiWindow).print(); */ +} + +BOOL MainFrame::handleFileSave(void) +{ +/* SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return FALSE; + CodeView &codeView=(CodeView&)*mdiWindow; + if(codeView.getTitle()==String(STRING_UNTITLED))return handleFileSaveAs(); + if(!codeView.save())return mStatusBar->setText(codeView.getTitle()+String(" save failed.")),FALSE; + return mStatusBar->setText(codeView.getTitle()+String(" saved.")),TRUE; */ + return TRUE; +} + +BOOL MainFrame::handleFileSaveAs(void) +{ +/* SmartPointer mdiWindow; + OpenDialog openDialog; + String strPathFileName; + + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return FALSE; + if(!openDialog.getSaveFileName(*this,"Assembly Files","File Save","*.asm",strPathFileName))return FALSE; + if(!strPathFileName.strstr(".asm"))strPathFileName+=".asm"; + if(!((CodeView&)*mdiWindow).save(strPathFileName))return mStatusBar->setText(strPathFileName+String(" save failed!.")),FALSE; + return mStatusBar->setText(strPathFileName+String(" saved.")),TRUE; */ + + return false; +} + +void MainFrame::handleCommunications(void) +{ +// SerialDlg serDlg; +// serDlg.perform(*this); +} + +void MainFrame::handleHelp(void) +{ + String strPathHelpFileName; + DiskInfo diskInfo; + + diskInfo.getCurrentDirectory(strPathHelpFileName); + strPathHelpFileName+=String(STRING_HELPFILENAME); + ::WinHelp(*this,strPathHelpFileName,HELP_CONTENTS,0); +} + +// support & testing +BOOL MainFrame::codeLoad(const String &strPathBinary) +{ +/* MCUView *pMCUView; + + pMCUView=::new MCUView; + pMCUView->createWindow(*this,STRING_MCUVIEWCLASSNAME,STRING_MCUVIEWCLASSNAME,"mcuMenu","Doc"); + insert(*pMCUView); + pMCUView->setCode(strPathBinary); */ + return TRUE; +} + +void MainFrame::setParts(int numParts) +{ + GlobalData statParts; + if(1==numParts){statParts.size(1);*((int*)&statParts[0])=FirstPartWidth;} + else {statParts.size(2);*((int*)&statParts[0])=FirstPartWidth;*((int*)&statParts[0]+1)=SecondPartWidth;} + mStatusBar->setParts(statParts); +} + +void MainFrame::updateHistory(const String &pathFileName) +{ +/* M68Reg m68Reg; + SmartPointer mdiWindow; + + if(!m68Reg.insertHistory(pathFileName))return; + removeHistory(getFrameMenu()); + applyHistory(getFrameMenu()); + if(getFirstDocument(mdiWindow)) + { + removeHistory(mdiWindow->getMenu()); + applyHistory(mdiWindow->getMenu()); + while(getNextDocument(mdiWindow)) + { + removeHistory(mdiWindow->getMenu()); + applyHistory(mdiWindow->getMenu()); + } + } */ +} + +void MainFrame::removeHistory(PureMenu &pureMenu) +{ +/* M68Reg m68Reg; + UINT startID(StartDynamicID); + Block nameList; + PureMenu fileMenu; + + m68Reg.getHistory(nameList); + if(!nameList.size())return; + pureMenu.getSubMenu(0,fileMenu); + for(int itemIndex=0;itemIndex nameList; + PureMenu fileMenu; + String strItem; + + m68Reg.getHistory(nameList); + if(!nameList.size())return; + pureMenu.getSubMenu(0,fileMenu); + fileMenu.appendSeparator(); + for(int itemIndex=0;itemIndex addBitmaps; + + mToolBar.create(*this,ToolBarID); + addBitmaps.insert(&AddBitmap(0,HINST_COMMCTRL)); + if(!mToolBar.addBitmaps(addBitmaps))return; + mToolBar.addButton(ToolBarButton(STD_FILENEW,MenuFileNew,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_FILEOPEN,MenuFileOpen,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_FILESAVE,MenuFileSave,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_PRINT,MenuFilePrint,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_CUT,MenuEditCut,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_COPY,MenuEditCopy,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_PASTE,MenuEditPaste,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_FIND,MenuEditFind,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_PRINT,MenuFilePrint,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); +} + +BOOL MainFrame::bringDocumentToFront(const String &strTitle) +{ + SmartPointer mdiWindowPtr; + + if(getFirstDocument(mdiWindowPtr)) + { + if(((CodeView&)*mdiWindowPtr).getTitle()==strTitle){mdiWindowPtr->bringWindowToTop();return TRUE;} + while(getNextDocument(mdiWindowPtr))if(((CodeView&)*mdiWindowPtr).getTitle()==strTitle){mdiWindowPtr->bringWindowToTop();return TRUE;} + } + return FALSE; +} + +void MainFrame::splash(void) +{ + SplashScreen splashScreen("SPLASH","M68HC11"); + splashScreen.perform(); +} + +// virtuals + +void MainFrame::mdiDestroy(MDIWindow &mdiWindow) +{ + SmartPointer mdiWindowPtr; + WORD winCount(0); + + if(getFirstDocument(mdiWindowPtr)) + { + if(mdiWindowPtr->className()==String(STRING_CODEVIEWCLASSNAME)&&((MDIWindow*)mdiWindowPtr!=&mdiWindow))winCount++; + while(getNextDocument(mdiWindowPtr))if(mdiWindowPtr->className()==String(STRING_CODEVIEWCLASSNAME)&&((MDIWindow*)mdiWindowPtr!=&mdiWindow))winCount++; + } + if(!winCount)setParts(SinglePart); +} + +void MainFrame::mdiActivate(MDIWindow &mdiWindow) +{ + if(mdiWindow.className()==String(STRING_CODEVIEWCLASSNAME))setParts(DoublePart); + removeHistory(mdiWindow.getMenu()); + applyHistory(mdiWindow.getMenu()); +} + +void MainFrame::mdiDeactivate(MDIWindow &/*mdiWindow*/) +{ +} diff --git a/aladin/hold/mainfrm.hpp b/aladin/hold/mainfrm.hpp new file mode 100644 index 0000000..971f5d1 --- /dev/null +++ b/aladin/hold/mainfrm.hpp @@ -0,0 +1,98 @@ +#ifndef _ALADIN_MAINFRAME_HPP_ +#define _ALADIN_MAINFRAME_HPP_ +#ifndef _COMMON_MDIFRM_HPP_ +#include +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif +#ifndef _STATBAR_STATUSBAREX_HPP_ +#include +#endif +#ifndef _TOOLBAR_TOOLBAR_HPP_ +#include +#endif +#ifndef _COMMCTRL_COMMCONTROL_HPP_ +#include +#endif + +class MainFrame : public FrameWindow +{ +public: + MainFrame(void); + virtual ~MainFrame(); + static String className(void); + void splash(void); +protected: + virtual void mdiDestroy(MDIWindow &mdiWindow); + virtual void mdiActivate(MDIWindow &mdiWindow); + virtual void mdiDeactivate(MDIWindow &mdiWindow); +private: + enum {StatusBarID=500,ToolBarID=501,StartDynamicID=30000}; + enum{SinglePart=1,DoublePart=2,FirstPartWidth=340,SecondPartWidth=420}; + enum{MenuFileSave=SBCMENU_FILESAVE,MenuFileQuit=SBCMENU_FILEQUIT,MenuFilePrint=SBCMENU_FILEPRINT, + MenuSettingsSerial=SBCMENU_SETTINGSSERIAL,MenuHelpContents=SBCMENU_HELPCONTENTS, + MenuHelpSearch=SBCMENU_HELPSEARCH,MenuRegistration=SBCMENU_REGISTRATION,MenuFileNew=SBCMENU_FILENEW, + MenuFileOpen=SBCMENU_FILEOPEN,MenuHelpAbout=SBCMENU_HELPABOUT,MenuFileClose=SBCMENU_FILECLOSE, + MenuFileSaveAs=SBCMENU_FILESAVEAS,MenuCascade=IDM_CASCADE,MenuTile=IDM_TILE,MenuArrange=IDM_ARRANGE, + MenuCloseAll=IDM_CLOSEALL,MenuMinimizeAll=IDM_MINIMIZEALL,MenuRestoreAll=IDM_RESTOREALL, + MenuEditCut=SBCMENU_EDITCUT,MenuEditCopy=SBCMENU_EDITCOPY,MenuEditPaste=SBCMENU_EDITPASTE, + MenuEditFind=SBCMENU_EDITFIND,MenuCodeCompile=SBCMENU_CODECOMPILE, + MenuCodeCompileAndLoad=SBCMENU_CODECOMPILEANDLOAD}; + CallbackData::ReturnType queryEndSessionHandler(CallbackData &someCallbackData); + CallbackData::ReturnType paintHandler(CallbackData &someCallbackData); + CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData); + CallbackData::ReturnType commandHandler(CallbackData &someCallbackData); + CallbackData::ReturnType keyDownHandler(CallbackData &someCallbackData); + CallbackData::ReturnType sizeHandler(CallbackData &someCallbackData); + CallbackData::ReturnType timerHandler(CallbackData &someCallbackData); + CallbackData::ReturnType createHandler(CallbackData &someCallbackData); + CallbackData::ReturnType activateAppHandler(CallbackData &someCallbackData); + CallbackData::ReturnType displayChangeHandler(CallbackData &someCallbackData); + void createToolBar(void); + void handleCommunications(void); + void handleEditCut(void); + void handleEditCopy(void); + void handleEditPaste(void); + void handleEditFind(void); + void handleFileNew(void); + void handleFileOpen(void); + void handleFileOpen(CallbackData &someCallbackData); + void handleFileOpen(const String &strPathFileName); + void handleFileClose(void); + void handleFilePrint(void); + void handleHelp(void); + BOOL handleFileSave(void); + BOOL handleFileSaveAs(void); + void registerClass(void)const; + void insertHandlers(void); + void removeHandlers(void); + void setParts(int numParts); + void applyHistory(PureMenu &pureMenu); + void updateHistory(const String &pathFileName); + void removeHistory(PureMenu &pureMenu); + BOOL bringDocumentToFront(const String &strTitle); + + Callback mQueryEndSessionHandler; + Callback mPaintHandler; + Callback mDestroyHandler; + Callback mCommandHandler; + Callback mSizeHandler; + Callback mCreateHandler; + SmartPointer mStatusBar; + CommControl mCommControl; + ToolBar mToolBar; +// SerialSettings mSerialSettings; + static char szClassName[]; + static char szMenuName[]; +}; + +inline +String MainFrame::className(void) +{ + return String(szClassName); +} +#endif diff --git a/aladin/hold/mainwnd.cpp b/aladin/hold/mainwnd.cpp new file mode 100644 index 0000000..8f2ca41 --- /dev/null +++ b/aladin/hold/mainwnd.cpp @@ -0,0 +1,215 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +char MainWindow::szClassName[]="Aladin"; +char MainWindow::szMenuName[]="mainMenu"; + +MainWindow::MainWindow() +{ + mPaintHandler.setCallback(this,&MainWindow::paintHandler); + mDestroyHandler.setCallback(this,&MainWindow::destroyHandler); + mCommandHandler.setCallback(this,&MainWindow::commandHandler); + mKeyDownHandler.setCallback(this,&MainWindow::keyDownHandler); + mSizeHandler.setCallback(this,&MainWindow::sizeHandler); + mCreateHandler.setCallback(this,&MainWindow::createHandler); + mTimerHandler.setCallback(this,&MainWindow::timerHandler); + mSetFocusHandler.setCallback(this,&MainWindow::setFocusHandler); + mCloseHandler.setCallback(this,&MainWindow::closeHandler); + insertHandlers(); + registerClass(); + ::CreateWindow(szClassName,szClassName, + WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_DLGFRAME|WS_CLIPCHILDREN|WS_VISIBLE, + CW_USEDEFAULT,CW_USEDEFAULT, + InitialWidth,InitialHeight, + NULL,NULL,processInstance(),(LPSTR)this); + show(SW_SHOW); + update(); +} + +MainWindow::~MainWindow() +{ + destroy(); +} + +void MainWindow::insertHandlers(void) +{ + insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + insertHandler(VectorHandler::PaintHandler,&mPaintHandler); + insertHandler(VectorHandler::CommandHandler,&mCommandHandler); + insertHandler(VectorHandler::SizeHandler,&mSizeHandler); + insertHandler(VectorHandler::KeyDownHandler,&mKeyDownHandler); + insertHandler(VectorHandler::CreateHandler,&mCreateHandler); + insertHandler(VectorHandler::TimerHandler,&mTimerHandler); + insertHandler(VectorHandler::SetFocusHandler,&mSetFocusHandler); +} + +void MainWindow::removeHandlers(void) +{ + removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + removeHandler(VectorHandler::PaintHandler,&mPaintHandler); + removeHandler(VectorHandler::CommandHandler,&mCommandHandler); + removeHandler(VectorHandler::SizeHandler,&mSizeHandler); + removeHandler(VectorHandler::KeyDownHandler,&mKeyDownHandler); + removeHandler(VectorHandler::CreateHandler,&mCreateHandler); + removeHandler(VectorHandler::TimerHandler,&mTimerHandler); + removeHandler(VectorHandler::SetFocusHandler,&mSetFocusHandler); +} + + + +void MainWindow::registerClass(void)const +{ + HINSTANCE hInstance(processInstance()); + WNDCLASS wndClass; + + if(::GetClassInfo(hInstance,className(),(WNDCLASS FAR*)&wndClass))return; + wndClass.style =CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS|CS_OWNDC; + wndClass.lpfnWndProc =(WNDPROC)Window::WndProc; + wndClass.cbClsExtra =0; + wndClass.cbWndExtra =sizeof(MainWindow*); + wndClass.hInstance =hInstance; + wndClass.hIcon =::LoadIcon(processInstance(),"CHECK"); +// wndClass.hIcon =::LoadIcon(processInstance(),"CHECK"); + wndClass.hCursor =::LoadCursor(NULL,IDC_ARROW); + wndClass.hbrBackground =(HBRUSH)::GetStockObject(WHITE_BRUSH); + wndClass.lpszMenuName =szMenuName; + wndClass.lpszClassName =szClassName; + ::RegisterClass(&wndClass); + assert(0!=::GetClassInfo(hInstance,className(),(WNDCLASS FAR*)&wndClass)); +} + +CallbackData::ReturnType MainWindow::createHandler(CallbackData &/*someCallbackData*/) +{ + mStatusBar=new StatusBarEx(*this,101); + mStatusBar.disposition(PointerDisposition::Delete); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainWindow::closeHandler(CallbackData &someCallbackData) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainWindow::sizeHandler(CallbackData &/*someCallbackData*/) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainWindow::paintHandler(CallbackData &someCallbackData) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainWindow::destroyHandler(CallbackData &/*someCallbackData*/) +{ + removeHandlers(); + ::PostQuitMessage(0); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainWindow::commandHandler(CallbackData &someCallbackData) +{ + switch(someCallbackData.wParam()) + { + case APPMENU_FILE_EXIT : + postMessage(*this,WM_CLOSE,0,0L); + break; + case APPMENU_SETTINGS_SERIAL : + handleSerialSettings(); + break; + case APPMENU_FILE_IMPORT : + handleImport(); + break; +// case SOURCE_SELECT : +// userSelectSource(); +// selectSource(); +// if(!twainAvailable())return message("twain not available",false); +// if(!openSourceManager())return message("open source failed",false); +// setShowUI(false); +// if(!openSource(1))return message("open default source failed",false); +// if(!openDefaultSource())return message("open default source failed",false); +// if(!modalAcquire())return message("modal acquire failed",false); +// break; + default : + break; + } + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainWindow::keyDownHandler(CallbackData &/*someCallbackData*/) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainWindow::timerHandler(CallbackData &/*someCallbackData*/) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainWindow::setFocusHandler(CallbackData &/*someCallbackData*/) +{ + return (CallbackData::ReturnType)FALSE; +} + +// non callbacks +void MainWindow::handleImport() +{ + OpenDialog openDialog; + String strPathFileName; + DiveDlg diveDlg; + Aladin aladin; + + if(!openDialog.getOpenFileName(*this,"*.dat","Open File","*.dat",strPathFileName))return; + aladin.openFile(strPathFileName); +// diveDlg.perform(*this,aladin); + +/* + Aladin aladin; + aladin.openFile(strPathFileName); + Console console; + + +// display from status section + console.writeLine(String("Remaining battery:")+String().fromDouble(aladin.getStatus().getRemainingBattery())); + console.writeLine(String("Total dives:")+String().fromInt(aladin.getStatus().getTotalDives())); + console.writeLine(String("Offset newest log:")+String().fromInt(aladin.getStatus().getOffsetNewestLog())); + console.writeLine(String("Dive profiles:")+String().fromInt(aladin.getStatus().getDiveProfiles())); + console.writeLine(String("End of profile ring buffer:")+String().fromInt(aladin.getStatus().getEndOfProfileRingBuffer())); + console.writeLine(String("Acquisition time:")+String().fromInt(aladin.getStatus().getAcquisitionTime())); + +// display from info section + console.writeLine(String("Computer type:")+aladin.getInformation().getComputerTypeString()); + console.writeLine(String("Nitrox:")+String().fromBool(aladin.getInformation().isNitrox())); + console.writeLine(String("Standard:")+aladin.getInformation().getStandardString()); + console.writeLine(String("Beep:")+String().fromBool(aladin.getInformation().getBeep())); +// display from profile section + + console.writeLine("\n"); +/* for(int index=0;index +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif +#ifndef _STATBAR_STATUSBAREX_HPP_ +#include +#endif + +class MainWindow : public Window +{ +public: + MainWindow(void); + virtual ~MainWindow(); + static String className(void); +protected: +private: + enum{InitialWidth=640,InitialHeight=480}; + CallbackData::ReturnType paintHandler(CallbackData &someCallbackData); + CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData); + CallbackData::ReturnType commandHandler(CallbackData &someCallbackData); + CallbackData::ReturnType keyDownHandler(CallbackData &someCallbackData); + CallbackData::ReturnType sizeHandler(CallbackData &someCallbackData); + CallbackData::ReturnType createHandler(CallbackData &someCallbackData); + CallbackData::ReturnType timerHandler(CallbackData &someCallbackData); + CallbackData::ReturnType setFocusHandler(CallbackData &someCallbackData); + CallbackData::ReturnType lineHandler(CallbackData &someCallbackData); + CallbackData::ReturnType closeHandler(CallbackData &someCallbackData); + CallbackData::ReturnType completionHandler(CallbackData &someCallbackData); + void handleSerialSettings(void); + void handleImport(void); + + void registerClass(void)const; + void insertHandlers(void); + void removeHandlers(void); + + Callback mPaintHandler; + Callback mDestroyHandler; + Callback mCommandHandler; + Callback mKeyDownHandler; + Callback mSizeHandler; + Callback mCreateHandler; + Callback mTimerHandler; + Callback mSetFocusHandler; + Callback mCloseHandler; + + static char szClassName[]; + static char szMenuName[]; + HINSTANCE mhInstance; + SmartPointer mStatusBar; +}; + +inline +String MainWindow::className(void) +{ + return String(szClassName); +} +#endif diff --git a/aladin/hold/profiledata.hpp b/aladin/hold/profiledata.hpp new file mode 100644 index 0000000..70024a8 --- /dev/null +++ b/aladin/hold/profiledata.hpp @@ -0,0 +1,96 @@ +#ifndef _ALADIN_PROFILEDATA_HPP_ +#define _ALADIN_PROFILEDATA_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif + +class ProfileData +{ +public: + typedef enum Warning{TransmitErrorAirPressure=0x20,WorkTooHard=0x10,CeilingViolationOfDeco=0x08,AscentTooFast=0x04,RemainingBottomTimeTooShort=0x02,DecoStop=0x01,None=0}; + ProfileData(void); + ProfileData(int depth,int stageTime,int warning); + virtual ~ProfileData(); + int getDepth(void)const; + void setDepth(int depth); + int getStageTime(void)const; + void setStageTime(int stageTime); + Warning getWarning(void)const; + String getWarningString(void)const; + void setWarning(Warning warning); +private: + int mDepth; + int mStageTime; + int mWarning; +}; + +inline +ProfileData::ProfileData() +: mDepth(0), mStageTime(0), mWarning(None) +{ +} + +inline +ProfileData::ProfileData(int depth,int stageTime,int warning) +: mDepth(depth), mStageTime(stageTime), mWarning(warning) +{ +} + +inline +ProfileData::~ProfileData() +{ +} + +inline +int ProfileData::getDepth(void)const +{ + return mDepth; +} + +inline +void ProfileData::setDepth(int depth) +{ + mDepth=depth; +} + +inline +int ProfileData::getStageTime(void)const +{ + return mStageTime; +} + +inline +void ProfileData::setStageTime(int stageTime) +{ + mStageTime=stageTime; +} + +inline +ProfileData::Warning ProfileData::getWarning(void)const +{ + return (Warning)mWarning; +} + +inline +String ProfileData::getWarningString(void)const +{ + String strWarning; + if(mWarning&TransmitErrorAirPressure)strWarning+="transmit error air pressure."; + if(mWarning&WorkTooHard){if(!strWarning.isNull())strWarning+=",";strWarning+="work too hard.";} + if(mWarning&CeilingViolationOfDeco){if(!strWarning.isNull())strWarning+=",";strWarning+="ceiling violation of deco.";} + if(mWarning&AscentTooFast){if(!strWarning.isNull())strWarning+=",";strWarning+="ascent too fast.";} + if(mWarning&RemainingBottomTimeTooShort){if(!strWarning.isNull())strWarning+=",";strWarning+="remaining bottom time too short.";} + if(mWarning&DecoStop){if(!strWarning.isNull())strWarning+=",";strWarning+="decompression stop.";} + if(!mWarning)strWarning+="no warnings"; + return strWarning; +} + +inline +void ProfileData::setWarning(Warning warning) +{ + mWarning=warning; +} +#endif diff --git a/aladin/hold/profiles.cpp b/aladin/hold/profiles.cpp new file mode 100644 index 0000000..7a7fb29 --- /dev/null +++ b/aladin/hold/profiles.cpp @@ -0,0 +1,80 @@ +#include +#include +#include +#include + +bool Profiles::readFrom(Array &array,Information &info,CurrentStatus &status) +{ + int index=0; + int endIndex; + int time; + WORD headerLength; + WORD depth; + BYTE warnings; + BYTE decoInfo; + double conversion=3.281; + + remove(); + try + { + while(true) + { + while(Marker!=array[index]&&indexarray.size()||index>=0x5FF)break; + +// String string; +// ::sprintf(string,"Reading profile at offset: %d (0x%08lx) %02lx,%02lx,%02lx \n",index,index,(int)array.elementAt(index),(int)array.elementAt(index+1),(int)array.elementAt(index+2)); +// ::OutputDebugString(string); + + index++; + + if(info.isNitroxOnly())index+=23; + else if(info.isO2())index+=24; + else index+=22; + time=20; + insert(&DiveProfile()); + DiveProfile &diveProfile=operator[](size()-1); + endIndex=getNextMarkerPos(array,index); + while(index>=6; + depth=(int)((((double)depth*10.00/64.00)*conversion)+.5); + index+=sizeof(WORD); + if(index>=0x5FF)break; + ProfileData profileData(depth,time,warnings); + diveProfile.insert(&ProfileData(depth,time,warnings)); +// ::OutputDebugString(String("Time:")+String().fromInt(time)+String(" Depth:")+String().fromInt(depth)+String("\n")); + if(index>=endIndex) + { + index-=sizeof(WORD); + break; + } + if(depth==0)break; + if(!(time%60)) + { + decoInfo=array[index]; + index++; + } + time+=20; + } +// ::OutputDebugString("*********************************************************\n"); + } + } + catch(ArrayIndexOutOfBoundsException exception) + { + ::OutputDebugString(exception.toString()+String("\n")); + return false; + } + return true; +} + + +int Profiles::getNextMarkerPos(Array &array,int currIndex) +{ + while(currIndex=array.size())return array.size()-1; + return currIndex; +} diff --git a/aladin/hold/profiles.hpp b/aladin/hold/profiles.hpp new file mode 100644 index 0000000..6ca05c4 --- /dev/null +++ b/aladin/hold/profiles.hpp @@ -0,0 +1,27 @@ +#ifndef _ALADIN_PROFILES_HPP_ +#define _ALADIN_PROFILES_HPP_ +#ifndef _COMMON_BLOCK_HPP_ +#include +#endif +#ifndef _COMMON_ARRAY_HPP_ +#include +#endif +#ifndef _ALADIN_STATUS_HPP_ +#include +#endif +#ifndef _ALADIN_INFORMATION_HPP_ +#include +#endif +#ifndef _ALADIN_DIVEPROFILE_HPP_ +#include +#endif + +class Profiles : public Block +{ +public: + enum{Marker=0xFF}; + bool readFrom(Array &array,Information &info,CurrentStatus &status); +private: + int getNextMarkerPos(Array &array,int currIndex); +}; +#endif diff --git a/aladin/hold/resource.hpp b/aladin/hold/resource.hpp new file mode 100644 index 0000000..48a779b --- /dev/null +++ b/aladin/hold/resource.hpp @@ -0,0 +1,6 @@ +#ifndef _ALADIN_RESOURCE_HPP_ +#define _ALADIN_RESOURCE_HPP_ +#ifndef _ALADIN_ALADIN_H_ +#include +#endif +#endif \ No newline at end of file diff --git a/aladin/hold/serdlg.cpp b/aladin/hold/serdlg.cpp new file mode 100644 index 0000000..7f6be65 --- /dev/null +++ b/aladin/hold/serdlg.cpp @@ -0,0 +1,388 @@ +#include +#include +#include + +SerialDlg::SerialDlg(void) +{ + mInitHandler.setCallback(this,&SerialDlg::initHandler); + mDestroyHandler.setCallback(this,&SerialDlg::destroyHandler); + mCommandHandler.setCallback(this,&SerialDlg::commandHandler); + mCloseHandler.setCallback(this,&SerialDlg::closeHandler); + DWindow::insertHandler(VectorHandler::InitDialogHandler,&mInitHandler); + DWindow::insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + DWindow::insertHandler(VectorHandler::CommandHandler,&mCommandHandler); + DWindow::insertHandler(VectorHandler::CloseHandler,&mCloseHandler); +} + +SerialDlg::~SerialDlg() +{ + DWindow::removeHandler(VectorHandler::InitDialogHandler,&mInitHandler); + DWindow::removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + DWindow::removeHandler(VectorHandler::CommandHandler,&mCommandHandler); + DWindow::removeHandler(VectorHandler::CloseHandler,&mCloseHandler); +} + +SerialDlg &SerialDlg::operator=(const SerialDlg &/*someSerialDlg*/) +{ // private implementation + return *this; +} + +BOOL SerialDlg::perform(GUIWindow &parentWindow) // ,SerialSettings &serialSettings) +{ + return ::DialogBoxParam(processInstance(),(LPSTR)"SERIAL",(HWND)parentWindow,DWindow::DlgProc,(LPARAM)(DWindow*)this); +} + +CallbackData::ReturnType SerialDlg::initHandler(CallbackData &/*someCallbackData*/) +{ + mStatusBar=::new StatusBarEx(*this,StatusBarID); + mStatusBar.disposition(PointerDisposition::Delete); + initSerialSettings(); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SerialDlg::destroyHandler(CallbackData &/*someCallbackData*/) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SerialDlg::commandHandler(CallbackData &someCallbackData) +{ + switch(someCallbackData.wmCommandID()) + { + case IDOK : + if(applySerialSettings())endDialog(TRUE); + break; + case IDCANCEL : + endDialog(FALSE); + break; + case SerialStopBits : + case SerialParity : + case SerialDataBits : + case SerialBaud : + case SerialPort : + mStatusBar->setText(" "); + break; + case SerialApply : + applySerialSettings(); + break; + case SerialReset : + reset(); + break; + } + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SerialDlg::closeHandler(CallbackData &/*someCallbackData*/) +{ + return (CallbackData::ReturnType)FALSE; +} + +void SerialDlg::initSerialSettings(void) +{ + AppReg appReg; + + initPorts(); + initBaud(); + initDataBits(); + initStopBits(); + initParity(); + sendMessage(SerialPort,CB_SELECTSTRING,-1,(LPARAM)(LPSTR)appReg.getPort()); + sendMessage(SerialBaud,CB_SELECTSTRING,-1,(LPARAM)(LPSTR)appReg.getBaud()); + sendMessage(SerialDataBits,CB_SELECTSTRING,-1,(LPARAM)(LPSTR)appReg.getDataBits()); + sendMessage(SerialParity,CB_SELECTSTRING,-1,(LPARAM)(LPSTR)appReg.getParity()); + sendMessage(SerialStopBits,CB_SELECTSTRING,-1,(LPARAM)(LPSTR)appReg.getStopBits()); +} + +void SerialDlg::initPorts(void) +{ + String strPort; + CommControl commControl; + Block ports; + + sendMessage(SerialPort,CB_RESETCONTENT,0,0L); + commControl.enumerateDevices(ports); + for(int index=0;indexsetText("Error opening port."); + ::MessageBeep(0); + return false; + } + if(!commControl.setDeviceControlBlock(strCommSettings)){mStatusBar->setText("Failed to apply settings.");return false;} + sendMessage(SerialBaud,WM_GETTEXT,String::MaxString,(LPARAM)(LPSTR)strBaud); + appReg.setBaud(strBaud); + sendMessage(SerialDataBits,WM_GETTEXT,String::MaxString,(LPARAM)(LPSTR)strDataBits); + appReg.setDataBits(strDataBits); + currSel=sendMessage(SerialParity,CB_GETCURSEL,0,0L); + sendMessage(SerialParity,CB_GETLBTEXT,0,(LPARAM)(LPSTR)strParity); + if(String("None")==strParity)strParity="N"; + else if(String("Odd")==strParity)strParity="O"; + else if(String("Even")==strParity)strParity="E"; + else if(String("Space")==strParity)strParity="S"; + appReg.setParity(strParity); + currSel=sendMessage(SerialStopBits,CB_GETCURSEL,0,0L); + sendMessage(SerialStopBits,CB_GETLBTEXT,0,(LPARAM)(LPSTR)strStopBits); + appReg.setStopBits(strStopBits); + mStatusBar->setText("Settings have been applied."); + return true; +} + +void SerialDlg::reset() +{ + AppReg appReg; + CommControl commControl; + Block deviceList; + + + if(IDCANCEL==::MessageBox(*this,"Reset serial settings to default values?","Confirm",MB_OKCANCEL))return; + commControl.enumerateDevices(deviceList); + appReg.setBaud("19200"); + appReg.setParity("N"); + appReg.setDataBits("8"); + appReg.setStopBits("1"); + appReg.setPort(deviceList.size()?deviceList[0]:"COM1"); + initSerialSettings(); +} + +/*void SerialDlg::testDevice() +{ + CommControl commControl; + DeviceControlBlock dcb; + + if(!commControl.open(getCommPort())){mStatusBar->setText("Error opening port.");return;} + if(!commControl.setDeviceControlBlock(getCommSettings())){mStatusBar->setText("Failed to apply settings.");return;} + mStatusBar->setText("loading data..."); + commControl.getDeviceControlBlock(dcb); + dcb.dtrControl(DeviceControlBlock::DtrControlEnable); + dcb.rtsControl(DeviceControlBlock::RtsControlEnable); + commControl.setDeviceControlBlock(dcb); + +} */ + +/* + + +void printDCB(CommControl &control,bool wait); +bool getControlData(CommControl &control); + +Console console; + + DeviceControlBlock dcb; + CommControl control; + Block deviceList; + String selDevice; + String strPrompt; + String strCommState="baud=19200 parity=N data=8 stop=1"; + + control.enumerateDevices(deviceList); + for(int index=0;index strLines; + FormatLines::hexasciiLines(strLines,rcvBuff,sizeof(rcvBuff)); + for(int index=0;index +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif +#ifndef _STATBAR_STATUSBAREX_HPP_ +#include +#endif +#ifndef _COMMCTRL_COMMCTRL_HPP_ +#include +#endif +#ifndef _ALADIN_ALADINRC_HPP_ +#include +#endif + + +class SerialDlg : public DWindow +{ +public: + SerialDlg(void); + virtual ~SerialDlg(); + BOOL perform(GUIWindow &parentWindow); +private: + enum{SerialStopBits=SERIAL_STOP,SerialParity=SERIAL_PARITY,SerialDataBits=SERIAL_DATA, + SerialBaud=SERIAL_BAUD,SerialPort=SERIAL_PORT,SerialApply=SERIAL_APPLY,SerialReset=SERIAL_RESET}; + enum {StatusBarID=500}; + SerialDlg &operator=(const SerialDlg &someSerialDlg); + CallbackData::ReturnType initHandler(CallbackData &someCallbackData); + CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData); + CallbackData::ReturnType commandHandler(CallbackData &someCallbackData); + CallbackData::ReturnType closeHandler(CallbackData &someCallbackData); + CallbackData::ReturnType dlgCodeHandler(CallbackData &someCallbackData); + CallbackData::ReturnType controlColorHandler(CallbackData &someCallbackData); + CallbackData::ReturnType measureItemHandler(CallbackData &someCallbackData); + CommControl::Port getCommPort(void)const; + String getCommSettings(void)const; + bool applySerialSettings(void); + void initSerialSettings(void); + void initDataBits(void); + void initParity(void); + void initStopBits(void); + void initPorts(void); + void initBaud(void); + void reset(void); + + Callback mInitHandler; + Callback mDestroyHandler; + Callback mCommandHandler; + Callback mCloseHandler; + SmartPointer mStatusBar; +}; +#endif \ No newline at end of file diff --git a/aladin/hold/splash.cpp b/aladin/hold/splash.cpp new file mode 100644 index 0000000..90962a3 --- /dev/null +++ b/aladin/hold/splash.cpp @@ -0,0 +1,170 @@ +#include +#include +#include +#include +#include + +char SplashScreen::szClassName[]="SplashScreen"; + +SplashScreen::SplashScreen(const String &strBitmap,const String &strCaption,const String &strTitle,UINT timeout) +: mBitmapName(strBitmap), mStrCaption(strCaption), mStrTitle(strTitle), mTimeout(timeout), + mTextFont("Helv",8,Font::PitchVariable|Font::FamilySwiss,Font::WeightBold) +{ + mResBitmap=new ResBitmap(mBitmapName); + mResBitmap.disposition(PointerDisposition::Delete); + mCreateHandler.setCallback(this,&SplashScreen::createHandler); + mPaintHandler.setCallback(this,&SplashScreen::paintHandler); + mDestroyHandler.setCallback(this,&SplashScreen::destroyHandler); + mPaletteChangedHandler.setCallback(this,&SplashScreen::paletteChangedHandler); + mSetFocusHandler.setCallback(this,&SplashScreen::setFocusHandler); + mLeftButtonHandler.setCallback(this,&SplashScreen::leftButtonHandler); + mTimerHandler.setCallback(this,&SplashScreen::timerHandler); + insertHandler(VectorHandler::CreateHandler,&mCreateHandler); + insertHandler(VectorHandler::PaintHandler,&mPaintHandler); + insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + insertHandler(VectorHandler::PaletteChangedHandler,&mPaletteChangedHandler); + insertHandler(VectorHandler::SetFocusHandler,&mSetFocusHandler); + insertHandler(VectorHandler::TimerHandler,&mTimerHandler); + insertHandler(VectorHandler::LeftButtonUpHandler,&mLeftButtonHandler); + registerClass(); +} + +SplashScreen::SplashScreen(const SplashScreen &someSplashScreen) +{ // private implementation +} + +SplashScreen::~SplashScreen() +{ + removeHandler(VectorHandler::CreateHandler,&mCreateHandler); + removeHandler(VectorHandler::PaintHandler,&mPaintHandler); + removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + removeHandler(VectorHandler::PaletteChangedHandler,&mPaletteChangedHandler); + removeHandler(VectorHandler::SetFocusHandler,&mSetFocusHandler); + removeHandler(VectorHandler::TimerHandler,&mTimerHandler); + removeHandler(VectorHandler::LeftButtonUpHandler,&mLeftButtonHandler); +} + +void SplashScreen::registerClass(void) +{ + HINSTANCE hInstance(processInstance()); + WNDCLASS wndClass; + + if(::GetClassInfo(hInstance,szClassName,(WNDCLASS FAR*)&wndClass))return; + wndClass.style =CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS|CS_OWNDC; + wndClass.lpfnWndProc =(WNDPROC)Window::WndProc; + wndClass.cbClsExtra =0; + wndClass.cbWndExtra =sizeof(SplashScreen*); + wndClass.hInstance =hInstance; + wndClass.hIcon =::LoadIcon(NULL,IDI_APPLICATION); + wndClass.hCursor =::LoadCursor(NULL,IDC_ARROW); + wndClass.hbrBackground =(HBRUSH)::GetStockObject(NULL_BRUSH); + wndClass.lpszMenuName =0; + wndClass.lpszClassName =szClassName; + ::RegisterClass(&wndClass); + assert(0!=::GetClassInfo(hInstance,szClassName,(WNDCLASS FAR*)&wndClass)); +} + +SplashScreen &SplashScreen::operator=(const SplashScreen &someSplashScreen) +{ // private implementation + return *this; +} + +BOOL SplashScreen::perform(Rect initRect) +{ + UINT style(0); + if(CW_USEDEFAULT==initRect.right())initRect.right(mResBitmap->width()); + if(CW_USEDEFAULT==initRect.bottom())initRect.bottom(mResBitmap->height()); + if(timeout()) + { + PureDevice pureDevice; + pureDevice.screenDevice(); + initRect.left((pureDevice.horizontalResolution()-mResBitmap->width())/2); + initRect.top((pureDevice.verticalResolution()-mResBitmap->height())/2); + style=WS_POPUP|WS_CLIPSIBLINGS|0x04|WS_DLGFRAME; + } + else style=WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_BORDER|WS_DLGFRAME|0x04|WS_CLIPSIBLINGS; + createWindow(WS_EX_CONTROLPARENT,szClassName,timeout()?(char*)0:(char*)"Splash",style,initRect,NULL,NULL,processInstance(),(LPSTR)this); // WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_BORDER|WS_DLGFRAME|0x04|WS_CLIPSIBLINGS + show(SW_SHOW); + update(); + return messageLoop(); +} + +CallbackData::ReturnType SplashScreen::leftButtonHandler(CallbackData &someCallbackData) +{ + killTimer(TimerID); + postMessage(*this,WM_CLOSE,0,0L); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SplashScreen::destroyHandler(CallbackData &someCallbackData) +{ + PureDevice pureDevice(*this); + ((PurePalette&)*mDIBitmap).usePalette(pureDevice,FALSE); + postQuitMessage(onDestroy()); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SplashScreen::createHandler(CallbackData &someCallbackData) +{ + mPureDevice=new PureDevice(*this); + mPureDevice.disposition(PointerDisposition::Delete); + mDIBitmap=new DIB24(); + mDIBitmap.disposition(PointerDisposition::Delete); + mDIBitmap->create(mResBitmap->width(),mResBitmap->height(),*mPureDevice); + mDIBitmap->copyBits(*mResBitmap); + if(timeout())setTimer(TimerID,timeout()); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SplashScreen::timerHandler(CallbackData &someCallbackData) +{ + killTimer(TimerID); + postMessage(*this,WM_CLOSE,0,0L); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SplashScreen::paletteChangedHandler(CallbackData &someCallbackData) +{ + if(!mDIBitmap.isOkay()||((HWND)*this==(HWND)someCallbackData.wParam()))return (CallbackData::ReturnType)FALSE; + PureDevice pureDevice(*this); + ((PurePalette&)*mDIBitmap).usePalette(pureDevice,TRUE); + update(); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SplashScreen::setFocusHandler(CallbackData &/*someCallbackData*/) +{ + if(!mDIBitmap.isOkay())return (CallbackData::ReturnType)FALSE; + PureDevice pureDevice(*this); + ((PurePalette&)*mDIBitmap).usePalette(pureDevice,TRUE); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SplashScreen::paintHandler(CallbackData &someCallbackData) +{ + if(!mResBitmap.isOkay())return (CallbackData::ReturnType)FALSE; + PaintInformation *pPaintInfo=(PaintInformation*)someCallbackData.lParam(); + PureDevice &pureDevice=(PureDevice&)*pPaintInfo; + mDIBitmap->bitBlt(pureDevice,Rect(0,0,width(),height()),Point()); + pureDevice.select((GDIObj)mTextFont,TRUE); + pureDevice.setTextColor(RGBColor(247,231,33)); + pureDevice.setBkMode(PureDevice::Transparent); + pureDevice.textOut(5,200,mStrCaption); + if(!mStrTitle.isNull()) + { + Font mFont("Helv",12,Font::PitchVariable|Font::FamilySwiss,Font::WeightBold); + pureDevice.select((GDIObj)mFont,TRUE); + pureDevice.setTextColor(RGBColor(255,255,255)); + pureDevice.textOut(12,10,mStrTitle); + pureDevice.select((GDIObj)mFont,FALSE); + } + return (CallbackData::ReturnType)FALSE; +} + +// virtuals +int SplashScreen::onDestroy(void) +{ + return 0; +} + + diff --git a/aladin/hold/splash.hpp b/aladin/hold/splash.hpp new file mode 100644 index 0000000..3d3c473 --- /dev/null +++ b/aladin/hold/splash.hpp @@ -0,0 +1,69 @@ +#ifndef _ALADIN_SPLASHSCREEN_HPP_ +#define _ALADIN_SPLASHSCREEN_HPP_ +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_WINDOW_HPP_ +#include +#endif +#ifndef _COMMON_RECTANGLE_HPP_ +#include +#endif +#ifndef _COMMON_FONT_HPP_ +#include +#endif + +class ResBitmap; +class DIB24; + +class SplashScreen : public Window +{ +public: + enum{TimeOut=5000}; + SplashScreen(const String &strBitmap,const String &strCaption,const String &strTitle,UINT timeout=TimeOut); + virtual ~SplashScreen(); + BOOL perform(Rect initRect=Rect(CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT)); +protected: + virtual int onDestroy(void); +private: + enum {TimerID=0}; + SplashScreen(const SplashScreen &someSplashScreen); + SplashScreen &operator=(const SplashScreen &someSplashScreen); + CallbackData::ReturnType createHandler(CallbackData &someCallbackData); + CallbackData::ReturnType paintHandler(CallbackData &someCallbackData); + CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData); + CallbackData::ReturnType paletteChangedHandler(CallbackData &someCallbackData); + CallbackData::ReturnType setFocusHandler(CallbackData &someCallbackData); + CallbackData::ReturnType timerHandler(CallbackData &someCallbackData); + CallbackData::ReturnType leftButtonHandler(CallbackData &someCallbackData); + void registerClass(void); + UINT timeout(void)const; + + Callback mPaintHandler; + Callback mCreateHandler; + Callback mDestroyHandler; + Callback mPaletteChangedHandler; + Callback mSetFocusHandler; + Callback mTimerHandler; + Callback mLeftButtonHandler; + + SmartPointer mResBitmap; + SmartPointer mDIBitmap; + SmartPointer mPureDevice; + String mBitmapName; + String mStrCaption; + String mStrTitle; + UINT mTimeout; + Font mTextFont; + static char szClassName[]; +}; + +inline +UINT SplashScreen::timeout(void)const +{ + return mTimeout; +} +#endif \ No newline at end of file diff --git a/aladin/hold/status.cpp b/aladin/hold/status.cpp new file mode 100644 index 0000000..5039c2f --- /dev/null +++ b/aladin/hold/status.cpp @@ -0,0 +1,50 @@ +#include + +CurrentStatus::CurrentStatus() +{ + mRemainingBattery=0; + mBattery=0; + mTotalDivesLow=0; + mTotalDivesHigh=0; + mOffsetNewestLog=0; + mDiveProfiles=0; + mEndOfProfileRingBufferLow=0; + mEndOfProfileRingBufferHigh=0; + mDataAquisitionTime1=0; + mDataAquisitionTime2=0; + mDataAquisitionTime3=0; + mDataAquisitionTime4=0; + mCheckSumLow=0; + mCheckSumHigh=0; +} + +CurrentStatus::~CurrentStatus() +{ +} + +bool CurrentStatus::readFrom(Array &array) +{ + try + { + mRemainingBattery=array[0x7F0]; + mBattery=array[0x7F1]; + mTotalDivesLow=array[0x7F2]; + mTotalDivesHigh=array[0x7F3]; + mOffsetNewestLog=array[0x7F4]; + mDiveProfiles=array[0x7F5]; + mEndOfProfileRingBufferLow=array[0x7F6]; + mEndOfProfileRingBufferHigh=array[0x7F7]; + mDataAquisitionTime1=array[0x7F8]; + mDataAquisitionTime2=array[0x7F9]; + mDataAquisitionTime3=array[0x7FA]; + mDataAquisitionTime4=array[0x7FB]; + mCheckSumLow=array[0x7FC]; + mCheckSumHigh=array[0x7FD]; + } + catch(ArrayIndexOutOfBoundsException exception) + { + ::OutputDebugString(exception.toString()+String("\n")); + return false; + } + return true; +} diff --git a/aladin/hold/status.hpp b/aladin/hold/status.hpp new file mode 100644 index 0000000..6b4b01b --- /dev/null +++ b/aladin/hold/status.hpp @@ -0,0 +1,91 @@ +#ifndef _ALADIN_STATUS_HPP_ +#define _ALADIN_STATUS_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_ARRAY_HPP_ +#include +#endif +#ifndef _COMMON_MATH_HPP_ +#include +#endif + +class CurrentStatus +{ +public: + CurrentStatus(); + virtual ~CurrentStatus(); + double getRemainingBattery(void)const; + bool getBattery(void)const; + WORD getTotalDives(void)const; + WORD getOffsetNewestLog(void)const; + WORD getOffsetLog(void)const; + BYTE getDiveProfiles(void)const; + WORD getEndOfProfileRingBuffer(void)const; + DWORD getAcquisitionTime(void)const; + bool readFrom(Array &array); +private: + BYTE mRemainingBattery; + BYTE mBattery; + BYTE mTotalDivesLow; + BYTE mTotalDivesHigh; + BYTE mOffsetNewestLog; + BYTE mDiveProfiles; + BYTE mEndOfProfileRingBufferLow; + BYTE mEndOfProfileRingBufferHigh; + BYTE mDataAquisitionTime1; + BYTE mDataAquisitionTime2; + BYTE mDataAquisitionTime3; + BYTE mDataAquisitionTime4; + BYTE mCheckSumLow; + BYTE mCheckSumHigh; +}; + +inline +double CurrentStatus::getRemainingBattery(void)const +{ + return (mRemainingBattery*100.00)/256.00; +} + +inline +bool CurrentStatus::getBattery(void)const +{ + return mBattery&0xF0; +} + +inline +WORD CurrentStatus::getTotalDives(void)const +{ + return (mTotalDivesLow*256)+mTotalDivesHigh; +} + +inline +WORD CurrentStatus::getOffsetNewestLog(void)const +{ + return ((((WORD)mOffsetNewestLog+36)%37)*12)+0x600; +} + +inline +WORD CurrentStatus::getOffsetLog(void)const +{ + return 0x604; +} + +inline +BYTE CurrentStatus::getDiveProfiles(void)const +{ + return mDiveProfiles; +} + +inline +WORD CurrentStatus::getEndOfProfileRingBuffer(void)const +{ + return (mEndOfProfileRingBufferLow+(mEndOfProfileRingBufferHigh>>1)*256)&0x7FF; +} + +inline +DWORD CurrentStatus::getAcquisitionTime(void)const +{ + return (double)mDataAquisitionTime1*Math::power(2,24)+(double)mDataAquisitionTime2*Math::power(2,16)+(double)mDataAquisitionTime3*Math::power(2,8)+(double)mDataAquisitionTime4; +} +#endif \ No newline at end of file diff --git a/aladin/hold/time.hpp b/aladin/hold/time.hpp new file mode 100644 index 0000000..bb7efd9 --- /dev/null +++ b/aladin/hold/time.hpp @@ -0,0 +1,72 @@ +#ifndef _ALADIN_TIME_HPP_ +#define _ALADIN_TIME_HPP_ +#ifndef _COMMON_STRING_HPP_ +#include +#endif + +class Time +{ +public: + Time(); + Time(int hours,int minutes); + virtual ~Time(); + int getHours(void)const; + void setHours(int hours); + int getMinutes(void)const; + void setMinutes(int minutes); + String toString(void)const; +private: + int mHours; + int mMinutes; +}; + +inline +Time::Time() +: mHours(0), mMinutes(0) +{ +} + +inline +Time::Time(int hours,int minutes) +: mHours(hours), mMinutes(minutes) +{ +} + +inline +Time::~Time() +{ +} + +inline +int Time::getHours(void)const +{ + return mHours; +} + +inline +void Time::setHours(int hours) +{ + mHours=hours; +} + +inline +int Time::getMinutes(void)const +{ + return mMinutes; +} + +inline +void Time::setMinutes(int minutes) +{ + mMinutes=minutes; +} + +inline +String Time::toString(void)const +{ + String str; + + ::sprintf(str,"%02d:%02d",mHours,mMinutes); + return str; +} +#endif diff --git a/aladin/information.cpp b/aladin/information.cpp new file mode 100644 index 0000000..49aa217 --- /dev/null +++ b/aladin/information.cpp @@ -0,0 +1,107 @@ +#include +#include + +Information::Information() +{ + mComputerType=0; + mExtraInfo1=0; +} + +Information::~Information() +{ +} + +bool Information::readFrom(RawData &array) +{ + try + { + mComputerType=array[0x7BC]; + mExtraInfo1=array[0x7D2]; + } + catch(ArrayIndexOutOfBoundsException exception) + { + ::OutputDebugString(exception.toString()+String("\n")); + return false; + } + return true; +} + +bool Information::readFrom(File &inFile) +{ + if(!inFile.isOkay())return false; + if(!inFile.read(&mComputerType,sizeof(mComputerType)))return false; + if(!inFile.read(&mExtraInfo1,sizeof(mExtraInfo1)))return false; + return true; +} + +bool Information::writeTo(File &outFile) +{ + if(!outFile.isOkay())return false; + if(!outFile.write(&mComputerType,sizeof(mComputerType)))return false; + if(!outFile.write(&mExtraInfo1,sizeof(mExtraInfo1)))return false; + return true; +} + +Information::Model Information::getComputerType(void)const +{ + switch(mComputerType) + { + case 0x40 : + return MaresGenius; + case 0x34 : + return AladinAirZ; + case 0x44 : + return AladinAirZ; + case 0xA4 : + return AladinAirZO2; + case 0xF4 : + return AladinAirXNitrox; + case 0x48 : + return SpiroMonitor3Air; + case 0x1C : + return AladinAirTwin; + case 0x1D : + case 0x3D : + return SpiroMonitor2Plus; + case 0x1E : + case 0x3E : + return AladinSportPlus; + case 0x1F : + case 0x3F : + return AladinPro; + case 0xFF : + return AladinProUltra; + default : + return Unknown; + } +} + +String Information::getComputerTypeString(void)const +{ + switch(getComputerType()) + { + case MaresGenius : + return "Mares Genius"; + case AladinAirZ : + return "Aladin Air Z/Aladin Air X"; + case AladinAirZO2 : + return "Aladin Air Z O2/Aladin Air X O2"; + case AladinAirXNitrox : + return "Aladin Air X Nitrox"; + case SpiroMonitor3Air : + return "Spiro Monitor 3 Air"; + case AladinAirTwin : + return "Aladin Air Twin/Aladin Air"; + case SpiroMonitor2Plus : + return "Spiro Monitor 2 Plus"; + case AladinSportPlus : + return "Aladin Sport Plus/Aladin Sport"; + case AladinPro : + return "Aladin Pro"; + case AladinProUltra : + return "Aladin Pro Ultra/Aladin Pro Nitrox"; + case Unknown : + default : + return "Unknown"; + } +} diff --git a/aladin/information.hpp b/aladin/information.hpp new file mode 100644 index 0000000..e9b59cd --- /dev/null +++ b/aladin/information.hpp @@ -0,0 +1,82 @@ +#ifndef _ALADIN_INFORMATION_HPP_ +#define _ALADIN_INFORMATION_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_ARRAY_HPP_ +#include +#endif +#ifndef _ALADIN_RAWDATA_HPP_ +#include +#endif + +class File; + +class Information +{ +public: + typedef enum Model{MaresGenius=0x40,AladinAirZ,AladinAirZO2,AladinAirXNitrox,SpiroMonitor3Air, + AladinAirTwin,SpiroMonitor2Plus,AladinSportPlus,AladinPro,AladinProUltra,Unknown}; + typedef enum Standard{Imperial,Metric}; + Information(); + virtual ~Information(); + Model getComputerType(void)const; + String getComputerTypeString(void)const; + bool isNitrox(void)const; + bool isO2(void)const; + bool isNitroxOnly(void)const; + bool readFrom(RawData &array); + bool readFrom(File &inFile); + bool writeTo(File &outFile); + Standard getStandard(void)const; + String getStandardString(void)const; + bool getBeep(void)const; +private: + BYTE mComputerType; + BYTE mExtraInfo1; +}; + + +inline +bool Information::isNitrox(void)const +{ + Model model(getComputerType()); + if(AladinAirXNitrox==model||AladinAirZO2==model||AladinProUltra==model)return true; + return false; +} + + +inline +bool Information::isO2(void)const +{ + Model model(getComputerType()); + if(AladinAirZO2==model)return true; + return false; +} + +inline +bool Information::isNitroxOnly(void)const +{ + if(isNitrox()&&!isO2())return true; + return false; +} + +inline +Information::Standard Information::getStandard(void)const +{ + return (mExtraInfo1&0x01)?Imperial:Metric; +} + +inline +String Information::getStandardString(void)const +{ + if(Metric==getStandard())return "Metric"; + return "Imperial"; +} + +inline +bool Information::getBeep(void)const +{ + return (mExtraInfo1&0x01)?true:false; +} +#endif \ No newline at end of file diff --git a/aladin/logbook.cpp b/aladin/logbook.cpp new file mode 100644 index 0000000..04fab29 --- /dev/null +++ b/aladin/logbook.cpp @@ -0,0 +1,64 @@ +#include +#include +#include + +LogBook::LogBook() +{ +} + +LogBook::~LogBook() +{ +} + +bool LogBook::readFrom(RawData &array,CurrentStatus &status) +{ + QuickSort quickSort; + int index=StartAddress; + + for(int logIndex=0;logIndex +#endif +#ifndef _COMMON_BLOCK_HPP_ +#include +#endif +#ifndef _ALADIN_DIVELOG_HPP_ +#include +#endif +#ifndef _ALADIN_RAWDATA_HPP_ +#include +#endif + +class File; + +class LogBook : public Block +{ +public: + enum{StartAddress=0x600,MaxLogs=37}; + LogBook(); + virtual ~LogBook(); + bool readFrom(RawData &array,CurrentStatus &status); + bool readFrom(File &inFile); + bool writeTo(File &outFile); + bool haveDive(DiveLog &diveLog); +private: +}; +#endif \ No newline at end of file diff --git a/aladin/m03l.jpg b/aladin/m03l.jpg new file mode 100644 index 0000000..2b2d884 Binary files /dev/null and b/aladin/m03l.jpg differ diff --git a/aladin/mainfrm.cpp b/aladin/mainfrm.cpp new file mode 100644 index 0000000..1fe2ccd --- /dev/null +++ b/aladin/mainfrm.cpp @@ -0,0 +1,484 @@ +#include +#include +#include +#include +#include +#include + +char MainFrame::szClassName[]="Aladin"; +char MainFrame::szMenuName[]="mainMenu"; + +MainFrame::MainFrame(void) +{ + mQueryEndSessionHandler.setCallback(this,&MainFrame::queryEndSessionHandler); + mPaintHandler.setCallback(this,&MainFrame::paintHandler); + mDestroyHandler.setCallback(this,&MainFrame::destroyHandler); + mCommandHandler.setCallback(this,&MainFrame::commandHandler); + mSizeHandler.setCallback(this,&MainFrame::sizeHandler); + mCreateHandler.setCallback(this,&MainFrame::createHandler); + insertHandlers(); +} + +MainFrame::~MainFrame() +{ + destroy(); +} + +void MainFrame::insertHandlers(void) +{ + insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + insertHandler(VectorHandler::PaintHandler,&mPaintHandler); + insertHandler(VectorHandler::CommandHandler,&mCommandHandler); + insertHandler(VectorHandler::SizeHandler,&mSizeHandler); + insertHandler(VectorHandler::CreateHandler,&mCreateHandler); + insertHandler(VectorHandler::QueryEndSessionHandler,&mQueryEndSessionHandler); +} + +void MainFrame::removeHandlers(void) +{ + removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + removeHandler(VectorHandler::PaintHandler,&mPaintHandler); + removeHandler(VectorHandler::CommandHandler,&mCommandHandler); + removeHandler(VectorHandler::SizeHandler,&mSizeHandler); + removeHandler(VectorHandler::CreateHandler,&mCreateHandler); + removeHandler(VectorHandler::QueryEndSessionHandler,&mQueryEndSessionHandler); +} + +CallbackData::ReturnType MainFrame::createHandler(CallbackData &/*someCallbackData*/) +{ + GlobalData statParts; + + createToolBar(); + mStatusBar=::new StatusBarEx(*this,StatusBarID); + mStatusBar.disposition(PointerDisposition::Delete); + statParts.size(2); + *((int*)&statParts[0])=300; + *((int*)&statParts[1])=400; + mStatusBar->setParts(statParts); + mStatusBar->setText("Ready"); + applyHistory(getFrameMenu()); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainFrame::destroyHandler(CallbackData &/*someCallbackData*/) +{ + removeHandlers(); + ::PostQuitMessage(0); + ::WinHelp(*this,0,HELP_QUIT,0); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainFrame::queryEndSessionHandler(CallbackData &someCallbackData) +{ + if(getClient().hasChildren())return (CallbackData::ReturnType)FALSE; + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainFrame::sizeHandler(CallbackData &someCallbackData) +{ + Rect statusRect; + Rect toolRect; + Rect cRect; + + mToolBar.windowRect(toolRect); + mStatusBar->windowRect(statusRect); + cRect.right(someCallbackData.loWord()); + cRect.bottom(someCallbackData.hiWord()); + getClient().moveWindow(0,toolRect.bottom()-toolRect.top(),cRect.right(),cRect.bottom()-((statusRect.bottom()-statusRect.top())+(toolRect.bottom()-toolRect.top()))); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainFrame::paintHandler(CallbackData &/*someCallbackData*/) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType MainFrame::commandHandler(CallbackData &someCallbackData) +{ + switch(someCallbackData.wmCommandID()) + { + case MenuCodeCompile : + handleCodeCompile(); + break; + case MenuCodeCompileAndLoad : + handleCodeCompileAndLoad(); + break; + case MenuEditCut : + handleEditCut(); + break; + case MenuEditCopy : + handleEditCopy(); + break; + case MenuEditPaste : + handleEditPaste(); + break; + case MenuEditFind : + handleEditFind(); + break; + case MenuCascade : + cascade(); + break; + case MenuTile : + tile(); + break; + case MenuArrange : + arrange(); + break; + case MenuCloseAll : + closeAll(); + break; + case MenuMinimizeAll : + minimizeAll(); + break; + case MenuRestoreAll : + restoreAll(); + break; + case MenuFileNew : + handleFileNew(); + break; + case MenuFileOpen : + handleFileOpen(); + break; + case MenuFileSave : + handleFileSave(); + break; + case MenuFilePrint : + handleFilePrint(); + break; + case MenuFileSaveAs : + handleFileSaveAs(); + break; + case MenuFileClose : + handleFileClose(); + break; + case MenuFileQuit : + break; + case MenuSettingsSerial : + handleCommunications(); + break; + case MenuHelpContents : + handleHelp(); + break; + case MenuHelpSearch : + handleHelp(); + break; + case MenuRegistration : + break; + case MenuHelpAbout : + break; + } + if(someCallbackData.wParam()>=StartDynamicID)handleFileOpen(someCallbackData); + return (CallbackData::ReturnType)FALSE; +} + +// handlers + +void MainFrame::handleCodeCompile(void) +{ + CursorControl cursorControl; + SmartPointer mdiWindow; + String strMessage; + + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + CodeView &codeView=(CodeView&)*mdiWindow; + if(codeView.isDirty()&&IDYES==::MessageBox(*this,(LPSTR)"Save Changes?",(LPSTR)"M68HC11",MB_YESNO))if(!handleFileSave())return; + mStatusBar->setText("compiling..."); + cursorControl.waitCursor(TRUE); + m68Assembler.assemble(codeView.getTitle()); + cursorControl.waitCursor(FALSE); + strMessage=m68Assembler.strLastMessage()+String(", code size is ")+String().fromInt(m68Assembler.codeSize())+String(" byte(s)."); + mStatusBar->setText(strMessage); +} + +void MainFrame::handleCodeCompileAndLoad(void) +{ + CursorControl cursorControl; + BOOL assembleResult; + String strPathBinary; + String strMessage; + + SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + CodeView &codeView=(CodeView&)*mdiWindow; + if(codeView.isDirty()&&IDYES==::MessageBox(*this,(LPSTR)"Save Changes?",(LPSTR)"M68HC11",MB_YESNO))if(!handleFileSave())return; + mStatusBar->setText("compiling..."); + cursorControl.waitCursor(TRUE); + assembleResult=m68Assembler.assemble(codeView.getTitle()); + cursorControl.waitCursor(FALSE); + strMessage=m68Assembler.strLastMessage()+String(", code size is ")+String().fromInt(m68Assembler.codeSize())+String(" byte(s)."); + mStatusBar->setText(strMessage); + if(!assembleResult)return; + strPathBinary=codeView.getTitle().betweenString(0,'.'); + strPathBinary+=".bin"; + codeLoad(strPathBinary); +} + +void MainFrame::handleEditCut(void) +{ + SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + ((CodeView&)*mdiWindow).cut(); +} + +void MainFrame::handleEditCopy(void) +{ + SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + ((CodeView&)*mdiWindow).copy(); +} + +void MainFrame::handleEditPaste(void) +{ + SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + ((CodeView&)*mdiWindow).paste(); +} + +void MainFrame::handleEditFind(void) +{ + SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + ((CodeView&)*mdiWindow).find(); +} + +void MainFrame::handleFileNew(void) +{ +// CodeView *pCodeView; +// +// pCodeView=::new CodeView; +// pCodeView->setLineHandler(&mLineHandler); +// pCodeView->createWindow(*this,STRING_CODEVIEWCLASSNAME,STRING_CODEVIEWCLASSNAME,"codeMenu","Doc"); +// insert(*pCodeView); +} + +void MainFrame::handleFileOpen(CallbackData &someCallbackData) +{ +/* PureMenu fileMenu; + String menuItemString; + + getFrameMenu().getSubMenu(0,fileMenu); + menuItemString=fileMenu.menuItemString(someCallbackData.wParam(),PureMenu::ByCommand); + if(menuItemString.isNull())return; + menuItemString=menuItemString.betweenString(')',0); + menuItemString.trimLeft(); + handleFileOpen(menuItemString); */ +} + +void MainFrame::handleFileOpen(void) +{ +/* OpenDialog openDialog; + String strPathFileName; + + if(!openDialog.getOpenFileName(*this,"*.asm","Open File","*.asm",strPathFileName))return; + handleFileOpen(strPathFileName); */ +} + +void MainFrame::handleFileOpen(const String &strPathFileName) +{ +/* CodeView *pCodeView; + CursorControl cursorControl; + + if(bringDocumentToFront(strPathFileName))return; + mStatusBar->setText("Loading..."); + cursorControl.waitCursor(TRUE); + + pCodeView=::new CodeView; + insert(*pCodeView); // insert the pointer before creating/activating the window + pCodeView->createWindow(*this,STRING_CODEVIEWCLASSNAME,STRING_CODEVIEWCLASSNAME,"codeMenu","Doc"); + pCodeView->setLineHandler(&mLineHandler); + pCodeView->open(strPathFileName); + mStatusBar->setText("Ready"); + cursorControl.waitCursor(FALSE); + updateHistory(strPathFileName); */ +} + +void MainFrame::handleFileClose(void) +{ + SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + mdiWindow->close(); +} + +void MainFrame::handleFilePrint(void) +{ +/* SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return; + ((CodeView&)*mdiWindow).print(); */ +} + +BOOL MainFrame::handleFileSave(void) +{ +/* SmartPointer mdiWindow; + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return FALSE; + CodeView &codeView=(CodeView&)*mdiWindow; + if(codeView.getTitle()==String(STRING_UNTITLED))return handleFileSaveAs(); + if(!codeView.save())return mStatusBar->setText(codeView.getTitle()+String(" save failed.")),FALSE; + return mStatusBar->setText(codeView.getTitle()+String(" saved.")),TRUE; */ + return TRUE; +} + +BOOL MainFrame::handleFileSaveAs(void) +{ +/* SmartPointer mdiWindow; + OpenDialog openDialog; + String strPathFileName; + + if(!getActive(mdiWindow)||!(mdiWindow->className()==String(STRING_CODEVIEWCLASSNAME)))return FALSE; + if(!openDialog.getSaveFileName(*this,"Assembly Files","File Save","*.asm",strPathFileName))return FALSE; + if(!strPathFileName.strstr(".asm"))strPathFileName+=".asm"; + if(!((CodeView&)*mdiWindow).save(strPathFileName))return mStatusBar->setText(strPathFileName+String(" save failed!.")),FALSE; + return mStatusBar->setText(strPathFileName+String(" saved.")),TRUE; */ + + return false; +} + +void MainFrame::handleCommunications(void) +{ +// SerialDlg serDlg; +// serDlg.perform(*this); +} + +void MainFrame::handleHelp(void) +{ + String strPathHelpFileName; + DiskInfo diskInfo; + + diskInfo.getCurrentDirectory(strPathHelpFileName); + strPathHelpFileName+=String(STRING_HELPFILENAME); + ::WinHelp(*this,strPathHelpFileName,HELP_CONTENTS,0); +} + +// support & testing +BOOL MainFrame::codeLoad(const String &strPathBinary) +{ +/* MCUView *pMCUView; + + pMCUView=::new MCUView; + pMCUView->createWindow(*this,STRING_MCUVIEWCLASSNAME,STRING_MCUVIEWCLASSNAME,"mcuMenu","Doc"); + insert(*pMCUView); + pMCUView->setCode(strPathBinary); */ + return TRUE; +} + +void MainFrame::setParts(int numParts) +{ + GlobalData statParts; + if(1==numParts){statParts.size(1);*((int*)&statParts[0])=FirstPartWidth;} + else {statParts.size(2);*((int*)&statParts[0])=FirstPartWidth;*((int*)&statParts[0]+1)=SecondPartWidth;} + mStatusBar->setParts(statParts); +} + +void MainFrame::updateHistory(const String &pathFileName) +{ +/* M68Reg m68Reg; + SmartPointer mdiWindow; + + if(!m68Reg.insertHistory(pathFileName))return; + removeHistory(getFrameMenu()); + applyHistory(getFrameMenu()); + if(getFirstDocument(mdiWindow)) + { + removeHistory(mdiWindow->getMenu()); + applyHistory(mdiWindow->getMenu()); + while(getNextDocument(mdiWindow)) + { + removeHistory(mdiWindow->getMenu()); + applyHistory(mdiWindow->getMenu()); + } + } */ +} + +void MainFrame::removeHistory(PureMenu &pureMenu) +{ +/* M68Reg m68Reg; + UINT startID(StartDynamicID); + Block nameList; + PureMenu fileMenu; + + m68Reg.getHistory(nameList); + if(!nameList.size())return; + pureMenu.getSubMenu(0,fileMenu); + for(int itemIndex=0;itemIndex nameList; + PureMenu fileMenu; + String strItem; + + m68Reg.getHistory(nameList); + if(!nameList.size())return; + pureMenu.getSubMenu(0,fileMenu); + fileMenu.appendSeparator(); + for(int itemIndex=0;itemIndex addBitmaps; + + mToolBar.create(*this,ToolBarID); + addBitmaps.insert(&AddBitmap(0,HINST_COMMCTRL)); + if(!mToolBar.addBitmaps(addBitmaps))return; + mToolBar.addButton(ToolBarButton(STD_FILENEW,MenuFileNew,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_FILEOPEN,MenuFileOpen,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_FILESAVE,MenuFileSave,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_PRINT,MenuFilePrint,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_CUT,MenuEditCut,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_COPY,MenuEditCopy,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_PASTE,MenuEditPaste,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_FIND,MenuEditFind,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); + mToolBar.addButton(ToolBarButton(STD_PRINT,MenuFilePrint,ToolBarButton::StateEnabled,ToolBarButton::StyleButton)); +} + +BOOL MainFrame::bringDocumentToFront(const String &strTitle) +{ + SmartPointer mdiWindowPtr; + + if(getFirstDocument(mdiWindowPtr)) + { + if(((CodeView&)*mdiWindowPtr).getTitle()==strTitle){mdiWindowPtr->bringWindowToTop();return TRUE;} + while(getNextDocument(mdiWindowPtr))if(((CodeView&)*mdiWindowPtr).getTitle()==strTitle){mdiWindowPtr->bringWindowToTop();return TRUE;} + } + return FALSE; +} + +void MainFrame::splash(void) +{ + SplashScreen splashScreen("SPLASH","M68HC11"); + splashScreen.perform(); +} + +// virtuals + +void MainFrame::mdiDestroy(MDIWindow &mdiWindow) +{ + SmartPointer mdiWindowPtr; + WORD winCount(0); + + if(getFirstDocument(mdiWindowPtr)) + { + if(mdiWindowPtr->className()==String(STRING_CODEVIEWCLASSNAME)&&((MDIWindow*)mdiWindowPtr!=&mdiWindow))winCount++; + while(getNextDocument(mdiWindowPtr))if(mdiWindowPtr->className()==String(STRING_CODEVIEWCLASSNAME)&&((MDIWindow*)mdiWindowPtr!=&mdiWindow))winCount++; + } + if(!winCount)setParts(SinglePart); +} + +void MainFrame::mdiActivate(MDIWindow &mdiWindow) +{ + if(mdiWindow.className()==String(STRING_CODEVIEWCLASSNAME))setParts(DoublePart); + removeHistory(mdiWindow.getMenu()); + applyHistory(mdiWindow.getMenu()); +} + +void MainFrame::mdiDeactivate(MDIWindow &/*mdiWindow*/) +{ +} diff --git a/aladin/mainfrm.hpp b/aladin/mainfrm.hpp new file mode 100644 index 0000000..971f5d1 --- /dev/null +++ b/aladin/mainfrm.hpp @@ -0,0 +1,98 @@ +#ifndef _ALADIN_MAINFRAME_HPP_ +#define _ALADIN_MAINFRAME_HPP_ +#ifndef _COMMON_MDIFRM_HPP_ +#include +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif +#ifndef _STATBAR_STATUSBAREX_HPP_ +#include +#endif +#ifndef _TOOLBAR_TOOLBAR_HPP_ +#include +#endif +#ifndef _COMMCTRL_COMMCONTROL_HPP_ +#include +#endif + +class MainFrame : public FrameWindow +{ +public: + MainFrame(void); + virtual ~MainFrame(); + static String className(void); + void splash(void); +protected: + virtual void mdiDestroy(MDIWindow &mdiWindow); + virtual void mdiActivate(MDIWindow &mdiWindow); + virtual void mdiDeactivate(MDIWindow &mdiWindow); +private: + enum {StatusBarID=500,ToolBarID=501,StartDynamicID=30000}; + enum{SinglePart=1,DoublePart=2,FirstPartWidth=340,SecondPartWidth=420}; + enum{MenuFileSave=SBCMENU_FILESAVE,MenuFileQuit=SBCMENU_FILEQUIT,MenuFilePrint=SBCMENU_FILEPRINT, + MenuSettingsSerial=SBCMENU_SETTINGSSERIAL,MenuHelpContents=SBCMENU_HELPCONTENTS, + MenuHelpSearch=SBCMENU_HELPSEARCH,MenuRegistration=SBCMENU_REGISTRATION,MenuFileNew=SBCMENU_FILENEW, + MenuFileOpen=SBCMENU_FILEOPEN,MenuHelpAbout=SBCMENU_HELPABOUT,MenuFileClose=SBCMENU_FILECLOSE, + MenuFileSaveAs=SBCMENU_FILESAVEAS,MenuCascade=IDM_CASCADE,MenuTile=IDM_TILE,MenuArrange=IDM_ARRANGE, + MenuCloseAll=IDM_CLOSEALL,MenuMinimizeAll=IDM_MINIMIZEALL,MenuRestoreAll=IDM_RESTOREALL, + MenuEditCut=SBCMENU_EDITCUT,MenuEditCopy=SBCMENU_EDITCOPY,MenuEditPaste=SBCMENU_EDITPASTE, + MenuEditFind=SBCMENU_EDITFIND,MenuCodeCompile=SBCMENU_CODECOMPILE, + MenuCodeCompileAndLoad=SBCMENU_CODECOMPILEANDLOAD}; + CallbackData::ReturnType queryEndSessionHandler(CallbackData &someCallbackData); + CallbackData::ReturnType paintHandler(CallbackData &someCallbackData); + CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData); + CallbackData::ReturnType commandHandler(CallbackData &someCallbackData); + CallbackData::ReturnType keyDownHandler(CallbackData &someCallbackData); + CallbackData::ReturnType sizeHandler(CallbackData &someCallbackData); + CallbackData::ReturnType timerHandler(CallbackData &someCallbackData); + CallbackData::ReturnType createHandler(CallbackData &someCallbackData); + CallbackData::ReturnType activateAppHandler(CallbackData &someCallbackData); + CallbackData::ReturnType displayChangeHandler(CallbackData &someCallbackData); + void createToolBar(void); + void handleCommunications(void); + void handleEditCut(void); + void handleEditCopy(void); + void handleEditPaste(void); + void handleEditFind(void); + void handleFileNew(void); + void handleFileOpen(void); + void handleFileOpen(CallbackData &someCallbackData); + void handleFileOpen(const String &strPathFileName); + void handleFileClose(void); + void handleFilePrint(void); + void handleHelp(void); + BOOL handleFileSave(void); + BOOL handleFileSaveAs(void); + void registerClass(void)const; + void insertHandlers(void); + void removeHandlers(void); + void setParts(int numParts); + void applyHistory(PureMenu &pureMenu); + void updateHistory(const String &pathFileName); + void removeHistory(PureMenu &pureMenu); + BOOL bringDocumentToFront(const String &strTitle); + + Callback mQueryEndSessionHandler; + Callback mPaintHandler; + Callback mDestroyHandler; + Callback mCommandHandler; + Callback mSizeHandler; + Callback mCreateHandler; + SmartPointer mStatusBar; + CommControl mCommControl; + ToolBar mToolBar; +// SerialSettings mSerialSettings; + static char szClassName[]; + static char szMenuName[]; +}; + +inline +String MainFrame::className(void) +{ + return String(szClassName); +} +#endif diff --git a/aladin/prodinfo.hpp b/aladin/prodinfo.hpp new file mode 100644 index 0000000..a75766c --- /dev/null +++ b/aladin/prodinfo.hpp @@ -0,0 +1,88 @@ +#ifndef _ALADIN_PRODUCTINFO_HPP_ +#define _ALADIN_PRODUCTINFO_HPP_ +#ifndef _COMMON_REGKEY_HPP_ +#include +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _ALADIN_RESOURCE_HPP_ +#include +#endif + +class ProductInfo +{ +public: + ProductInfo(void); + virtual ~ProductInfo(); + void refresh(void); + const String &strProductName(void)const; + const String &strRegisteredOwner(void)const; + const String &strProductID(void)const; + const String &strVersion(void)const; +private: + String mStrProductName; + String mStrRegisteredOwner; + String mStrProductID; + String mStrVersion; +}; + +inline +ProductInfo::ProductInfo(void) +{ + refresh(); +} + +inline +ProductInfo::~ProductInfo() +{ +} + +inline +void ProductInfo::refresh(void) +{ + RegKey regKey(RegKey::LocalMachine); + + if(!regKey.openKey(String(STRING_CURRENTVERSIONKEYNAME)))return; + regKey.queryValue(String(STRING_PRODUCTNAME),mStrProductName); + if(!mStrProductName.isNull()) + { + regKey.queryValue(String(STRING_REGISTEREDOWNER),mStrRegisteredOwner); + regKey.queryValue(String(STRING_PRODUCTID),mStrProductID); + regKey.queryValue(String(STRING_VERSIONNUMBER),mStrVersion); + } + else + { + RegKey regKey(RegKey::LocalMachine); + if(!regKey.openKey(String(STRING_CURRENTVERSIONNTKEYNAME)))return; + regKey.queryValue(String(STRING_PRODUCTNAME),mStrProductName); + regKey.queryValue(String(STRING_REGISTEREDOWNER),mStrRegisteredOwner); + regKey.queryValue(String(STRING_PRODUCTID),mStrProductID); + regKey.queryValue(String(STRING_VERSIONNUMBER),mStrVersion); + } +} + +inline +const String &ProductInfo::strProductName(void)const +{ + return mStrProductName; +} + +inline +const String &ProductInfo::strRegisteredOwner(void)const +{ + return mStrRegisteredOwner; +} + +inline +const String &ProductInfo::strProductID(void)const +{ + return mStrProductID; +} + +inline +const String &ProductInfo::strVersion(void)const +{ + return mStrVersion; +} +#endif diff --git a/aladin/profiledata.hpp b/aladin/profiledata.hpp new file mode 100644 index 0000000..702ea35 --- /dev/null +++ b/aladin/profiledata.hpp @@ -0,0 +1,126 @@ +#ifndef _ALADIN_PROFILEDATA_HPP_ +#define _ALADIN_PROFILEDATA_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_FILE_HPP_ +#include +#endif + +class ProfileData +{ +public: + typedef enum Warning{TransmitErrorAirPressure=0x20,WorkTooHard=0x10,CeilingViolationOfDeco=0x08,AscentTooFast=0x04,RemainingBottomTimeTooShort=0x02,DecoStop=0x01,None=0}; + ProfileData(void); + ProfileData(int depth,int stageTime,int warning); + bool operator==(const ProfileData &profileData)const; + bool writeTo(File &outFile); + bool readFrom(File &inFile); + virtual ~ProfileData(); + int getDepth(void)const; + void setDepth(int depth); + int getStageTime(void)const; + void setStageTime(int stageTime); + Warning getWarning(void)const; + String getWarningString(void)const; + void setWarning(Warning warning); + String toString(void)const; +private: + int mDepth; + int mStageTime; + int mWarning; +}; + +inline +ProfileData::ProfileData() +: mDepth(0), mStageTime(0), mWarning(None) +{ +} + +inline +ProfileData::ProfileData(int depth,int stageTime,int warning) +: mDepth(depth), mStageTime(stageTime), mWarning(warning) +{ +} + +inline +ProfileData::~ProfileData() +{ +} + +inline +bool ProfileData::operator==(const ProfileData &profileData)const +{ + return (mDepth==profileData.mDepth&&mStageTime==profileData.mStageTime&&mWarning==profileData.mWarning); +} + +inline +String ProfileData::toString(void)const +{ + String str; + + str+=String("Depth:")+String().fromInt(getDepth())+String(" "); + str+=String("StageTime:")+String().fromInt(getStageTime())+String(" "); + str+=String("Warning:")+String().fromInt(getWarning()); + return str; +} + +inline +bool ProfileData::readFrom(File &inFile) +{ + if(!inFile.isOkay())return false; + if(!inFile.read(&mDepth,sizeof(mDepth)))return false; + if(!inFile.read(&mStageTime,sizeof(mStageTime)))return false; + if(!inFile.read(&mWarning,sizeof(mWarning)))return false; + return true; +} + +inline +bool ProfileData::writeTo(File &outFile) +{ + if(!outFile.isOkay())return false; + if(!outFile.write(&mDepth,sizeof(mDepth)))return false; + if(!outFile.write(&mStageTime,sizeof(mStageTime)))return false; + if(!outFile.write(&mWarning,sizeof(mWarning)))return false; + return true; +} + +inline +int ProfileData::getDepth(void)const +{ + return mDepth; +} + +inline +void ProfileData::setDepth(int depth) +{ + mDepth=depth; +} + +inline +int ProfileData::getStageTime(void)const +{ + return mStageTime; +} + +inline +void ProfileData::setStageTime(int stageTime) +{ + mStageTime=stageTime; +} + +inline +ProfileData::Warning ProfileData::getWarning(void)const +{ + return (Warning)mWarning; +} + +inline +void ProfileData::setWarning(Warning warning) +{ + mWarning=warning; +} +#endif diff --git a/aladin/profiles.cpp b/aladin/profiles.cpp new file mode 100644 index 0000000..b9766e7 --- /dev/null +++ b/aladin/profiles.cpp @@ -0,0 +1,109 @@ +#include +#include +#include +#include +#include + +bool Profiles::readFrom(RawData &array,Information &info,CurrentStatus &status) +{ + int index=0; + int endIndex; + int time; + WORD headerLength; + WORD depth; + BYTE warnings; + BYTE decoInfo; + double conversion=3.281; + + try + { + while(true) + { + while(Marker!=array[index]&&indexarray.size()||index>=0x5FF)break; + index++; + if(info.isNitroxOnly())index+=23; + else if(info.isO2())index+=24; + else index+=22; + time=20; + + DiveProfile diveProfile; + endIndex=getNextMarkerPos(array,index); + while(index>=6; + depth=(int)((((double)depth*10.00/64.00)*conversion)+.5); + index+=sizeof(WORD); + if(index>=0x5FF)break; + ProfileData profileData(depth,time,warnings); + diveProfile.insert(&ProfileData(depth,time,warnings)); + if(index>=endIndex) + { + index-=sizeof(WORD); + break; + } + if(depth==0)break; + if(!(time%60)) + { + decoInfo=array[index]; + index++; + } + time+=20; + } + if(!haveProfile(diveProfile))insert(&diveProfile); + } + } + catch(ArrayIndexOutOfBoundsException exception) + { + ::OutputDebugString(exception.toString()+String("\n")); + return false; + } + return true; +} + +bool Profiles::readFrom(File &inFile) +{ + int count; + + if(!inFile.isOkay())return false; + if(!inFile.read(&count,sizeof(count)))return false; + for(int index=0;index &array,int currIndex) +{ + while(currIndex=array.size())return array.size()-1; + return currIndex; +} + +bool Profiles::haveProfile(DiveProfile &diveProfile) +{ + for(int index=0;index +#endif +#ifndef _COMMON_ARRAY_HPP_ +#include +#endif +#ifndef _ALADIN_STATUS_HPP_ +#include +#endif +#ifndef _ALADIN_INFORMATION_HPP_ +#include +#endif +#ifndef _ALADIN_DIVEPROFILE_HPP_ +#include +#endif +#ifndef _ALADIN_RAWDATA_HPP_ +#include +#endif + +class File; +typedef Block DiveProfiles; + +class Profiles : public DiveProfiles +{ +public: + enum{Marker=0xFF}; + bool readFrom(RawData &array,Information &info,CurrentStatus &status); + bool readFrom(File &inFile); + bool writeTo(File &outFile); + bool haveProfile(DiveProfile &diveProfile); +private: + int getNextMarkerPos(Array &array,int currIndex); +}; +#endif diff --git a/aladin/rawdata.hpp b/aladin/rawdata.hpp new file mode 100644 index 0000000..d4addec --- /dev/null +++ b/aladin/rawdata.hpp @@ -0,0 +1,12 @@ +#ifndef _ALADIN_RAWDATA_HPP_ +#define _ALADIN_RAWDATA_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_ARRAY_HPP_ +#include +#endif +typedef Array RawData; +#endif + + diff --git a/aladin/resource.h b/aladin/resource.h new file mode 100644 index 0000000..fcc548c --- /dev/null +++ b/aladin/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by aladin.rc +// +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1016 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/aladin/resource.hpp b/aladin/resource.hpp new file mode 100644 index 0000000..48a779b --- /dev/null +++ b/aladin/resource.hpp @@ -0,0 +1,6 @@ +#ifndef _ALADIN_RESOURCE_HPP_ +#define _ALADIN_RESOURCE_HPP_ +#ifndef _ALADIN_ALADIN_H_ +#include +#endif +#endif \ No newline at end of file diff --git a/aladin/scraps.txt b/aladin/scraps.txt new file mode 100644 index 0000000..f0b745f --- /dev/null +++ b/aladin/scraps.txt @@ -0,0 +1,417 @@ +void SerialDlg::testDevice(void) +{ + CommControl commControl; + BYTE prefix(0xFF); + GlobalData rcvBuffer; + GlobalData sndBuffer; + BYTE codeBytes[]={0x8E,0x00,0xFF,0xCE,0x10,0x00,0x6F,0x2C,0xCC,0x33,0x0C,0xA7,0x2B,0xE7,0x2D,0x1F,0x2E,0x20,0xFC,0xA6,0x2F,0x4C,0x1F,0x2E,0x80,0xFC,0xA7,0x2F,0x7E,0x00,0x0F}; + + sndBuffer.size(256); + sndBuffer.setZero(); + rcvBuffer.size(sndBuffer.size()); + rcvBuffer.setZero(); + ::memcpy(&sndBuffer[0],codeBytes,sizeof(codeBytes)); + if(IDCANCEL==::MessageBox(*this,"This operation will overwrite the contents of MCU RAM with the ECHO program.","WARNING",MB_OKCANCEL))return; + if(!commControl.open(getCommPort())){mStatusBar->setText("Error opening port.");return;} + if(!commControl.setDeviceControlBlock(getCommSettings())){mStatusBar->setText("Failed to apply settings.");return;} + mStatusBar->setText("waiting for break signal....please reset the device."); + if(!commControl.waitForBreak()){mStatusBar->setText("timeout waiting for break.");return;} + mStatusBar->setText("break received, loading code..."); + commControl.write(&prefix,sizeof(prefix)); + commControl.clearReceiveQueue(); + commControl.write(sndBuffer); + mStatusBar->setText("Waiting for response."); + if(!commControl.waitForData()){mStatusBar->setText("Timeout reached for receive.");return;} + commControl.readFully(rcvBuffer); + if(::memcmp(&rcvBuffer[0],&sndBuffer[0],sndBuffer.size())) + { + mStatusBar->setText("Failed to verify program load."); + return; + } + ::Sleep(250); + if(!echo(commControl))mStatusBar->setText("Received unexpected results from program."); + else mStatusBar->setText("The program has been verified, all tests successful."); + return; +} + +bool SerialDlg::echo(CommControl &commControl) +{ + BYTE sndByte('a'); + BYTE rcvByte=0; + DWORD rcvCount(0); + String str; + + if(!commControl.isOkay()) + { + if(!commControl.open(getCommPort())){mStatusBar->setText("Unable to open comm port.");mStatusBar->setText("Error opening port.");return false;} + if(!commControl.setDeviceControlBlock(getCommSettings())){mStatusBar->setText("Failed to apply settings.");return false;} + } + commControl.clearError(); + while('z'!=rcvByte) + { + CommStatus commStatus; + commControl.write(&sndByte,sizeof(sndByte)); + if(commControl.waitForData()) + { + rcvByte=0; + commControl.read(&rcvByte,sizeof(rcvByte)); + str+=rcvByte; + mStatusBar->setText(str); + if(!rcvCount&&rcvByte!='b') + { + mStatusBar->setText("Unexpected character in input stream."); + return false; + } + sndByte++; + rcvCount++; + } + } + ::Sleep(250); + return true; +} + +String SerialDlg::getByteString(BYTE charByte) +{ + String str; + ::sprintf(str.str(),"char:%d(0x%08lx)",(int)charByte,(int)charByte); + return str; +} + + + + + +unsigned long DiveLog::getEntryTimeLong(void)const +{ + return mEntryTime1*Math::power(2,24)+mEntryTime2*Math::power(2,16)+mEntryTime3*Math::power(2,8)+mEntryTime4; +} + + + + + + +/* +bool Profile::readFrom(Array &array,Information &info,CurrentStatus &status) +{ + int index=0; + int endIndex; + int time; + WORD headerLength; + WORD depthAt20; + BYTE warningAt20; + WORD depthAt40; + BYTE warningAt40; + WORD depthAt60; + BYTE warningAt60; + BYTE decoInfo; + double conversion; + + conversion=3.281; + remove(); + try + { + while(true) + { + while(Marker!=array[index]&&indexarray.size()||index>=0x5FF)break; + + String string; + ::sprintf(string,"Reading profile at offset: %d (0x%08lx) %02lx,%02lx,%02lx \n",index,index,(int)array.elementAt(index),(int)array.elementAt(index+1),(int)array.elementAt(index+2)); + ::OutputDebugString(string); + + index++; + + if(info.isNitroxOnly())index+=23; + else if(info.isO2())index+=24; + else index+=22; + time=20; + DiveProfile diveProfile; + insert(&diveProfile); + endIndex=getNextMarkerPos(array,index); + while(index>=6; +// depthAt20=depthAt20*10/64; + index+=sizeof(WORD); + if(index>=0x5FF)break; + diveProfile.insert(&ProfileData(depthAt20*conversion,time,warningAt20)); + ::OutputDebugString(String("Time:")+String().fromInt(time)+String(" Depth:")+String().fromInt(depthAt20*conversion)+String("\n")); + time+=20; + if(index>=endIndex) + { + index-=sizeof(WORD); + break; + } + if(depthAt20==0)break; + + depthAt40=*((WORD*)&array[index]); + depthAt40=BitManip::reverse(depthAt40); + warningAt40=depthAt40&0x3F; + depthAt40>>=6; + depthAt40=depthAt40*10/64; + index+=sizeof(WORD); + if(index>=0x5FF)break; + diveProfile.insert(&ProfileData(depthAt40*conversion,time,warningAt40)); + ::OutputDebugString(String("Time:")+String().fromInt(time)+String(" Depth:")+String().fromInt(depthAt40*conversion)+String("\n")); + time+=20; + if(index>=endIndex) + { + index-=sizeof(WORD); + break; + } + + depthAt60=*((WORD*)&array[index]); + depthAt60=BitManip::reverse(depthAt60); + warningAt60=depthAt60&0x3F; + depthAt60>>=6; + depthAt60=depthAt60*10/64; + index+=sizeof(WORD); + if(index>=0x5FF)break; + diveProfile.insert(&ProfileData(depthAt60,time,warningAt60)); + ::OutputDebugString(String("Time:")+String().fromInt(time)+String(" Depth:")+String().fromInt(depthAt60*conversion)+String("\n")); + time+=20; + if(index>=endIndex) + { + index-=sizeof(WORD); + break; + } + + decoInfo=array[index]; + index++; + } + ::OutputDebugString("*********************************************************\n"); + } + } + catch(ArrayIndexOutOfBoundsException exception) + { + ::OutputDebugString(exception.toString()+String("\n")); + return false; + } + return true; +} */ + + + + + + +/* Worksheet worksheet; +// Worksheet load; +// int rows(10); +// int cols(10); + +// worksheet.setDimensions(rows,cols); + worksheet.open("d:\\parts\\lotus\\a.wk1"); + worksheet.save("d:\\mysheet.wk1"); +// worksheet.open("d:\\divelog.123"); */ + +/* File outFile("c:\\aladin2.dat","wb"); + File outFile2("c:\\aladin2.txt","wb"); + outFile.write(syncBuff,sizeof(syncBuff)); + outFile.write(rcvBuff,sizeof(rcvBuff)); + Block strLines; + FormatLines::hexasciiLines(strLines,(BYTE*)rcvBuff,sizeof(rcvBuff)); + for(index=0;index&)profile)[pIndex]; + sRow=startRow; + String strTitle(String("Profile_")+String().fromInt(pIndex+1)); + worksheet.setAt(sRow++,startCol,strTitle); + worksheet.setAt(sRow,startCol,"Time"); + worksheet.setAt(sRow++,startCol+1,"Depth"); + for(int diveIndex=0;diveIndex + +void OwnerDrawGraph::setData(DiveProfile &diveProfile) +{ + Block &profileData=(Block &)diveProfile; + Array dstPairs; + + double wRatio=(double)width()/(double)profileData.size(); + double hRatio=(double)height()/getMaxDepth(profileData); + double x=wRatio; + + ::OutputDebugString(String("Width:")+String().fromInt(width())+String(" entries:")+String().fromInt(profileData.size())+String(" Ratio:")+String().fromDouble(wRatio)+String("\n")); + splineData(profileData,dstPairs,wRatio); + + ::OutputDebugString(String("Width:")+String().fromInt(width())+String(" entries:")+String().fromInt(profileData.size())+String(" Ratio:")+String().fromDouble(wRatio)+String("\n")); + mDIBitmap->setBits(0); +/* for(int index=0;indexline(Point(x,0),Point(x,(int)(double)pData.getDepth()*(double)hRatio),RGB888(0,255,0)); + x+=wRatio; + } */ + + for(int index=0;indexline(Point(x,0),Point(x,(int)fp.row()*(double)hRatio),RGB888(0,255,0)); + x+=2; +// x+=wRatio; + } +} + +void OwnerDrawGraph::splineData(Block &profileData,Array &dstPairs,double wRatio) +{ + CatmullRom catmullRom; + Array srcPairs; + + srcPairs.size(width()); + dstPairs.size(width()); + ::OutputDebugString(String("Entries:")+String().fromInt(profileData.size())+String(" \n")); + for(int index=0;index(%d,%d)\n",p1.x(),p1.y(),p2.x(),p2.y()); + ::OutputDebugString(strPoints.str()); + mDIBitmap->line(p1,p2,hashColor); +// if(!depth)break; + } + +/* + p1=Point(0,(int)(double)depth*(double)hRatio); + p2=Point(5,(int)(double)depth*(double)hRatio); + p1.y(height()-p1.y()); + p2.y(height()-p2.y()); + if(p1.y()<=0)p1.y(1); + if(p2.y()<=0)p2.y(1); + mDIBitmap->line(p1,p2,RGB888(0,255,0)); +*/ + +} + + + + +/* +void OwnerDrawGraph::setData(DiveProfile &diveProfile) +{ + Block &profileData=(Block &)diveProfile; + + double wRatio=(double)width()/(double)profileData.size(); + double hRatio=(double)height()/getMaxDepth(profileData); + double x=wRatio; + + mDIBitmap->setBits(0); + for(int index=0;indexline(Point(x,0),Point(x,(int)(double)pData.getDepth()*(double)hRatio),RGB888(0,255,0)); + x+=wRatio; + } + mHasData=true; +} +*/ diff --git a/aladin/serdlg.cpp b/aladin/serdlg.cpp new file mode 100644 index 0000000..7f6be65 --- /dev/null +++ b/aladin/serdlg.cpp @@ -0,0 +1,388 @@ +#include +#include +#include + +SerialDlg::SerialDlg(void) +{ + mInitHandler.setCallback(this,&SerialDlg::initHandler); + mDestroyHandler.setCallback(this,&SerialDlg::destroyHandler); + mCommandHandler.setCallback(this,&SerialDlg::commandHandler); + mCloseHandler.setCallback(this,&SerialDlg::closeHandler); + DWindow::insertHandler(VectorHandler::InitDialogHandler,&mInitHandler); + DWindow::insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + DWindow::insertHandler(VectorHandler::CommandHandler,&mCommandHandler); + DWindow::insertHandler(VectorHandler::CloseHandler,&mCloseHandler); +} + +SerialDlg::~SerialDlg() +{ + DWindow::removeHandler(VectorHandler::InitDialogHandler,&mInitHandler); + DWindow::removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + DWindow::removeHandler(VectorHandler::CommandHandler,&mCommandHandler); + DWindow::removeHandler(VectorHandler::CloseHandler,&mCloseHandler); +} + +SerialDlg &SerialDlg::operator=(const SerialDlg &/*someSerialDlg*/) +{ // private implementation + return *this; +} + +BOOL SerialDlg::perform(GUIWindow &parentWindow) // ,SerialSettings &serialSettings) +{ + return ::DialogBoxParam(processInstance(),(LPSTR)"SERIAL",(HWND)parentWindow,DWindow::DlgProc,(LPARAM)(DWindow*)this); +} + +CallbackData::ReturnType SerialDlg::initHandler(CallbackData &/*someCallbackData*/) +{ + mStatusBar=::new StatusBarEx(*this,StatusBarID); + mStatusBar.disposition(PointerDisposition::Delete); + initSerialSettings(); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SerialDlg::destroyHandler(CallbackData &/*someCallbackData*/) +{ + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SerialDlg::commandHandler(CallbackData &someCallbackData) +{ + switch(someCallbackData.wmCommandID()) + { + case IDOK : + if(applySerialSettings())endDialog(TRUE); + break; + case IDCANCEL : + endDialog(FALSE); + break; + case SerialStopBits : + case SerialParity : + case SerialDataBits : + case SerialBaud : + case SerialPort : + mStatusBar->setText(" "); + break; + case SerialApply : + applySerialSettings(); + break; + case SerialReset : + reset(); + break; + } + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SerialDlg::closeHandler(CallbackData &/*someCallbackData*/) +{ + return (CallbackData::ReturnType)FALSE; +} + +void SerialDlg::initSerialSettings(void) +{ + AppReg appReg; + + initPorts(); + initBaud(); + initDataBits(); + initStopBits(); + initParity(); + sendMessage(SerialPort,CB_SELECTSTRING,-1,(LPARAM)(LPSTR)appReg.getPort()); + sendMessage(SerialBaud,CB_SELECTSTRING,-1,(LPARAM)(LPSTR)appReg.getBaud()); + sendMessage(SerialDataBits,CB_SELECTSTRING,-1,(LPARAM)(LPSTR)appReg.getDataBits()); + sendMessage(SerialParity,CB_SELECTSTRING,-1,(LPARAM)(LPSTR)appReg.getParity()); + sendMessage(SerialStopBits,CB_SELECTSTRING,-1,(LPARAM)(LPSTR)appReg.getStopBits()); +} + +void SerialDlg::initPorts(void) +{ + String strPort; + CommControl commControl; + Block ports; + + sendMessage(SerialPort,CB_RESETCONTENT,0,0L); + commControl.enumerateDevices(ports); + for(int index=0;indexsetText("Error opening port."); + ::MessageBeep(0); + return false; + } + if(!commControl.setDeviceControlBlock(strCommSettings)){mStatusBar->setText("Failed to apply settings.");return false;} + sendMessage(SerialBaud,WM_GETTEXT,String::MaxString,(LPARAM)(LPSTR)strBaud); + appReg.setBaud(strBaud); + sendMessage(SerialDataBits,WM_GETTEXT,String::MaxString,(LPARAM)(LPSTR)strDataBits); + appReg.setDataBits(strDataBits); + currSel=sendMessage(SerialParity,CB_GETCURSEL,0,0L); + sendMessage(SerialParity,CB_GETLBTEXT,0,(LPARAM)(LPSTR)strParity); + if(String("None")==strParity)strParity="N"; + else if(String("Odd")==strParity)strParity="O"; + else if(String("Even")==strParity)strParity="E"; + else if(String("Space")==strParity)strParity="S"; + appReg.setParity(strParity); + currSel=sendMessage(SerialStopBits,CB_GETCURSEL,0,0L); + sendMessage(SerialStopBits,CB_GETLBTEXT,0,(LPARAM)(LPSTR)strStopBits); + appReg.setStopBits(strStopBits); + mStatusBar->setText("Settings have been applied."); + return true; +} + +void SerialDlg::reset() +{ + AppReg appReg; + CommControl commControl; + Block deviceList; + + + if(IDCANCEL==::MessageBox(*this,"Reset serial settings to default values?","Confirm",MB_OKCANCEL))return; + commControl.enumerateDevices(deviceList); + appReg.setBaud("19200"); + appReg.setParity("N"); + appReg.setDataBits("8"); + appReg.setStopBits("1"); + appReg.setPort(deviceList.size()?deviceList[0]:"COM1"); + initSerialSettings(); +} + +/*void SerialDlg::testDevice() +{ + CommControl commControl; + DeviceControlBlock dcb; + + if(!commControl.open(getCommPort())){mStatusBar->setText("Error opening port.");return;} + if(!commControl.setDeviceControlBlock(getCommSettings())){mStatusBar->setText("Failed to apply settings.");return;} + mStatusBar->setText("loading data..."); + commControl.getDeviceControlBlock(dcb); + dcb.dtrControl(DeviceControlBlock::DtrControlEnable); + dcb.rtsControl(DeviceControlBlock::RtsControlEnable); + commControl.setDeviceControlBlock(dcb); + +} */ + +/* + + +void printDCB(CommControl &control,bool wait); +bool getControlData(CommControl &control); + +Console console; + + DeviceControlBlock dcb; + CommControl control; + Block deviceList; + String selDevice; + String strPrompt; + String strCommState="baud=19200 parity=N data=8 stop=1"; + + control.enumerateDevices(deviceList); + for(int index=0;index strLines; + FormatLines::hexasciiLines(strLines,rcvBuff,sizeof(rcvBuff)); + for(int index=0;index +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif +#ifndef _STATBAR_STATUSBAREX_HPP_ +#include +#endif +#ifndef _COMMCTRL_COMMCTRL_HPP_ +#include +#endif +#ifndef _ALADIN_ALADINRC_HPP_ +#include +#endif + + +class SerialDlg : public DWindow +{ +public: + SerialDlg(void); + virtual ~SerialDlg(); + BOOL perform(GUIWindow &parentWindow); +private: + enum{SerialStopBits=SERIAL_STOP,SerialParity=SERIAL_PARITY,SerialDataBits=SERIAL_DATA, + SerialBaud=SERIAL_BAUD,SerialPort=SERIAL_PORT,SerialApply=SERIAL_APPLY,SerialReset=SERIAL_RESET}; + enum {StatusBarID=500}; + SerialDlg &operator=(const SerialDlg &someSerialDlg); + CallbackData::ReturnType initHandler(CallbackData &someCallbackData); + CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData); + CallbackData::ReturnType commandHandler(CallbackData &someCallbackData); + CallbackData::ReturnType closeHandler(CallbackData &someCallbackData); + CallbackData::ReturnType dlgCodeHandler(CallbackData &someCallbackData); + CallbackData::ReturnType controlColorHandler(CallbackData &someCallbackData); + CallbackData::ReturnType measureItemHandler(CallbackData &someCallbackData); + CommControl::Port getCommPort(void)const; + String getCommSettings(void)const; + bool applySerialSettings(void); + void initSerialSettings(void); + void initDataBits(void); + void initParity(void); + void initStopBits(void); + void initPorts(void); + void initBaud(void); + void reset(void); + + Callback mInitHandler; + Callback mDestroyHandler; + Callback mCommandHandler; + Callback mCloseHandler; + SmartPointer mStatusBar; +}; +#endif \ No newline at end of file diff --git a/aladin/splash.cpp b/aladin/splash.cpp new file mode 100644 index 0000000..7aae7d9 --- /dev/null +++ b/aladin/splash.cpp @@ -0,0 +1,176 @@ +#include +#include +#include +#include +#include +#include + +char SplashScreen::szClassName[]="SplashScreen"; + +SplashScreen::SplashScreen(const String &strBitmap,const String &strCaption,const String &strTitle,UINT timeout) +: mBitmapName(strBitmap), mStrCaption(strCaption), mStrTitle(strTitle), mTimeout(timeout), + mTextFont("Helv",8,Font::PitchVariable|Font::FamilySwiss,Font::WeightBold) +{ + mResBitmap=new ResBitmap(mBitmapName); + mResBitmap.disposition(PointerDisposition::Delete); + mCreateHandler.setCallback(this,&SplashScreen::createHandler); + mPaintHandler.setCallback(this,&SplashScreen::paintHandler); + mDestroyHandler.setCallback(this,&SplashScreen::destroyHandler); + mPaletteChangedHandler.setCallback(this,&SplashScreen::paletteChangedHandler); + mSetFocusHandler.setCallback(this,&SplashScreen::setFocusHandler); + mLeftButtonHandler.setCallback(this,&SplashScreen::leftButtonHandler); + mTimerHandler.setCallback(this,&SplashScreen::timerHandler); + insertHandler(VectorHandler::CreateHandler,&mCreateHandler); + insertHandler(VectorHandler::PaintHandler,&mPaintHandler); + insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + insertHandler(VectorHandler::PaletteChangedHandler,&mPaletteChangedHandler); + insertHandler(VectorHandler::SetFocusHandler,&mSetFocusHandler); + insertHandler(VectorHandler::TimerHandler,&mTimerHandler); + insertHandler(VectorHandler::LeftButtonUpHandler,&mLeftButtonHandler); + registerClass(); +} + +SplashScreen::SplashScreen(const SplashScreen &someSplashScreen) +{ // private implementation +} + +SplashScreen::~SplashScreen() +{ + removeHandler(VectorHandler::CreateHandler,&mCreateHandler); + removeHandler(VectorHandler::PaintHandler,&mPaintHandler); + removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler); + removeHandler(VectorHandler::PaletteChangedHandler,&mPaletteChangedHandler); + removeHandler(VectorHandler::SetFocusHandler,&mSetFocusHandler); + removeHandler(VectorHandler::TimerHandler,&mTimerHandler); + removeHandler(VectorHandler::LeftButtonUpHandler,&mLeftButtonHandler); +} + +void SplashScreen::registerClass(void) +{ + HINSTANCE hInstance(processInstance()); + WNDCLASS wndClass; + + if(::GetClassInfo(hInstance,szClassName,(WNDCLASS FAR*)&wndClass))return; + wndClass.style =CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS|CS_OWNDC; + wndClass.lpfnWndProc =(WNDPROC)Window::WndProc; + wndClass.cbClsExtra =0; + wndClass.cbWndExtra =sizeof(SplashScreen*); + wndClass.hInstance =hInstance; + wndClass.hIcon =::LoadIcon(NULL,IDI_APPLICATION); + wndClass.hCursor =::LoadCursor(NULL,IDC_ARROW); + wndClass.hbrBackground =(HBRUSH)::GetStockObject(NULL_BRUSH); + wndClass.lpszMenuName =0; + wndClass.lpszClassName =szClassName; + ::RegisterClass(&wndClass); + assert(0!=::GetClassInfo(hInstance,szClassName,(WNDCLASS FAR*)&wndClass)); +} + +SplashScreen &SplashScreen::operator=(const SplashScreen &someSplashScreen) +{ // private implementation + return *this; +} + +BOOL SplashScreen::perform(Rect initRect) +{ + UINT style(0); + if(CW_USEDEFAULT==initRect.right())initRect.right(mResBitmap->width()); + if(CW_USEDEFAULT==initRect.bottom())initRect.bottom(mResBitmap->height()); + if(timeout()) + { + PureDevice pureDevice; + pureDevice.screenDevice(); + initRect.left((pureDevice.horizontalResolution()-mResBitmap->width())/2); + initRect.top((pureDevice.verticalResolution()-mResBitmap->height())/2); + style=WS_POPUP|WS_CLIPSIBLINGS|0x04|WS_DLGFRAME; + } + else style=WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_BORDER|WS_DLGFRAME|0x04|WS_CLIPSIBLINGS; + createWindow(WS_EX_CONTROLPARENT,szClassName,timeout()?(char*)0:(char*)"Splash",style,initRect,NULL,NULL,processInstance(),(LPSTR)this); // WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_BORDER|WS_DLGFRAME|0x04|WS_CLIPSIBLINGS + show(SW_SHOW); + update(); + return messageLoop(); +} + +CallbackData::ReturnType SplashScreen::leftButtonHandler(CallbackData &someCallbackData) +{ + killTimer(TimerID); + postMessage(*this,WM_CLOSE,0,0L); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SplashScreen::destroyHandler(CallbackData &someCallbackData) +{ + PureDevice pureDevice(*this); + ((PurePalette&)*mDIBitmap).usePalette(pureDevice,FALSE); + postQuitMessage(onDestroy()); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SplashScreen::createHandler(CallbackData &someCallbackData) +{ + mPureDevice=new PureDevice(*this); + mPureDevice.disposition(PointerDisposition::Delete); + mDIBitmap=new DIB24(); + mDIBitmap.disposition(PointerDisposition::Delete); + mDIBitmap->create(mResBitmap->width(),mResBitmap->height(),*mPureDevice); + mDIBitmap->copyBits(*mResBitmap); + if(timeout())setTimer(TimerID,timeout()); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SplashScreen::timerHandler(CallbackData &someCallbackData) +{ + killTimer(TimerID); + postMessage(*this,WM_CLOSE,0,0L); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SplashScreen::paletteChangedHandler(CallbackData &someCallbackData) +{ + if(!mDIBitmap.isOkay()||((HWND)*this==(HWND)someCallbackData.wParam()))return (CallbackData::ReturnType)FALSE; + PureDevice pureDevice(*this); + ((PurePalette&)*mDIBitmap).usePalette(pureDevice,TRUE); + update(); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SplashScreen::setFocusHandler(CallbackData &/*someCallbackData*/) +{ + if(!mDIBitmap.isOkay())return (CallbackData::ReturnType)FALSE; + PureDevice pureDevice(*this); + ((PurePalette&)*mDIBitmap).usePalette(pureDevice,TRUE); + return (CallbackData::ReturnType)FALSE; +} + +CallbackData::ReturnType SplashScreen::paintHandler(CallbackData &someCallbackData) +{ + if(!mResBitmap.isOkay())return (CallbackData::ReturnType)FALSE; + PaintInformation *pPaintInfo=(PaintInformation*)someCallbackData.lParam(); + PureDevice &pureDevice=(PureDevice&)*pPaintInfo; + mDIBitmap->bitBlt(pureDevice,Rect(0,0,width(),height()),Point()); + pureDevice.select((GDIObj)mTextFont,TRUE); + pureDevice.setTextColor(RGBColor(247,231,33)); + pureDevice.setBkMode(PureDevice::Transparent); + pureDevice.textOut(5,200,mStrCaption); + ProductInfo prodInfo; + pureDevice.setTextColor(RGBColor(255,255,255)); + pureDevice.textOut(1,250,prodInfo.strProductName()+String(" ")+prodInfo.strVersion()); + pureDevice.textOut(1,265,prodInfo.strRegisteredOwner()); + pureDevice.textOut(1,280,String("OEM:")+prodInfo.strProductID()); + if(!mStrTitle.isNull()) + { + Font mFont("Helv",12,Font::PitchVariable|Font::FamilySwiss,Font::WeightBold); + pureDevice.select((GDIObj)mFont,TRUE); + pureDevice.setTextColor(RGBColor(255,255,255)); + pureDevice.textOut(12,10,mStrTitle); + pureDevice.select((GDIObj)mFont,FALSE); + } + return (CallbackData::ReturnType)FALSE; +} + +// virtuals +int SplashScreen::onDestroy(void) +{ + return 0; +} + + diff --git a/aladin/splash.hpp b/aladin/splash.hpp new file mode 100644 index 0000000..3d3c473 --- /dev/null +++ b/aladin/splash.hpp @@ -0,0 +1,69 @@ +#ifndef _ALADIN_SPLASHSCREEN_HPP_ +#define _ALADIN_SPLASHSCREEN_HPP_ +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_WINDOW_HPP_ +#include +#endif +#ifndef _COMMON_RECTANGLE_HPP_ +#include +#endif +#ifndef _COMMON_FONT_HPP_ +#include +#endif + +class ResBitmap; +class DIB24; + +class SplashScreen : public Window +{ +public: + enum{TimeOut=5000}; + SplashScreen(const String &strBitmap,const String &strCaption,const String &strTitle,UINT timeout=TimeOut); + virtual ~SplashScreen(); + BOOL perform(Rect initRect=Rect(CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT)); +protected: + virtual int onDestroy(void); +private: + enum {TimerID=0}; + SplashScreen(const SplashScreen &someSplashScreen); + SplashScreen &operator=(const SplashScreen &someSplashScreen); + CallbackData::ReturnType createHandler(CallbackData &someCallbackData); + CallbackData::ReturnType paintHandler(CallbackData &someCallbackData); + CallbackData::ReturnType destroyHandler(CallbackData &someCallbackData); + CallbackData::ReturnType paletteChangedHandler(CallbackData &someCallbackData); + CallbackData::ReturnType setFocusHandler(CallbackData &someCallbackData); + CallbackData::ReturnType timerHandler(CallbackData &someCallbackData); + CallbackData::ReturnType leftButtonHandler(CallbackData &someCallbackData); + void registerClass(void); + UINT timeout(void)const; + + Callback mPaintHandler; + Callback mCreateHandler; + Callback mDestroyHandler; + Callback mPaletteChangedHandler; + Callback mSetFocusHandler; + Callback mTimerHandler; + Callback mLeftButtonHandler; + + SmartPointer mResBitmap; + SmartPointer mDIBitmap; + SmartPointer mPureDevice; + String mBitmapName; + String mStrCaption; + String mStrTitle; + UINT mTimeout; + Font mTextFont; + static char szClassName[]; +}; + +inline +UINT SplashScreen::timeout(void)const +{ + return mTimeout; +} +#endif \ No newline at end of file diff --git a/aladin/status.cpp b/aladin/status.cpp new file mode 100644 index 0000000..c1eade2 --- /dev/null +++ b/aladin/status.cpp @@ -0,0 +1,105 @@ +#include +#include + +CurrentStatus::CurrentStatus() +{ + mRemainingBattery=0; + mBattery=0; + mTotalDivesLow=0; + mTotalDivesHigh=0; + mOffsetNewestLog=0; + mDiveProfiles=0; + mEndOfProfileRingBufferLow=0; + mEndOfProfileRingBufferHigh=0; + mDataAquisitionTime1=0; + mDataAquisitionTime2=0; + mDataAquisitionTime3=0; + mDataAquisitionTime4=0; + mCheckSumLow=0; + mCheckSumHigh=0; +} + +CurrentStatus::~CurrentStatus() +{ +} + +String CurrentStatus::toString(void)const +{ + String str; + str+=String("Battery:")+String().fromDouble(getRemainingBattery())+String(" "); + str+=String("Battery:")+String().fromBool(getBattery())+String(" "); + str+=String("TotalDives:")+String().fromInt(getTotalDives())+String(" "); + str+=String("NewestLog:")+String().fromInt(getOffsetNewestLog())+String(" "); + str+=String("OffsetLog:")+String().fromInt(getOffsetLog())+String(" "); + str+=String("DiveProfiles:")+String().fromInt(getDiveProfiles())+String(" "); + str+=String("OffsetLog:")+String().fromInt(getEndOfProfileRingBuffer())+String(" "); + str+=String("AcquisitionTime:")+String().fromInt(getAcquisitionTime())+String(" "); + return str; +} + +bool CurrentStatus::readFrom(RawData &array) +{ + try + { + mRemainingBattery=array[0x7F0]; + mBattery=array[0x7F1]; + mTotalDivesLow=array[0x7F2]; + mTotalDivesHigh=array[0x7F3]; + mOffsetNewestLog=array[0x7F4]; + mDiveProfiles=array[0x7F5]; + mEndOfProfileRingBufferLow=array[0x7F6]; + mEndOfProfileRingBufferHigh=array[0x7F7]; + mDataAquisitionTime1=array[0x7F8]; + mDataAquisitionTime2=array[0x7F9]; + mDataAquisitionTime3=array[0x7FA]; + mDataAquisitionTime4=array[0x7FB]; + mCheckSumLow=array[0x7FC]; + mCheckSumHigh=array[0x7FD]; + } + catch(ArrayIndexOutOfBoundsException exception) + { + ::OutputDebugString(exception.toString()+String("\n")); + return false; + } + return true; +} + +bool CurrentStatus::readFrom(File &inFile) +{ + if(!inFile.isOkay())return false; + if(!inFile.read(&mRemainingBattery,sizeof(mRemainingBattery)))return false; + if(!inFile.read(&mBattery,sizeof(mBattery)))return false; + if(!inFile.read(&mTotalDivesLow,sizeof(mTotalDivesLow)))return false; + if(!inFile.read(&mTotalDivesHigh,sizeof(mTotalDivesHigh)))return false; + if(!inFile.read(&mOffsetNewestLog,sizeof(mOffsetNewestLog)))return false; + if(!inFile.read(&mDiveProfiles,sizeof(mDiveProfiles)))return false; + if(!inFile.read(&mEndOfProfileRingBufferLow,sizeof(mEndOfProfileRingBufferLow)))return false; + if(!inFile.read(&mEndOfProfileRingBufferHigh,sizeof(mEndOfProfileRingBufferHigh)))return false; + if(!inFile.read(&mDataAquisitionTime1,sizeof(mDataAquisitionTime1)))return false; + if(!inFile.read(&mDataAquisitionTime2,sizeof(mDataAquisitionTime2)))return false; + if(!inFile.read(&mDataAquisitionTime3,sizeof(mDataAquisitionTime3)))return false; + if(!inFile.read(&mDataAquisitionTime4,sizeof(mDataAquisitionTime4)))return false; + if(!inFile.read(&mCheckSumLow,sizeof(mCheckSumLow)))return false; + if(!inFile.read(&mCheckSumHigh,sizeof(mCheckSumHigh)))return false; + return true; +} + +bool CurrentStatus::writeTo(File &outFile) +{ + if(!outFile.isOkay())return false; + if(!outFile.write(&mRemainingBattery,sizeof(mRemainingBattery)))return false; + if(!outFile.write(&mBattery,sizeof(mBattery)))return false; + if(!outFile.write(&mTotalDivesLow,sizeof(mTotalDivesLow)))return false; + if(!outFile.write(&mTotalDivesHigh,sizeof(mTotalDivesHigh)))return false; + if(!outFile.write(&mOffsetNewestLog,sizeof(mOffsetNewestLog)))return false; + if(!outFile.write(&mDiveProfiles,sizeof(mDiveProfiles)))return false; + if(!outFile.write(&mEndOfProfileRingBufferLow,sizeof(mEndOfProfileRingBufferLow)))return false; + if(!outFile.write(&mEndOfProfileRingBufferHigh,sizeof(mEndOfProfileRingBufferHigh)))return false; + if(!outFile.write(&mDataAquisitionTime1,sizeof(mDataAquisitionTime1)))return false; + if(!outFile.write(&mDataAquisitionTime2,sizeof(mDataAquisitionTime2)))return false; + if(!outFile.write(&mDataAquisitionTime3,sizeof(mDataAquisitionTime3)))return false; + if(!outFile.write(&mDataAquisitionTime4,sizeof(mDataAquisitionTime4)))return false; + if(!outFile.write(&mCheckSumLow,sizeof(mCheckSumLow)))return false; + if(!outFile.write(&mCheckSumHigh,sizeof(mCheckSumHigh)))return false; + return true; +} diff --git a/aladin/status.hpp b/aladin/status.hpp new file mode 100644 index 0000000..39e7d0b --- /dev/null +++ b/aladin/status.hpp @@ -0,0 +1,99 @@ +#ifndef _ALADIN_STATUS_HPP_ +#define _ALADIN_STATUS_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_ARRAY_HPP_ +#include +#endif +#ifndef _COMMON_MATH_HPP_ +#include +#endif +#ifndef _ALADIN_RAWDATA_HPP_ +#include +#endif + +class File; + +class CurrentStatus +{ +public: + CurrentStatus(); + virtual ~CurrentStatus(); + double getRemainingBattery(void)const; + bool getBattery(void)const; + WORD getTotalDives(void)const; + WORD getOffsetNewestLog(void)const; + WORD getOffsetLog(void)const; + BYTE getDiveProfiles(void)const; + WORD getEndOfProfileRingBuffer(void)const; + DWORD getAcquisitionTime(void)const; + bool readFrom(RawData &array); + bool readFrom(File &inFile); + bool writeTo(File &outFile); + String toString(void)const; +private: + BYTE mRemainingBattery; + BYTE mBattery; + BYTE mTotalDivesLow; + BYTE mTotalDivesHigh; + BYTE mOffsetNewestLog; + BYTE mDiveProfiles; + BYTE mEndOfProfileRingBufferLow; + BYTE mEndOfProfileRingBufferHigh; + BYTE mDataAquisitionTime1; + BYTE mDataAquisitionTime2; + BYTE mDataAquisitionTime3; + BYTE mDataAquisitionTime4; + BYTE mCheckSumLow; + BYTE mCheckSumHigh; +}; + +inline +double CurrentStatus::getRemainingBattery(void)const +{ + return (mRemainingBattery*100.00)/256.00; +} + +inline +bool CurrentStatus::getBattery(void)const +{ + return mBattery&0xF0; +} + +inline +WORD CurrentStatus::getTotalDives(void)const +{ + return (mTotalDivesLow*256)+mTotalDivesHigh; +} + +inline +WORD CurrentStatus::getOffsetNewestLog(void)const +{ + return ((((WORD)mOffsetNewestLog+36)%37)*12)+0x600; +} + +inline +WORD CurrentStatus::getOffsetLog(void)const +{ + return 0x604; +} + +inline +BYTE CurrentStatus::getDiveProfiles(void)const +{ + return mDiveProfiles; +} + +inline +WORD CurrentStatus::getEndOfProfileRingBuffer(void)const +{ + return (mEndOfProfileRingBufferLow+(mEndOfProfileRingBufferHigh>>1)*256)&0x7FF; +} + +inline +DWORD CurrentStatus::getAcquisitionTime(void)const +{ + return (double)mDataAquisitionTime1*Math::power(2,24)+(double)mDataAquisitionTime2*Math::power(2,16)+(double)mDataAquisitionTime3*Math::power(2,8)+(double)mDataAquisitionTime4; +} +#endif \ No newline at end of file diff --git a/aladin/time.hpp b/aladin/time.hpp new file mode 100644 index 0000000..bb7efd9 --- /dev/null +++ b/aladin/time.hpp @@ -0,0 +1,72 @@ +#ifndef _ALADIN_TIME_HPP_ +#define _ALADIN_TIME_HPP_ +#ifndef _COMMON_STRING_HPP_ +#include +#endif + +class Time +{ +public: + Time(); + Time(int hours,int minutes); + virtual ~Time(); + int getHours(void)const; + void setHours(int hours); + int getMinutes(void)const; + void setMinutes(int minutes); + String toString(void)const; +private: + int mHours; + int mMinutes; +}; + +inline +Time::Time() +: mHours(0), mMinutes(0) +{ +} + +inline +Time::Time(int hours,int minutes) +: mHours(hours), mMinutes(minutes) +{ +} + +inline +Time::~Time() +{ +} + +inline +int Time::getHours(void)const +{ + return mHours; +} + +inline +void Time::setHours(int hours) +{ + mHours=hours; +} + +inline +int Time::getMinutes(void)const +{ + return mMinutes; +} + +inline +void Time::setMinutes(int minutes) +{ + mMinutes=minutes; +} + +inline +String Time::toString(void)const +{ + String str; + + ::sprintf(str,"%02d:%02d",mHours,mMinutes); + return str; +} +#endif diff --git a/analytic/ANALYTIC.001 b/analytic/ANALYTIC.001 new file mode 100644 index 0000000..9e65523 --- /dev/null +++ b/analytic/ANALYTIC.001 @@ -0,0 +1,391 @@ +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +!IF "$(CFG)" == "" +CFG=analytic - Win32 Debug +!MESSAGE No configuration specified. Defaulting to analytic - Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "analytic - Win32 Release" && "$(CFG)" !=\ + "analytic - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE on this makefile +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "analytic.mak" CFG="analytic - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "analytic - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "analytic - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF +################################################################################ +# Begin Project +# PROP Target_Last_Scanned "analytic - Win32 Debug" +CPP=cl.exe + +!IF "$(CFG)" == "analytic - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +OUTDIR=.\Release +INTDIR=.\Release + +ALL : "$(OUTDIR)\analytic.lib" + +CLEAN : + -@erase "$(INTDIR)\Bond.obj" + -@erase "$(INTDIR)\Catmull.obj" + -@erase "$(INTDIR)\Coupon.obj" + -@erase "$(INTDIR)\Instrmnt.obj" + -@erase "$(INTDIR)\Money.obj" + -@erase "$(INTDIR)\Pairs.obj" + -@erase "$(INTDIR)\portflio.obj" + -@erase "$(INTDIR)\Zbond.obj" + -@erase "$(OUTDIR)\analytic.lib" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\ + /Fp"$(INTDIR)/analytic.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\Release/ +CPP_SBRS=.\. +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/analytic.bsc" +BSC32_SBRS= \ + +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +LIB32_FLAGS=/nologo /out:"$(OUTDIR)/analytic.lib" +LIB32_OBJS= \ + "$(INTDIR)\Bond.obj" \ + "$(INTDIR)\Catmull.obj" \ + "$(INTDIR)\Coupon.obj" \ + "$(INTDIR)\Instrmnt.obj" \ + "$(INTDIR)\Money.obj" \ + "$(INTDIR)\Pairs.obj" \ + "$(INTDIR)\portflio.obj" \ + "$(INTDIR)\Zbond.obj" + +"$(OUTDIR)\analytic.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) + $(LIB32) @<< + $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) +<< + +!ELSEIF "$(CFG)" == "analytic - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "msvcobj" +# PROP Intermediate_Dir "msvcobj" +# PROP Target_Dir "" +OUTDIR=.\msvcobj +INTDIR=.\msvcobj + +ALL : "..\exe\analytic.lib" + +CLEAN : + -@erase "$(INTDIR)\Bond.obj" + -@erase "$(INTDIR)\Catmull.obj" + -@erase "$(INTDIR)\Coupon.obj" + -@erase "$(INTDIR)\Instrmnt.obj" + -@erase "$(INTDIR)\Money.obj" + -@erase "$(INTDIR)\Pairs.obj" + -@erase "$(INTDIR)\portflio.obj" + -@erase "$(INTDIR)\Zbond.obj" + -@erase "..\exe\analytic.lib" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /GX /Z7 /O2 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "STRICT" /D "__FLAT__" /YX /c +CPP_PROJ=/nologo /MLd /GX /Z7 /O2 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\ + "STRICT" /D "__FLAT__" /Fp"$(INTDIR)/analytic.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\msvcobj/ +CPP_SBRS=.\. +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/analytic.bsc" +BSC32_SBRS= \ + +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\exe\analytic.lib" +LIB32_FLAGS=/nologo /out:"..\exe\analytic.lib" +LIB32_OBJS= \ + "$(INTDIR)\Bond.obj" \ + "$(INTDIR)\Catmull.obj" \ + "$(INTDIR)\Coupon.obj" \ + "$(INTDIR)\Instrmnt.obj" \ + "$(INTDIR)\Money.obj" \ + "$(INTDIR)\Pairs.obj" \ + "$(INTDIR)\portflio.obj" \ + "$(INTDIR)\Zbond.obj" + +"..\exe\analytic.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) + $(LIB32) @<< + $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) +<< + +!ENDIF + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +################################################################################ +# Begin Target + +# Name "analytic - Win32 Release" +# Name "analytic - Win32 Debug" + +!IF "$(CFG)" == "analytic - Win32 Release" + +!ELSEIF "$(CFG)" == "analytic - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE=.\Zbond.cpp + +!IF "$(CFG)" == "analytic - Win32 Release" + +DEP_CPP_ZBOND=\ + {$(INCLUDE)}"\.\bond.hpp"\ + {$(INCLUDE)}"\.\coupon.hpp"\ + {$(INCLUDE)}"\.\freq.hpp"\ + {$(INCLUDE)}"\.\instrmnt.hpp"\ + {$(INCLUDE)}"\.\rate.hpp"\ + {$(INCLUDE)}"\.\zbond.hpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\gdata.tpp"\ + {$(INCLUDE)}"\common\math.hpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Zbond.obj" : $(SOURCE) $(DEP_CPP_ZBOND) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "analytic - Win32 Debug" + +DEP_CPP_ZBOND=\ + {$(INCLUDE)}"\.\bond.hpp"\ + {$(INCLUDE)}"\.\zbond.hpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\math.hpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Zbond.obj" : $(SOURCE) $(DEP_CPP_ZBOND) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Catmull.cpp +DEP_CPP_CATMU=\ + {$(INCLUDE)}"\.\catmull.hpp"\ + {$(INCLUDE)}"\.\pairs.hpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\gdata.tpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Catmull.obj" : $(SOURCE) $(DEP_CPP_CATMU) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Coupon.cpp +DEP_CPP_COUPO=\ + {$(INCLUDE)}"\.\coupon.hpp"\ + {$(INCLUDE)}"\.\freq.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Coupon.obj" : $(SOURCE) $(DEP_CPP_COUPO) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Instrmnt.cpp +DEP_CPP_INSTR=\ + {$(INCLUDE)}"\.\coupon.hpp"\ + {$(INCLUDE)}"\.\freq.hpp"\ + {$(INCLUDE)}"\.\instrmnt.hpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\gdata.tpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Instrmnt.obj" : $(SOURCE) $(DEP_CPP_INSTR) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Money.cpp +DEP_CPP_MONEY=\ + {$(INCLUDE)}"\.\money.hpp"\ + {$(INCLUDE)}"\common\stdio.hpp"\ + {$(INCLUDE)}"\common\stdlib.hpp"\ + {$(INCLUDE)}"\common\string.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Money.obj" : $(SOURCE) $(DEP_CPP_MONEY) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Pairs.cpp +DEP_CPP_PAIRS=\ + {$(INCLUDE)}"\.\pairs.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Pairs.obj" : $(SOURCE) $(DEP_CPP_PAIRS) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Bond.cpp + +!IF "$(CFG)" == "analytic - Win32 Release" + +DEP_CPP_BOND_=\ + {$(INCLUDE)}"\.\bond.hpp"\ + {$(INCLUDE)}"\.\coupon.hpp"\ + {$(INCLUDE)}"\.\freq.hpp"\ + {$(INCLUDE)}"\.\instrmnt.hpp"\ + {$(INCLUDE)}"\.\rate.hpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\gdata.tpp"\ + {$(INCLUDE)}"\common\math.hpp"\ + {$(INCLUDE)}"\common\stdio.hpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Bond.obj" : $(SOURCE) $(DEP_CPP_BOND_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "analytic - Win32 Debug" + +DEP_CPP_BOND_=\ + {$(INCLUDE)}"\.\bond.hpp"\ + {$(INCLUDE)}"\.\coupon.hpp"\ + {$(INCLUDE)}"\.\freq.hpp"\ + {$(INCLUDE)}"\.\rate.hpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\gdata.tpp"\ + {$(INCLUDE)}"\common\math.hpp"\ + {$(INCLUDE)}"\common\stdio.hpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Bond.obj" : $(SOURCE) $(DEP_CPP_BOND_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\portflio.cpp +DEP_CPP_PORTF=\ + {$(INCLUDE)}"\.\coupon.hpp"\ + {$(INCLUDE)}"\.\freq.hpp"\ + {$(INCLUDE)}"\.\instrmnt.hpp"\ + {$(INCLUDE)}"\.\portflio.hpp"\ + {$(INCLUDE)}"\.\rate.hpp"\ + {$(INCLUDE)}"\common\block.hpp"\ + {$(INCLUDE)}"\common\block.tpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\gdata.tpp"\ + {$(INCLUDE)}"\common\math.hpp"\ + {$(INCLUDE)}"\common\pointer.hpp"\ + {$(INCLUDE)}"\common\stdio.hpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\portflio.obj" : $(SOURCE) $(DEP_CPP_PORTF) "$(INTDIR)" + + +# End Source File +# End Target +# End Project +################################################################################ diff --git a/analytic/ANALYTIC.DSP b/analytic/ANALYTIC.DSP new file mode 100644 index 0000000..f42acd2 --- /dev/null +++ b/analytic/ANALYTIC.DSP @@ -0,0 +1,168 @@ +# Microsoft Developer Studio Project File - Name="analytic" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=analytic - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "ANALYTIC.MAK". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "ANALYTIC.MAK" CFG="analytic - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "analytic - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "analytic - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "analytic - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir ".\Release" +# PROP BASE Intermediate_Dir ".\Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir ".\Release" +# PROP Intermediate_Dir ".\Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo + +!ELSEIF "$(CFG)" == "analytic - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir ".\Debug" +# PROP BASE Intermediate_Dir ".\Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir ".\msvcobj" +# PROP Intermediate_Dir ".\msvcobj" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /Gz /MTd /GX /Zi /O2 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "STRICT" /D "__FLAT__" /YX /FD /c +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\exe\analytic.lib" + +!ENDIF + +# Begin Target + +# Name "analytic - Win32 Release" +# Name "analytic - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90" +# Begin Source File + +SOURCE=.\Bond.cpp +# End Source File +# Begin Source File + +SOURCE=.\Catmull.cpp +# End Source File +# Begin Source File + +SOURCE=.\Coupon.cpp +# End Source File +# Begin Source File + +SOURCE=.\Instrmnt.cpp +# End Source File +# Begin Source File + +SOURCE=.\Money.cpp +# End Source File +# Begin Source File + +SOURCE=.\Pairs.cpp +# End Source File +# Begin Source File + +SOURCE=.\portflio.cpp +# End Source File +# Begin Source File + +SOURCE=.\Zbond.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" +# Begin Source File + +SOURCE=.\bond.hpp +# End Source File +# Begin Source File + +SOURCE=.\catmull.hpp +# End Source File +# Begin Source File + +SOURCE=.\coupon.hpp +# End Source File +# Begin Source File + +SOURCE=.\freq.hpp +# End Source File +# Begin Source File + +SOURCE=.\instrmnt.hpp +# End Source File +# Begin Source File + +SOURCE=.\money.hpp +# End Source File +# Begin Source File + +SOURCE=.\pairs.hpp +# End Source File +# Begin Source File + +SOURCE=.\portflio.hpp +# End Source File +# Begin Source File + +SOURCE=.\rate.hpp +# End Source File +# Begin Source File + +SOURCE=.\zbond.hpp +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/analytic/ANALYTIC.DSW b/analytic/ANALYTIC.DSW new file mode 100644 index 0000000..926d290 --- /dev/null +++ b/analytic/ANALYTIC.DSW @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "analytic"=.\ANALYTIC.DSP - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/analytic/ANALYTIC.MAK b/analytic/ANALYTIC.MAK new file mode 100644 index 0000000..9e65523 --- /dev/null +++ b/analytic/ANALYTIC.MAK @@ -0,0 +1,391 @@ +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +!IF "$(CFG)" == "" +CFG=analytic - Win32 Debug +!MESSAGE No configuration specified. Defaulting to analytic - Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "analytic - Win32 Release" && "$(CFG)" !=\ + "analytic - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE on this makefile +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "analytic.mak" CFG="analytic - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "analytic - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "analytic - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF +################################################################################ +# Begin Project +# PROP Target_Last_Scanned "analytic - Win32 Debug" +CPP=cl.exe + +!IF "$(CFG)" == "analytic - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +OUTDIR=.\Release +INTDIR=.\Release + +ALL : "$(OUTDIR)\analytic.lib" + +CLEAN : + -@erase "$(INTDIR)\Bond.obj" + -@erase "$(INTDIR)\Catmull.obj" + -@erase "$(INTDIR)\Coupon.obj" + -@erase "$(INTDIR)\Instrmnt.obj" + -@erase "$(INTDIR)\Money.obj" + -@erase "$(INTDIR)\Pairs.obj" + -@erase "$(INTDIR)\portflio.obj" + -@erase "$(INTDIR)\Zbond.obj" + -@erase "$(OUTDIR)\analytic.lib" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\ + /Fp"$(INTDIR)/analytic.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\Release/ +CPP_SBRS=.\. +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/analytic.bsc" +BSC32_SBRS= \ + +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo +LIB32_FLAGS=/nologo /out:"$(OUTDIR)/analytic.lib" +LIB32_OBJS= \ + "$(INTDIR)\Bond.obj" \ + "$(INTDIR)\Catmull.obj" \ + "$(INTDIR)\Coupon.obj" \ + "$(INTDIR)\Instrmnt.obj" \ + "$(INTDIR)\Money.obj" \ + "$(INTDIR)\Pairs.obj" \ + "$(INTDIR)\portflio.obj" \ + "$(INTDIR)\Zbond.obj" + +"$(OUTDIR)\analytic.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) + $(LIB32) @<< + $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) +<< + +!ELSEIF "$(CFG)" == "analytic - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "msvcobj" +# PROP Intermediate_Dir "msvcobj" +# PROP Target_Dir "" +OUTDIR=.\msvcobj +INTDIR=.\msvcobj + +ALL : "..\exe\analytic.lib" + +CLEAN : + -@erase "$(INTDIR)\Bond.obj" + -@erase "$(INTDIR)\Catmull.obj" + -@erase "$(INTDIR)\Coupon.obj" + -@erase "$(INTDIR)\Instrmnt.obj" + -@erase "$(INTDIR)\Money.obj" + -@erase "$(INTDIR)\Pairs.obj" + -@erase "$(INTDIR)\portflio.obj" + -@erase "$(INTDIR)\Zbond.obj" + -@erase "..\exe\analytic.lib" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /GX /Z7 /O2 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "STRICT" /D "__FLAT__" /YX /c +CPP_PROJ=/nologo /MLd /GX /Z7 /O2 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D\ + "STRICT" /D "__FLAT__" /Fp"$(INTDIR)/analytic.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\msvcobj/ +CPP_SBRS=.\. +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/analytic.bsc" +BSC32_SBRS= \ + +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\exe\analytic.lib" +LIB32_FLAGS=/nologo /out:"..\exe\analytic.lib" +LIB32_OBJS= \ + "$(INTDIR)\Bond.obj" \ + "$(INTDIR)\Catmull.obj" \ + "$(INTDIR)\Coupon.obj" \ + "$(INTDIR)\Instrmnt.obj" \ + "$(INTDIR)\Money.obj" \ + "$(INTDIR)\Pairs.obj" \ + "$(INTDIR)\portflio.obj" \ + "$(INTDIR)\Zbond.obj" + +"..\exe\analytic.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) + $(LIB32) @<< + $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) +<< + +!ENDIF + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +################################################################################ +# Begin Target + +# Name "analytic - Win32 Release" +# Name "analytic - Win32 Debug" + +!IF "$(CFG)" == "analytic - Win32 Release" + +!ELSEIF "$(CFG)" == "analytic - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE=.\Zbond.cpp + +!IF "$(CFG)" == "analytic - Win32 Release" + +DEP_CPP_ZBOND=\ + {$(INCLUDE)}"\.\bond.hpp"\ + {$(INCLUDE)}"\.\coupon.hpp"\ + {$(INCLUDE)}"\.\freq.hpp"\ + {$(INCLUDE)}"\.\instrmnt.hpp"\ + {$(INCLUDE)}"\.\rate.hpp"\ + {$(INCLUDE)}"\.\zbond.hpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\gdata.tpp"\ + {$(INCLUDE)}"\common\math.hpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Zbond.obj" : $(SOURCE) $(DEP_CPP_ZBOND) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "analytic - Win32 Debug" + +DEP_CPP_ZBOND=\ + {$(INCLUDE)}"\.\bond.hpp"\ + {$(INCLUDE)}"\.\zbond.hpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\math.hpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Zbond.obj" : $(SOURCE) $(DEP_CPP_ZBOND) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Catmull.cpp +DEP_CPP_CATMU=\ + {$(INCLUDE)}"\.\catmull.hpp"\ + {$(INCLUDE)}"\.\pairs.hpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\gdata.tpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Catmull.obj" : $(SOURCE) $(DEP_CPP_CATMU) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Coupon.cpp +DEP_CPP_COUPO=\ + {$(INCLUDE)}"\.\coupon.hpp"\ + {$(INCLUDE)}"\.\freq.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Coupon.obj" : $(SOURCE) $(DEP_CPP_COUPO) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Instrmnt.cpp +DEP_CPP_INSTR=\ + {$(INCLUDE)}"\.\coupon.hpp"\ + {$(INCLUDE)}"\.\freq.hpp"\ + {$(INCLUDE)}"\.\instrmnt.hpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\gdata.tpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Instrmnt.obj" : $(SOURCE) $(DEP_CPP_INSTR) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Money.cpp +DEP_CPP_MONEY=\ + {$(INCLUDE)}"\.\money.hpp"\ + {$(INCLUDE)}"\common\stdio.hpp"\ + {$(INCLUDE)}"\common\stdlib.hpp"\ + {$(INCLUDE)}"\common\string.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Money.obj" : $(SOURCE) $(DEP_CPP_MONEY) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Pairs.cpp +DEP_CPP_PAIRS=\ + {$(INCLUDE)}"\.\pairs.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Pairs.obj" : $(SOURCE) $(DEP_CPP_PAIRS) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Bond.cpp + +!IF "$(CFG)" == "analytic - Win32 Release" + +DEP_CPP_BOND_=\ + {$(INCLUDE)}"\.\bond.hpp"\ + {$(INCLUDE)}"\.\coupon.hpp"\ + {$(INCLUDE)}"\.\freq.hpp"\ + {$(INCLUDE)}"\.\instrmnt.hpp"\ + {$(INCLUDE)}"\.\rate.hpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\gdata.tpp"\ + {$(INCLUDE)}"\common\math.hpp"\ + {$(INCLUDE)}"\common\stdio.hpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Bond.obj" : $(SOURCE) $(DEP_CPP_BOND_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "analytic - Win32 Debug" + +DEP_CPP_BOND_=\ + {$(INCLUDE)}"\.\bond.hpp"\ + {$(INCLUDE)}"\.\coupon.hpp"\ + {$(INCLUDE)}"\.\freq.hpp"\ + {$(INCLUDE)}"\.\rate.hpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\gdata.tpp"\ + {$(INCLUDE)}"\common\math.hpp"\ + {$(INCLUDE)}"\common\stdio.hpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\Bond.obj" : $(SOURCE) $(DEP_CPP_BOND_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\portflio.cpp +DEP_CPP_PORTF=\ + {$(INCLUDE)}"\.\coupon.hpp"\ + {$(INCLUDE)}"\.\freq.hpp"\ + {$(INCLUDE)}"\.\instrmnt.hpp"\ + {$(INCLUDE)}"\.\portflio.hpp"\ + {$(INCLUDE)}"\.\rate.hpp"\ + {$(INCLUDE)}"\common\block.hpp"\ + {$(INCLUDE)}"\common\block.tpp"\ + {$(INCLUDE)}"\common\except.hpp"\ + {$(INCLUDE)}"\common\gdata.hpp"\ + {$(INCLUDE)}"\common\gdata.tpp"\ + {$(INCLUDE)}"\common\math.hpp"\ + {$(INCLUDE)}"\common\pointer.hpp"\ + {$(INCLUDE)}"\common\stdio.hpp"\ + {$(INCLUDE)}"\common\types.hpp"\ + {$(INCLUDE)}"\common\windows.hpp"\ + + +"$(INTDIR)\portflio.obj" : $(SOURCE) $(DEP_CPP_PORTF) "$(INTDIR)" + + +# End Source File +# End Target +# End Project +################################################################################ diff --git a/analytic/ANALYTIC.MDP b/analytic/ANALYTIC.MDP new file mode 100644 index 0000000..5502908 Binary files /dev/null and b/analytic/ANALYTIC.MDP differ diff --git a/analytic/ANALYTIC.OPT b/analytic/ANALYTIC.OPT new file mode 100644 index 0000000..5c11a15 Binary files /dev/null and b/analytic/ANALYTIC.OPT differ diff --git a/analytic/ANALYTIC.PLG b/analytic/ANALYTIC.PLG new file mode 100644 index 0000000..c4852bf --- /dev/null +++ b/analytic/ANALYTIC.PLG @@ -0,0 +1,41 @@ + + +
+

Build Log

+

+--------------------Configuration: analytic - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\sean\LOCALS~1\Temp\RSP17.tmp" with contents +[ +/nologo /MLd /GX /Z7 /O2 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "STRICT" /D "__FLAT__" /Fp".\msvcobj/ANALYTIC.pch" /YX /Fo".\msvcobj/" /Fd".\msvcobj/" /FD /c +"E:\work\analytic\Bond.cpp" +"E:\work\analytic\Catmull.cpp" +"E:\work\analytic\Coupon.cpp" +"E:\work\analytic\Instrmnt.cpp" +"E:\work\analytic\Money.cpp" +"E:\work\analytic\Pairs.cpp" +"E:\work\analytic\portflio.cpp" +"E:\work\analytic\Zbond.cpp" +] +Creating command line "cl.exe @C:\DOCUME~1\sean\LOCALS~1\Temp\RSP17.tmp" +Creating command line "link.exe -lib /nologo /out:"..\exe\analytic.lib" .\msvcobj\Bond.obj .\msvcobj\Catmull.obj .\msvcobj\Coupon.obj .\msvcobj\Instrmnt.obj .\msvcobj\Money.obj .\msvcobj\Pairs.obj .\msvcobj\portflio.obj .\msvcobj\Zbond.obj " +

Output Window

+Compiling... +Bond.cpp +Catmull.cpp +Coupon.cpp +Instrmnt.cpp +Money.cpp +Pairs.cpp +portflio.cpp +Zbond.cpp +Creating library... + + + +

Results

+analytic.lib - 0 error(s), 0 warning(s) +
+ + diff --git a/analytic/ANALYTIC.ncb b/analytic/ANALYTIC.ncb new file mode 100644 index 0000000..bf0a20f Binary files /dev/null and b/analytic/ANALYTIC.ncb differ diff --git a/analytic/BOND.CPP b/analytic/BOND.CPP new file mode 100644 index 0000000..0ddcd81 --- /dev/null +++ b/analytic/BOND.CPP @@ -0,0 +1,147 @@ +#include +#include +#include +#include +#include +#include + +Bond::Bond(void) +: Instrument(StraightBond), mPar(0.00), mYTM(0), mYield(0.00) +{ +} + +Bond::Bond(const Bond &bond) +{ + *this=bond; +} + +Bond::Bond(double par,const Coupon &coupon,int ytm,double price) +{ + Instrument::price(price); + Instrument::coupon(coupon); + Instrument::type(StraightBond); + Bond::par(par); + Bond::ytm(ytm); + Bond::yield(0.00); +} + +Bond::~Bond() +{ +} + +Bond &Bond::operator=(const Bond &bond) +{ + par(bond.par()); + ytm(bond.ytm()); + price(bond.price()); + coupon(bond.coupon()); + yield(bond.yield()); + type(StraightBond); + return *this; +} + +BOOL Bond::operator==(const Bond &bond)const +{ + return (par()==bond.par()&& + ytm()==bond.ytm()&& + price()==bond.price()&& + coupon()==bond.coupon()&& + yield()==bond.yield()&& + type()==bond.type()); +} + +double Bond::par(void)const +{ + return mPar; +} + +void Bond::par(double par) +{ + mPar=par; +} + +const Rate &Bond::yield(void)const +{ + return mYield; +} + +void Bond::yield(const Rate &yield) +{ + mYield=yield; +} + +int Bond::ytm(void)const +{ + return mYTM; +} + +void Bond::ytm(int ytm) +{ + mYTM=ytm; +} + +// virtuals + +BOOL Bond::cashflows(GlobalData &cashflows) +{ + double semiAnnualPmt; + int periods; + Coupon coupon(coupon()); + + coupon.makeSemiAnnual(); + periods=coupon.frequency()*ytm(); + semiAnnualPmt=par()*coupon.decimalRate(); + cashflows.size(periods); + for(int period=0;periodprice()) + { + maxGuess=guess; + guess.rate((guess.rate()+minGuess.rate())/2.00); + } + else + { + minGuess=guess; + guess.rate((guess.rate()+maxGuess.rate())/2.00); + } + printf("calculated price:%lf market price:%lf\n",price(),market); + } + yield(guess); + return yield(); +} diff --git a/analytic/BOND.HPP b/analytic/BOND.HPP new file mode 100644 index 0000000..923451c --- /dev/null +++ b/analytic/BOND.HPP @@ -0,0 +1,43 @@ +#ifndef _ANALYTIC_BOND_HPP_ +#define _ANALYTIC_BOND_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_GLOBALDATA_HPP_ +#include +#endif +#ifndef _ANALYTIC_INSTRUMENT_HPP_ +#include +#endif +#ifndef _ANALYTIC_RATE_HPP_ +#include +#endif + +class Bond : public Instrument +{ +public: + Bond(void); + Bond(const Bond &bond); + Bond(double par,const Coupon &coupon,int ytm,double price=0.00); + virtual ~Bond(); + Bond &operator=(const Bond &bond); + BOOL operator==(const Bond &bond)const; + double par(void)const; + void par(double par); + int ytm(void)const; + void ytm(int ytm); + const Rate &yield(void)const; + void yield(const Rate &yield); + virtual BOOL cashflows(GlobalData &cashflows); // retrieve cashflows (ie)periodic payments + virtual double discount(Rate yield); // given the yield, calculate the price + virtual Rate discount(double price); // given the price, calculate the yield +private: + double mPar; + Rate mYield; + int mYTM; +}; +#endif + + + + diff --git a/analytic/CATMULL.CPP b/analytic/CATMULL.CPP new file mode 100644 index 0000000..2af742f --- /dev/null +++ b/analytic/CATMULL.CPP @@ -0,0 +1,83 @@ +// SOURCE: CATMULL-ROM CUBIC SPLINE +// AUTHOR: SEAN M. KESSLER (Adopted from Numerical Recipes in 'C') +// DATE: 12/28/1993 +#include + +CatmullRom::CatmullRom(void) +{ +} + +CatmullRom::CatmullRom(const CatmullRom &someCatmullRom) +{ // no implementation + *this=someCatmullRom; +} + +inline +CatmullRom::~CatmullRom() +{ +} + +inline +CatmullRom &CatmullRom::operator=(const CatmullRom &/*someCatmullRom*/) +{ // no implementation + return *this; +} + +BOOL CatmullRom::performSpline(GlobalData &sourcePairs,GlobalData &destPairs) +{ + double a0,a1,a2,a3; + double dx,dx1,dx2; + double dy,dy1,dy2; + double endPointOne,endPointTwo,resamplingPos; + double xPoint; + short clampOne,clampTwo; + short direction; + short destSize((short)destPairs.size()); + short sourceSize((short)sourcePairs.size()); + short inputIndex,index; + + if(sourceSize<2||destSize<2)return FALSE; + if(sourcePairs[0].column()sourcePairs[sourceSize-1].column())direction=0; + else direction=1; + } + else + { + if(destPairs[0].column()>sourcePairs[0].column()|| + destPairs[destSize-1].column()endPointTwo)||(-1==direction&&resamplingPossourcePairs[inputIndex].column();inputIndex++); + if(resamplingPos +#endif +#ifndef _COMMON_GLOBALDATA_HPP_ +#include +#endif +#ifndef _ANALYTIC_FLOATPAIRS_HPP_ +#include +#endif + +// Sample usage of the spline generator... +// CarmullRom splineGen; +// PureVector srcPairs; +// PureVector dstPairs; +// srcPairs[0]=FloatPairs(1.00,25); +// srcPairs[1]=FloatPairs(4.00,50); +// dstPairs[0]=FloatPairs(1.00,0.00); +// dstPairs[1]=FloatPairs(2.00,0.00); +// dstPairs[2]=FloatPairs(3.00,0.00); +// dstPairs[3]=FloatPairs(4.00,0.00); +// splineGen.performSpline(srcPairs,dstPairs); +// ... dstPairs contains interpolation of 25-50 across four points + +class CatmullRom +{ +public: + CatmullRom(void); + virtual ~CatmullRom(); + BOOL performSpline(GlobalData &sourcePoints,GlobalData &destPoints); +private: + CatmullRom(const CatmullRom &someCatmullRom); + CatmullRom &operator=(const CatmullRom &someCatmullRom); +}; + +#endif + + + + + + + + + + + + diff --git a/analytic/COUPON.CPP b/analytic/COUPON.CPP new file mode 100644 index 0000000..2bdd286 --- /dev/null +++ b/analytic/COUPON.CPP @@ -0,0 +1,92 @@ +#include + +Coupon::Coupon(void) +: mRate(0.00), mDecimalRate(0.00), mFrequency(Annual) +{ +} + +Coupon::Coupon(const Coupon &coupon) +{ + *this=coupon; +} + +Coupon::Coupon(double rate,Frequency frequency) +: mRate(rate), mDecimalRate(rate/100.00), mFrequency(frequency) +{ +} + +Coupon::~Coupon() +{ +} + +BOOL Coupon::operator==(const Coupon &coupon)const +{ + return (rate()==coupon.rate()&& + frequency()==coupon.frequency()); +} + +BOOL Coupon::operator>(const Coupon &coupon)const +{ + Coupon cpn(coupon); + + cpn.frequency(frequency()); + return rate()>cpn.rate(); +} + +BOOL Coupon::operator<(const Coupon &coupon)const +{ + Coupon cpn(coupon); + + cpn.frequency(frequency()); + return rate() +#endif +#ifndef _ANALYTIC_FREQUENCY_HPP_ +#include +#endif + +class Coupon +{ +public: + Coupon(void); + Coupon(const Coupon &coupon); + Coupon(double rate,Frequency frequency=Annual); + virtual ~Coupon(); + BOOL operator==(const Coupon &coupon)const; + BOOL operator>(const Coupon &coupon)const; + BOOL operator<(const Coupon &coupon)const; + Coupon &operator=(const Coupon &coupon); + double rate(void)const; + void rate(double rate); + double decimalRate(void)const; + Frequency frequency(void)const; + void frequency(const Frequency &frequency); + void makeAnnual(void); + void makeSemiAnnual(void); +private: + double mRate; + double mDecimalRate; + Frequency mFrequency; +}; +#endif diff --git a/analytic/Debug/Test.obj b/analytic/Debug/Test.obj new file mode 100644 index 0000000..3fe384e Binary files /dev/null and b/analytic/Debug/Test.obj differ diff --git a/analytic/Debug/test.exe b/analytic/Debug/test.exe new file mode 100644 index 0000000..8b39c53 Binary files /dev/null and b/analytic/Debug/test.exe differ diff --git a/analytic/Debug/test.ilk b/analytic/Debug/test.ilk new file mode 100644 index 0000000..b7a8916 Binary files /dev/null and b/analytic/Debug/test.ilk differ diff --git a/analytic/Debug/test.pch b/analytic/Debug/test.pch new file mode 100644 index 0000000..a76f445 Binary files /dev/null and b/analytic/Debug/test.pch differ diff --git a/analytic/Debug/test.pdb b/analytic/Debug/test.pdb new file mode 100644 index 0000000..caf6e4e Binary files /dev/null and b/analytic/Debug/test.pdb differ diff --git a/analytic/Debug/vc60.idb b/analytic/Debug/vc60.idb new file mode 100644 index 0000000..8b6439a Binary files /dev/null and b/analytic/Debug/vc60.idb differ diff --git a/analytic/Debug/vc60.pdb b/analytic/Debug/vc60.pdb new file mode 100644 index 0000000..f8afa28 Binary files /dev/null and b/analytic/Debug/vc60.pdb differ diff --git a/analytic/FREQ.HPP b/analytic/FREQ.HPP new file mode 100644 index 0000000..91b2708 --- /dev/null +++ b/analytic/FREQ.HPP @@ -0,0 +1,6 @@ +#ifndef _ANALYTIC_FREQUENCY_HPP_ +#define _ANALYTIC_FREQUENCY_HPP_ + +enum Frequency{Annual=1,SemiAnnual=2,Quarterly=4,Monthly=12}; + +#endif diff --git a/analytic/INSTRMNT.CPP b/analytic/INSTRMNT.CPP new file mode 100644 index 0000000..2fe7162 --- /dev/null +++ b/analytic/INSTRMNT.CPP @@ -0,0 +1,92 @@ +#include +#include + +Instrument::Instrument(Type type) +: mPrice(0.00), mType(type) +{ +} + +Instrument::Instrument(const Instrument &instrument) +{ + *this=instrument; +} + +Instrument::~Instrument() +{ +} + +BOOL Instrument::operator==(const Instrument &instrument)const +{ + return (price()==instrument.price()&& + coupon()==instrument.coupon()&& + type()==instrument.type()); +} + +Instrument &Instrument::operator=(const Instrument &instrument) +{ + price(instrument.price()); + coupon(instrument.coupon()); + type(instrument.type()); + return *this; +} + +double Instrument::price(void)const +{ + return mPrice; +} + +void Instrument::price(double price) +{ + mPrice=price; +} + +const Coupon &Instrument::coupon(void)const +{ + return mCoupon; +} + +void Instrument::coupon(const Coupon &coupon) +{ + mCoupon=coupon; +} + +Instrument::Type Instrument::type(void)const +{ + return mType; +} + +void Instrument::type(Type type) +{ + mType=type; +} + +// **** virtuals + +double Instrument::par(void)const +{ + return 0.00; +} + +BOOL Instrument::cashflows(GlobalData &cashflows) +{ + cashflows.size(0); + return cashflows.size(); +} + +double Instrument::fv(int periods) +{ + Coupon ac(mCoupon); + ac.makeAnnual(); + return price()*::pow(1.00+(ac.rate()/100.00)/ac.frequency(),ac.frequency()*periods); +} + +double Instrument::discount(double fv,int periods) +{ + Coupon ac(mCoupon); + ac.makeAnnual(); + price(fv*(1.00/::pow(1+ac.rate()/100.00,periods))); + return price(); +} + + + diff --git a/analytic/INSTRMNT.HPP b/analytic/INSTRMNT.HPP new file mode 100644 index 0000000..d64aee7 --- /dev/null +++ b/analytic/INSTRMNT.HPP @@ -0,0 +1,35 @@ +#ifndef _ANALYTIC_INSTRUMENT_HPP_ +#define _ANALYTIC_INSTRUMENT_HPP_ +#ifndef _COMMON_GLOBALDATA_HPP_ +#include +#endif +#ifndef _ANALYTIC_COUPON_HPP_ +#include +#endif + +class Instrument +{ +public: + enum Type{Generic,StraightBond,ZeroCouponBond}; + Instrument(Type type=Generic); + Instrument(const Instrument &instrument); + virtual ~Instrument(); + BOOL operator==(const Instrument &instrument)const; + Instrument &operator=(const Instrument &instrument); + double price(void)const; + void price(double price); + const Coupon &coupon(void)const; + void coupon(const Coupon &coupon); + Type type(void)const; + void type(Type type); + virtual BOOL cashflows(GlobalData &cashflows); + virtual double par(void)const; + virtual double fv(int periods); + virtual double discount(double fv,int periods); +private: + double mPrice; + Coupon mCoupon; + Type mType; +}; +#endif + diff --git a/analytic/MAIN.CPP b/analytic/MAIN.CPP new file mode 100644 index 0000000..eca5eda --- /dev/null +++ b/analytic/MAIN.CPP @@ -0,0 +1,18 @@ +#include +#include + +int main(int argc,char **argv) +{ + File fileDummy; + Point ptDummy; + Application mainApp(argc,argv); + MainWindow mainWindow(mainApp); + mainApp.main(); + return 1; +} + + + + + + diff --git a/analytic/MAINWND.CPP b/analytic/MAINWND.CPP new file mode 100644 index 0000000..1d4d178 --- /dev/null +++ b/analytic/MAINWND.CPP @@ -0,0 +1,469 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +MainWindow::MainWindow(Application &mainApp) +: Window(mainApp), mCurrentRow(0) +{ + initHandlers(); + createControls(); + initControls(); +} + +MainWindow::~MainWindow() +{ +} + +void MainWindow::initHandlers(void) +{ + mCancelHandler.setCallback(this,&cancelHandler); + mCalcHandler.setCallback(this,&calcHandler); + mAddHandler.setCallback(this,&addHandler); + mDelHandler.setCallback(this,&delHandler); + mSetHandler.setCallback(this,&setHandler); + mSaveHandler.setCallback(this,&saveHandler); + mLoadHandler.setCallback(this,&loadHandler); + mSelectRowHandler.setCallback(this,&selectRowHandler); + mSaveFileSelectHandler.setCallback(this,&saveFileSelectHandler); + mLoadFileSelectHandler.setCallback(this,&loadFileSelectHandler); +} + +void MainWindow::createControls(void) +{ + create(); + size(InitialWidth,InitialHeight); + setCaption("Portfolio v1.0.0"); + position(CenterPosition); + + show(); + + mPixmap.create(*this,220,120); + mPixmap.clear(); + + mLabelBond.create("Bond:"); + mLabelCoupon.create("Coupon:"); + mLabelYTM.create("YTM:");; + mLabelPar.create("Par:"); + mLabelPrice.create("Price:"); + mLabelYield.create("Yield:"); + mLabelYieldValue.create(); + + mEntryBond.create(); + mEntryCoupon.create(); + mEntryYTM.create(); + mEntryPar.create(); + mEntryPrice.create(); + + mCancelButton.setHandler(&mCancelHandler); + mCancelButton.create("Quit"); + mCalcButton.setHandler(&mCalcHandler); + mCalcButton.create("Yield"); + + mAddButton.setHandler(&mAddHandler); + mAddButton.create("Add"); + mDelButton.setHandler(&mDelHandler); + mDelButton.create("Remove"); + mSaveButton.setHandler(&mSaveHandler); + mSaveButton.create("Save"); + mLoadButton.setHandler(&mLoadHandler); + mLoadButton.create("Load"); + mSetButton.setHandler(&mSetHandler); + mSetButton.create("Set"); + + mStatusBar.create(); + Block strColTitles; + strColTitles.insert(String("Bond")); + strColTitles.insert(String("CPN")); + strColTitles.insert(String("YTM")); + strColTitles.insert(String("Par")); + strColTitles.insert(String("Price")); + mPortfolioList.create(strColTitles); + mPortfolioList.setSelectRowHandler(&mSelectRowHandler); + mPortfolioList.setColumnWidth(0,50); + mPortfolioList.setColumnWidth(1,50); + mPortfolioList.setColumnWidth(2,50); + mPortfolioList.setColumnWidth(3,100); + mPortfolioList.setColumnWidth(4,100); + mWinGrid.create(14,6); + mWinGrid.setColSpacing(52); + mWinGrid.setRowSpacing(3); + + mWinGrid.attach(mCancelButton,4,6,0,1); + mWinGrid.attach(mCalcButton,4,6,1,2); + mWinGrid.attach(mAddButton,4,6,7,8); + mWinGrid.attach(mDelButton,4,6,8,9); + mWinGrid.attach(mSetButton,4,6,9,10); + mWinGrid.attach(mSaveButton,4,6,2,3); + mWinGrid.attach(mLoadButton,4,6,3,4); + mWinGrid.attach(mStatusBar,0,6,13,14); + mWinGrid.attach(mPortfolioList,0,5,0,6); + + mWinGrid.attach(mLabelBond,3,4,6,7); + mWinGrid.attach(mLabelCoupon,3,4,7,8); + mWinGrid.attach(mLabelYTM,3,4,8,9); + mWinGrid.attach(mLabelPar,3,4,9,10); + mWinGrid.attach(mLabelPrice,3,4,10,11); + mWinGrid.attach(mLabelYield,3,4,11,12); + mWinGrid.attach(mLabelYieldValue,4,5,11,12); + mWinGrid.attach(mEntryBond,4,5,6,7); + mWinGrid.attach(mEntryCoupon,4,5,7,8); + mWinGrid.attach(mEntryYTM,4,5,8,9); + mWinGrid.attach(mEntryPar,4,5,9,10); + mWinGrid.attach(mEntryPrice,4,5,10,11); + mWinGrid.attach(mPixmap,0,4,6,11); + + *this+=mWinGrid; + mWinGrid.show(); + mPixmap.show(); + mCancelButton.show(); + mCalcButton.show(); + mAddButton.show(); + mDelButton.show(); + mSaveButton.show(); + mLoadButton.show(); + mSetButton.show(); + mStatusBar.show(); + mPortfolioList.show(); + mLabelBond.show(); + mLabelCoupon.show(); + mLabelYTM.show(); + mLabelPar.show(); + mLabelPrice.show(); + mLabelYield.show(); + mLabelYieldValue.show(); + + mEntryBond.show(); + mEntryCoupon.show(); + mEntryYTM.show(); + mEntryPar.show(); + mEntryPrice.show(); +} + +void MainWindow::initControls(void) +{ + mStatusBar.setText("Ready."); +} + +// callbacks + +int MainWindow::cancelHandler(CallbackData &someCallbackData) +{ + CallbackData cbData(someCallbackData); + quit(); + return 0; +} + +int MainWindow::calcHandler(CallbackData &someCallbackData) +{ + calcYield(); + return 0; +} + +void MainWindow::calcYield(void) +{ + Portfolio portfolio; + String strYield; + + getPortfolio(portfolio); + if(!portfolio.size())return; + Rate yield(portfolio.yield()); + ::sprintf(strYield,"%5.3lf",yield.decimalRate()*100.00); + mLabelYieldValue.setLabel(strYield); +} + +int MainWindow::addHandler(CallbackData &someCallbackData) +{ + String strEntry; + String strFormat; + int row; + + mPortfolioList.addRow(); + row=mPortfolioList.getRowCount(); + mEntryBond.getText(strEntry); + mPortfolioList.setCellData(row-1,0,strEntry); + mEntryCoupon.getText(strEntry); + ::sprintf(strFormat,"%5.3lf",::atof(strEntry)); + mPortfolioList.setCellData(row-1,1,strFormat); + mEntryYTM.getText(strEntry); + ::sprintf(strFormat,"%d",::atoi(strEntry)); + mPortfolioList.setCellData(row-1,2,strFormat); + mEntryPar.getText(strEntry); + mPortfolioList.setCellData(row-1,3,(String)Money(::atof(strEntry))); + mEntryPrice.getText(strEntry); + mPortfolioList.setCellData(row-1,4,(String)Money(::atof(strEntry))); + calcYield(); + graphCashflows(); + return 0; +} + +int MainWindow::delHandler(CallbackData &someCallbackData) +{ + if(!mPortfolioList.getRowCount())return 0; + mPortfolioList.removeRow(currentRow()); + calcYield(); + graphCashflows(); + return 0; +} + +int MainWindow::saveHandler(CallbackData &someCallbackData) +{ + if(!mOpenDialog.create("Save Portfolio"))return 0; + mOpenDialog.setSelectHandler(&mSaveFileSelectHandler); +} + +int MainWindow::loadHandler(CallbackData &someCallbackData) +{ + if(!mOpenDialog.create("Load Portfolio"))return 0; + mOpenDialog.setSelectHandler(&mLoadFileSelectHandler); +} + +int MainWindow::setHandler(CallbackData &someCallbackData) +{ + String strEntry; + String strFormat; + + if(!mPortfolioList.getRowCount())return 0; + mEntryBond.getText(strEntry); + mPortfolioList.setCellData(currentRow(),0,strEntry); + mEntryCoupon.getText(strEntry); + ::sprintf(strFormat,"%5.3lf",::atof(strEntry)); + mPortfolioList.setCellData(currentRow(),1,strFormat); + mEntryYTM.getText(strEntry); + ::sprintf(strFormat,"%d",::atoi(strEntry)); + mPortfolioList.setCellData(currentRow(),2,strFormat); + mEntryPar.getText(strEntry); + mPortfolioList.setCellData(currentRow(),3,(String)Money(::atof(strEntry))); + mEntryPrice.getText(strEntry); + mPortfolioList.setCellData(currentRow(),4,(String)Money(::atof(strEntry))); + calcYield(); + graphCashflows(); + return 0; +} + +int MainWindow::saveFileSelectHandler(CallbackData &someCallbackData) +{ + String strPathFileName(*(String*)someCallbackData.data()); + Block listLines; + File saveFile; + + if(strPathFileName.isNull())return 0; + if(!getLines(listLines))return 0; + saveFile.open(strPathFileName,"wb"); + for(int index=0;index strLines; + String strLine; + File inFile; + char *ptrLine; + int rows; + + inFile.open(strPathFileName,"rb"); + if(!inFile.isOkay())return 0; + mPortfolioList.clear(); + while(!inFile.eof()) + { + inFile.getLine(strLine); + if(strLine.isNull())continue; + mPortfolioList.addRow(); + rows=mPortfolioList.getRowCount(); + ptrLine=(char*)strLine; + ptrLine=::strtok(ptrLine,","); + if(!ptrLine)continue; + mPortfolioList.setCellData(rows-1,0,ptrLine); + ptrLine=::strtok(0,","); + if(!ptrLine)continue; + mPortfolioList.setCellData(rows-1,1,ptrLine); + ptrLine=::strtok(0,","); + if(!ptrLine)continue; + mPortfolioList.setCellData(rows-1,2,ptrLine); + ptrLine=::strtok(0,","); + if(!ptrLine)continue; + mPortfolioList.setCellData(rows-1,3,(String)Money(::atof(ptrLine))); + ptrLine=::strtok(0,",\0"); + if(!ptrLine)continue; + mPortfolioList.setCellData(rows-1,4,(String)Money(::atof(ptrLine))); + } + calcYield(); + graphCashflows(); + return 0; +} + +void MainWindow::graphCashflows(void) +{ + GlobalData cashflows; + GlobalData srcPairs; + GlobalData dstPairs; + CatmullRom splineGen; + Portfolio portfolio; + double maxFlow; + double clampFactor; + int recLen; + + mPixmap.clear(); + getPortfolio(portfolio); + portfolio.getCashflows(cashflows); + recLen=mPixmap.width()/cashflows.size(); + if(!cashflows.size())return; + for(int index=0;indexmaxFlow)maxFlow=cashflows[index]; + } + clampFactor=(float)mPixmap.height()/(float)maxFlow; + for(int index=0;index cashflows; + GlobalData srcPairs; + GlobalData dstPairs; + CatmullRom splineGen; + Portfolio portfolio; + double maxFlow; + double clampFactor; + + mPixmap.clear(); + getPortfolio(portfolio); + portfolio.getCashflows(cashflows); + if(!cashflows.size())return; + for(int index=0;indexmaxFlow)maxFlow=cashflows[index]; + } + clampFactor=(float)mPixmap.height()/(float)maxFlow; + for(int index=0;index &listLines) +{ + String strEntry; + String strLine; + int rows; + + listLines.remove(); + rows=mPortfolioList.getRowCount(); + for(int row=0;row +#endif +#ifndef _GUI_WINDOW_HPP_ +#include +#endif + +class Portfolio; + +class MainWindow : private Window +{ +public: + MainWindow(Application &mainApp); + virtual ~MainWindow(); +protected: + void exposeEvent(const Expose &expose); + void configureEvent(const Configure &configure); +private: + enum{InitialWidth=640,InitialHeight=360}; + void initHandlers(void); + void createControls(void); + void initControls(void); + void graphCashflows(void); + void graphCashflowsSpline(void); + void calcYield(void); + int currentRow(void)const; + int getLines(Block &listLines); + int getPortfolio(Portfolio &portfolio); + int selectRowHandler(CallbackData &someCallbackData); + int cancelHandler(CallbackData &someCallbackData); + int calcHandler(CallbackData &someCallbackData); + int addHandler(CallbackData &someCallbackData); + int delHandler(CallbackData &someCallbackData); + int setHandler(CallbackData &someCallbackData); + int saveHandler(CallbackData &someCallbackData); + int loadHandler(CallbackData &someCallbackData); + int saveFileSelectHandler(CallbackData &someCallbackData); + int loadFileSelectHandler(CallbackData &someCallbackData); + + Callback mCancelHandler; + Callback mCalcHandler; + Callback mAddHandler; + Callback mDelHandler; + Callback mSetHandler; + Callback mSelectRowHandler; + Callback mSaveHandler; + Callback mLoadHandler; + Callback mSaveFileSelectHandler; + Callback mLoadFileSelectHandler; + Button mCancelButton; + Button mCalcButton; + Button mAddButton; + Button mDelButton; + Button mSetButton; + Button mSaveButton; + Button mLoadButton; + Label mLabelBond; + Label mLabelCoupon; + Label mLabelYTM; + Label mLabelPar; + Label mLabelPrice; + Label mLabelYield; + Label mLabelYieldValue; + Entry mEntryBond; + Entry mEntryCoupon; + Entry mEntryYTM; + Entry mEntryPar; + Entry mEntryPrice; + StatusBar mStatusBar; + CList mPortfolioList; + Table mWinGrid; + Pixmap mPixmap; + OpenDialog mOpenDialog; + int mCurrentRow; +}; +#endif + + diff --git a/analytic/MONEY.CPP b/analytic/MONEY.CPP new file mode 100644 index 0000000..3195a01 --- /dev/null +++ b/analytic/MONEY.CPP @@ -0,0 +1,86 @@ +#include +#include + +Money::Money(void) +: mValue(0.00), mFormat("% 12.2lf") +{ +} + +Money::Money(double value) +: mValue(value), mFormat("% 12.2lf") +{ +} + +Money::Money(const Money &someMoney) +{ + *this=someMoney; +} + +Money::~Money() +{ +} + +Money &Money::operator=(const Money &someMoney) +{ + format(someMoney.format()); + value(someMoney.value()); + return *this; +} + +void Money::format(const String &strFormat) +{ + mFormat=strFormat; +} + +const String &Money::format(void)const +{ + return mFormat; +} + +double Money::value(void)const +{ + return mValue; +} + +void Money::value(double value) +{ + mValue=value; +} + +Money::operator String(void) +{ + String strString; + String moneyString; + + ::sprintf(strString,mFormat,mValue); + char *strPtr=strString; + char *strRoot=strPtr; + while(*strPtr!='.')strPtr++; + while(TRUE) + { + for(int count=0;count<3&&strPtr>strRoot&&*strPtr!=' ';count++)strPtr--; + if(strPtr +#endif + +class Money +{ +public: + Money(void); + Money(double value); + Money(const Money &someMoney); + Money(String strMoney); + virtual ~Money(); + Money &operator=(const Money &someMoney); + operator String(void); + void format(const String &strFormat); + const String &format(void)const; + double value(void)const; + void value(double value); +protected: + virtual void apply(String &strMoney); +private: + double mValue; + String mFormat; +}; +#endif diff --git a/analytic/PAIRS.CPP b/analytic/PAIRS.CPP new file mode 100644 index 0000000..299ada2 --- /dev/null +++ b/analytic/PAIRS.CPP @@ -0,0 +1,74 @@ +#include + +FloatPairs::FloatPairs(void) +: mColumn(0.00), mRow(0.00) +{ +} + +FloatPairs::FloatPairs(const FloatPairs &someFloatPairs) +{ + *this=someFloatPairs; +} + +FloatPairs::FloatPairs(double column,double row) +: mColumn(column), mRow(row) +{ +} + +FloatPairs::~FloatPairs() +{ +} + +BOOL FloatPairs::operator==(const FloatPairs &someFloatPair)const +{ + return (mColumn==someFloatPair.mColumn && mRow==someFloatPair.mRow); +} + +FloatPairs &FloatPairs::operator=(const FloatPairs &someFloatPairs) +{ + column(someFloatPairs.column()); + row(someFloatPairs.row()); + return *this; +} + +double FloatPairs::column(void)const +{ + return mColumn; +} + +void FloatPairs::column(double newColumn) +{ + mColumn=newColumn; +} + +double FloatPairs::row(void)const +{ + return mRow; +} + +void FloatPairs::row(double newRow) +{ + mRow=newRow; +} + +void FloatPairs::setPairs(double newColumn,double newRow) +{ + mColumn=newColumn; + mRow=newRow; +} + +void FloatPairs::setPairs(int newColumn,int newRow) +{ + mColumn=(double)newColumn; + mRow=(double)newRow; +} + +int FloatPairs::fpmax(int firstVal,int secondVal) +{ + return (firstVal>secondVal?firstVal:secondVal); +} + +int FloatPairs::fpmin(int firstVal,int secondVal) +{ + return (firstVal +#endif + +class FloatPairs +{ +public: + FloatPairs(void); + FloatPairs(const FloatPairs &someFloatPairs); + FloatPairs(double column,double row); + virtual ~FloatPairs(); + FloatPairs &operator=(const FloatPairs &someFloatPairs); + BOOL operator==(const FloatPairs &someFloatPair)const; + double column(void)const; + void column(double newColumn); + double row(void)const; + void row(double newRow); + void setPairs(double newColumn,double newRow); + void setPairs(int newColumn,int newRow); + static int fpmax(int firstVal,int secondVal); + static int fpmin(int firstVal,int secondVal); +private: + double mColumn; + double mRow; +}; +#endif diff --git a/analytic/PORTFLIO.CPP b/analytic/PORTFLIO.CPP new file mode 100644 index 0000000..d4ea6c2 --- /dev/null +++ b/analytic/PORTFLIO.CPP @@ -0,0 +1,127 @@ +#include +#include +#include + +Portfolio::Portfolio(void) +{ +} + +Portfolio::Portfolio(const Portfolio &portfolio) +{ // private implementation + *this=portfolio; +} + +Portfolio::~Portfolio() +{ +} + +Portfolio &Portfolio::operator=(const Portfolio &/*portfolio*/) +{ // private implementation + return *this; +} + +BOOL Portfolio::operator==(const Portfolio &portfolio)const +{ + return FALSE; +} + +double Portfolio::discount(Rate yield,GlobalData &cashflows) +{ + double price(0.00); + + yield.makeSemiAnnual(); + for(int index=0;indexcoupon(); + rate.makeAnnual(); + weighted+=rate.decimalRate()*operator[](index)->par(); + parValue+=operator[](index)->par(); + } + weighted/=parValue; + return Rate(weighted*100.00,Annual); +} + +Rate Portfolio::discount(double market,GlobalData &cashflows) +{ + Rate guess(wac()); + Rate maxGuess; + Rate minGuess; + double price; + int maxPly=50; + int ply=0; + + maxGuess=guess; + minGuess=guess; + maxGuess.rate(guess.rate()+12.00); + minGuess.rate(guess.rate()-12.00); + if(minGuess.rate()<0.00)minGuess.rate(1.00); + while(TRUE) + { + price=discount(guess,cashflows); + if(price==market||(price-market<0.00?market-price:price-market)<1.00)break; + if(market>price) + { + maxGuess=guess; + guess.rate((guess.rate()+minGuess.rate())/2.00); + } + else + { + minGuess=guess; + guess.rate((guess.rate()+maxGuess.rate())/2.00); + } + if(++ply>maxPly)return Rate(0.00); + printf("calculated price:%lf market price:%lf\n",price,market); + } + return guess; +} + +int Portfolio::getCashflows(GlobalData &sumCashflows) +{ + GlobalData > cashflows; + int maxFlows(0); + + cashflows.size(size()); + for(int index=0;indexcashflows(cashflows[index]); + for(index=0;indexmaxFlows)maxFlows=cashflows[index].size(); + } + sumCashflows.size(maxFlows); + for(int pIndex=0;pIndex &cashflow=cashflows[pIndex]; + for(int index=0;index cashflows; + double price(0.00); + + getCashflows(cashflows); + for(int index=0;indexprice(); + return Rate(discount(price,cashflows)); +} + + + + + + + + + + diff --git a/analytic/PORTFLIO.HPP b/analytic/PORTFLIO.HPP new file mode 100644 index 0000000..61f925b --- /dev/null +++ b/analytic/PORTFLIO.HPP @@ -0,0 +1,37 @@ +#ifndef _ANALYTIC_PORTFOLIO_HPP_ +#define _ANALYTIC_PORTFOLIO_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif +#ifndef _COMMON_BLOCK_HPP_ +#include +#endif +#ifndef _ANALYTIC_INSTRUMENT_HPP_ +#include +#endif +#ifndef _ANALYTIC_RATE_HPP_ +#include +#endif + +typedef SmartPointer FinancialInstrument; +typedef Block FinancialInstruments; + +class Portfolio : public FinancialInstruments +{ +public: + Portfolio(void); + virtual ~Portfolio(); + BOOL operator==(const Portfolio &portfolio)const; + int getCashflows(GlobalData &sumCashflows); + Rate yield(void); +private: + Portfolio(const Portfolio &portfolio); + Portfolio &operator=(const Portfolio &portfolio); + double discount(Rate yield,GlobalData &cashflows); + Rate discount(double market,GlobalData &cashflows); + Rate wac(void); +}; +#endif diff --git a/analytic/PORTFOLI.CPP b/analytic/PORTFOLI.CPP new file mode 100644 index 0000000..f3c5609 --- /dev/null +++ b/analytic/PORTFOLI.CPP @@ -0,0 +1,124 @@ +#include +#include +#include + +Portfolio::Portfolio(void) +{ +} + +Portfolio::Portfolio(const Portfolio &portfolio) +{ // private implementation + *this=portfolio; +} + +Portfolio::~Portfolio() +{ +} + +Portfolio &Portfolio::operator=(const Portfolio &/*portfolio*/) +{ // private implementation + return *this; +} + +BOOL Portfolio::operator==(const Portfolio &portfolio)const +{ + return FALSE; +} + +double Portfolio::discount(Rate yield,GlobalData &cashflows) +{ + double price(0.00); + + yield.makeSemiAnnual(); + for(int index=0;indexcoupon(); + rate.makeAnnual(); + weighted+=rate.decimalRate()*operator[](index)->par(); + parValue+=operator[](index)->par(); + } + weighted/=parValue; + return Rate(weighted*100.00,Annual); +} + +Rate Portfolio::discount(double market,GlobalData &cashflows) +{ + Rate guess(wac()); + Rate maxGuess; + Rate minGuess; + double price; + + maxGuess=guess; + minGuess=guess; + maxGuess.rate(guess.rate()+12.00); + minGuess.rate(guess.rate()-12.00); + if(minGuess.rate()<0.00)minGuess.rate(1.00); + while(TRUE) + { + price=discount(guess,cashflows); + if(price==market||(price-market<0.00?market-price:price-market)<1.00)break; + if(market>price) + { + maxGuess=guess; + guess.rate((guess.rate()+minGuess.rate())/2.00); + } + else + { + minGuess=guess; + guess.rate((guess.rate()+maxGuess.rate())/2.00); + } + //printf("calculated price:%lf market price:%lf\n",price,market); + } + return guess; +} + +int Portfolio::getCashflows(GlobalData &sumCashflows) +{ + GlobalData > cashflows; + int maxFlows(0); + + cashflows.size(size()); + for(int index=0;indexcashflows(cashflows[index]); + for(int index=0;indexmaxFlows)maxFlows=cashflows[index].size(); + } + sumCashflows.size(maxFlows); + for(int pIndex=0;pIndex &cashflow=cashflows[pIndex]; + for(int index=0;index cashflows; + double price(0.00); + + getCashflows(cashflows); + for(int index=0;indexprice(); + return Rate(discount(price,cashflows)); +} + + + + + + + + + + diff --git a/analytic/RATE.HPP b/analytic/RATE.HPP new file mode 100644 index 0000000..a1094b0 --- /dev/null +++ b/analytic/RATE.HPP @@ -0,0 +1,10 @@ +#ifndef _ANALYTIC_RATE_HPP_ +#define _ANALYTIC_RATE_HPP_ +#ifndef _ANALYTIC_COUPON_HPP_ +#include +#endif + +typedef Coupon Rate; +#endif + + diff --git a/analytic/Test.cpp b/analytic/Test.cpp new file mode 100644 index 0000000..77f18b1 --- /dev/null +++ b/analytic/Test.cpp @@ -0,0 +1,16 @@ +#include +#include +#include + +void __cdecl main(int argc,char **argv) +{ + Portfolio portfolio; + + for(double price=10.00;price<100.00;price+=2.00) + { + SmartPointer bond=new Bond(100.00,Coupon(7.00),10,price); + bond.disposition(PointerDisposition::Assume); + portfolio.insert(&bond); + } + Rate yield=portfolio.yield(); +} diff --git a/analytic/ZBOND.CPP b/analytic/ZBOND.CPP new file mode 100644 index 0000000..0066d88 --- /dev/null +++ b/analytic/ZBOND.CPP @@ -0,0 +1,60 @@ +#include +#include + +ZeroCouponBond::ZeroCouponBond(void) +{ + type(Instrument::ZeroCouponBond); +} + +ZeroCouponBond::ZeroCouponBond(const ZeroCouponBond &zeroCouponBond) +{ + *this=zeroCouponBond; +} + +ZeroCouponBond::ZeroCouponBond(double par,const Coupon &coupon,int ytm) +: Bond(par,coupon,ytm) +{ + type(Instrument::ZeroCouponBond); +} + +ZeroCouponBond::~ZeroCouponBond() +{ +} + +ZeroCouponBond &ZeroCouponBond::operator=(const ZeroCouponBond &zeroCouponBond) +{ + (Bond&)*this=(Bond&)zeroCouponBond; + return *this; +} + +BOOL ZeroCouponBond::operator==(const ZeroCouponBond &zeroCouponBond)const +{ + return (Bond&)*this==(Bond&)zeroCouponBond; +} + +// virtuals + +double ZeroCouponBond::discount(Rate /*yield*/) +{ + return discount(); +} + +double ZeroCouponBond::discount(void) +{ + Coupon coupon(coupon()); + double bondPrice; + int periods; + + coupon.makeSemiAnnual(); + periods=coupon.frequency()*ytm(); + bondPrice=par()/::pow(1.00+coupon.decimalRate(),periods); + price(bondPrice); + return price(); +} + + + + + + + diff --git a/analytic/ZBOND.HPP b/analytic/ZBOND.HPP new file mode 100644 index 0000000..2a9ba58 --- /dev/null +++ b/analytic/ZBOND.HPP @@ -0,0 +1,20 @@ +#ifndef _ANALYTIC_ZEROCOUPONBOND_HPP_ +#define _ANALYTIC_ZEROCOUPONBOND_HPP_ +#ifndef _ANALYTIC_BOND_HPP_ +#include +#endif + +class ZeroCouponBond : public Bond +{ +public: + ZeroCouponBond(void); + ZeroCouponBond(const ZeroCouponBond &zeroCouponBond); + ZeroCouponBond(double par,const Coupon &coupon,int ytm); + virtual ~ZeroCouponBond(); + ZeroCouponBond &operator=(const ZeroCouponBond &zeroCouponBond); + BOOL operator==(const ZeroCouponBond &zeroCouponBond)const; + virtual double discount(void); + virtual double discount(Rate yield); +private: +}; +#endif diff --git a/analytic/test.dsp b/analytic/test.dsp new file mode 100644 index 0000000..06e4538 --- /dev/null +++ b/analytic/test.dsp @@ -0,0 +1,101 @@ +# Microsoft Developer Studio Project File - Name="test" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=test - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "test.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "test.mak" CFG="test - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "test - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "test - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "test - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "test - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "STRICT" /D "__FLAT__" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "test - Win32 Release" +# Name "test - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\Test.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/analytic/test.dsw b/analytic/test.dsw new file mode 100644 index 0000000..a185061 --- /dev/null +++ b/analytic/test.dsw @@ -0,0 +1,59 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "analytic"=.\ANALYTIC.DSP - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "common"=..\common\common.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "test"=.\test.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name analytic + End Project Dependency + Begin Project Dependency + Project_Dep_Name common + End Project Dependency +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/analytic/test.ncb b/analytic/test.ncb new file mode 100644 index 0000000..aed4c46 Binary files /dev/null and b/analytic/test.ncb differ diff --git a/analytic/test.opt b/analytic/test.opt new file mode 100644 index 0000000..2cbb2b8 Binary files /dev/null and b/analytic/test.opt differ diff --git a/analytic/test.plg b/analytic/test.plg new file mode 100644 index 0000000..8b0ee20 --- /dev/null +++ b/analytic/test.plg @@ -0,0 +1,41 @@ + + +
+

Build Log

+

+--------------------Configuration: analytic - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\sean\LOCALS~1\Temp\RSP114.tmp" with contents +[ +/nologo /Gz /MTd /GX /Zi /O2 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "STRICT" /D "__FLAT__" /Fp".\msvcobj/ANALYTIC.pch" /YX /Fo".\msvcobj/" /Fd".\msvcobj/" /FD /c +"E:\work\analytic\portflio.cpp" +] +Creating command line "cl.exe @C:\DOCUME~1\sean\LOCALS~1\Temp\RSP114.tmp" +Creating command line "link.exe -lib /nologo /out:"..\exe\analytic.lib" .\msvcobj\Bond.obj .\msvcobj\Catmull.obj .\msvcobj\Coupon.obj .\msvcobj\Instrmnt.obj .\msvcobj\Money.obj .\msvcobj\Pairs.obj .\msvcobj\portflio.obj .\msvcobj\Zbond.obj " +

Output Window

+Compiling... +portflio.cpp +Creating library... +

+--------------------Configuration: test - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\sean\LOCALS~1\Temp\RSP115.tmp" with contents +[ +kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/test.pdb" /debug /machine:I386 /out:"Debug/test.exe" /pdbtype:sept +.\Debug\Test.obj +\work\exe\analytic.lib +\work\exe\mscommon.lib +] +Creating command line "link.exe @C:\DOCUME~1\sean\LOCALS~1\Temp\RSP115.tmp" +

Output Window

+Linking... + + + +

Results

+test.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/as68hc11/AS68HC11.PLG b/as68hc11/AS68HC11.PLG new file mode 100644 index 0000000..234c132 --- /dev/null +++ b/as68hc11/AS68HC11.PLG @@ -0,0 +1,60 @@ + + +
+

Build Log

+

+--------------------Configuration: as68hc11 - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP259.tmp" with contents +[ +/nologo /MTd /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "STRICT" /D "__FLAT__" /FR".\msvcobj/" /Fp".\msvcobj/as68hc11.pch" /YX /Fo".\msvcobj/" /Fd".\msvcobj/" /FD /c +"F:\as68hc11\Main.cpp" +] +Creating command line "cl.exe @C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP259.tmp" +Creating temporary file "C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP25A.tmp" with contents +[ +kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:yes /pdb:".\msvcobj/as68hc11.pdb" /debug /machine:I386 /out:".\msvcobj/as68hc11.exe" +.\msvcobj\asm6811.obj +.\msvcobj\Cacheblk.obj +.\msvcobj\Fmtlines.obj +.\msvcobj\instrctn.obj +.\msvcobj\Main.obj +.\msvcobj\mode.obj +.\msvcobj\Parse.obj +.\msvcobj\S19Generator.obj +.\msvcobj\Scan.obj +.\msvcobj\symbol.obj +.\msvcobj\Table.obj +\exe\mscommon.lib +] +Creating command line "link.exe @C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP25A.tmp" +

Output Window

+Compiling... +Main.cpp +Linking... +Creating temporary file "C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP25B.tmp" with contents +[ +/nologo /o".\msvcobj/as68hc11.bsc" +.\msvcobj\asm6811.sbr +.\msvcobj\Cacheblk.sbr +.\msvcobj\Fmtlines.sbr +.\msvcobj\instrctn.sbr +.\msvcobj\Main.sbr +.\msvcobj\mode.sbr +.\msvcobj\Parse.sbr +.\msvcobj\S19Generator.sbr +.\msvcobj\Scan.sbr +.\msvcobj\symbol.sbr +.\msvcobj\Table.sbr] +Creating command line "bscmake.exe @C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP25B.tmp" +Creating browse info file... +

Output Window

+ + + +

Results

+as68hc11.exe - 0 error(s), 0 warning(s) +
+ + diff --git a/as68hc11/AS68HC11.dsw b/as68hc11/AS68HC11.dsw new file mode 100644 index 0000000..c29369c --- /dev/null +++ b/as68hc11/AS68HC11.dsw @@ -0,0 +1,44 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "as68hc11"=.\as68hc11.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name common + End Project Dependency +}}} + +############################################################################### + +Project: "common"=..\COMMON\common.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/as68hc11/AS68HC11.mdp b/as68hc11/AS68HC11.mdp new file mode 100644 index 0000000..d772aad Binary files /dev/null and b/as68hc11/AS68HC11.mdp differ diff --git a/as68hc11/AS68HC11.ncb b/as68hc11/AS68HC11.ncb new file mode 100644 index 0000000..91b2db1 Binary files /dev/null and b/as68hc11/AS68HC11.ncb differ diff --git a/as68hc11/AS68HC11.opt b/as68hc11/AS68HC11.opt new file mode 100644 index 0000000..9145329 Binary files /dev/null and b/as68hc11/AS68HC11.opt differ diff --git a/as68hc11/ASM6811.HPP b/as68hc11/ASM6811.HPP new file mode 100644 index 0000000..f517a65 --- /dev/null +++ b/as68hc11/ASM6811.HPP @@ -0,0 +1,63 @@ +#ifndef _AS68HC11_M68ASSEMBLER_HPP_ +#define _AS68HC11_M68ASSEMBLER_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_OPENFILE_HPP_ +#include +#endif +#ifndef _COMMON_FILEMAP_HPP_ +#include +#endif +#ifndef _COMMON_PUREVIEWOFFILE_HPP_ +#include +#endif +#ifndef _COMMON_STDLIB_HPP_ +#include +#endif +#ifndef _AS68HC11_TABLE_HPP_ +#include +#endif +#ifndef _AS68HC11_SCAN_HPP_ +#include +#endif +#ifndef _AS68HC11_PARSE_HPP_ +#include +#endif + +class M68Assembler +{ +public: + M68Assembler(void); + virtual ~M68Assembler(); + bool assemble(const String &strPathFileName,const String &strPathOutFile,Block &includePath=Block()); + bool assemble(const String &strPathFileName,Block &includePath=Block()); + const String &strLastMessage(void)const; + DWORD codeSize(void)const; + DWORD lastLineNumber(void)const; +private: + enum{MaxScanBytes=128000,MaxParseBytes=512}; + M68Assembler(const M68Assembler &someM68Assembler); + M68Assembler &operator=(const M68Assembler &someM68Assembler); + bool operator==(const M68Assembler &someM68Assembler)const; + void createSymbolTable(Table &symbols); + void shuffle(Block &symbols); + bool generateCode(const String &strPathOutFile,PureViewOfFile &parseView,DWORD codeLength); + bool generateListing(const String &strPathOutFile,PureViewOfFile &parseView,DWORD codeLength); + bool generateS19(const String &strPathOutFile,PureViewOfFile &rawCode); + + Table mSymbolTable; + String mLastMessage; + DWORD mLastLineNumber; + DWORD mCodeSize; +}; + +inline +DWORD M68Assembler::codeSize(void)const +{ + return mCodeSize; +} +#endif \ No newline at end of file diff --git a/as68hc11/As68hc11.mak b/as68hc11/As68hc11.mak new file mode 100644 index 0000000..af43fdb --- /dev/null +++ b/as68hc11/As68hc11.mak @@ -0,0 +1,722 @@ +# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +!IF "$(CFG)" == "" +CFG=as68hc11 - Win32 Debug +!MESSAGE No configuration specified. Defaulting to as68hc11 - Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "as68hc11 - Win32 Release" && "$(CFG)" !=\ + "as68hc11 - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE on this makefile +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "as68hc11.mak" CFG="as68hc11 - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "as68hc11 - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "as68hc11 - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF +################################################################################ +# Begin Project +# PROP Target_Last_Scanned "as68hc11 - Win32 Debug" +RSC=rc.exe +MTL=mktyplib.exe +CPP=cl.exe + +!IF "$(CFG)" == "as68hc11 - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +OUTDIR=.\Release +INTDIR=.\Release + +ALL : "$(OUTDIR)\as68hc11.exe" + +CLEAN : + -@erase "$(INTDIR)\asm6811.obj" + -@erase "$(INTDIR)\Cacheblk.obj" + -@erase "$(INTDIR)\Fmtlines.obj" + -@erase "$(INTDIR)\instrctn.obj" + -@erase "$(INTDIR)\Main.obj" + -@erase "$(INTDIR)\mode.obj" + -@erase "$(INTDIR)\Parse.obj" + -@erase "$(INTDIR)\Scan.obj" + -@erase "$(INTDIR)\symbol.obj" + -@erase "$(INTDIR)\Table.obj" + -@erase "$(OUTDIR)\as68hc11.exe" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\ + /Fp"$(INTDIR)/as68hc11.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\Release/ +CPP_SBRS=.\. +# ADD BASE MTL /nologo /D "NDEBUG" /win32 +# ADD MTL /nologo /D "NDEBUG" /win32 +MTL_PROJ=/nologo /D "NDEBUG" /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/as68hc11.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /incremental:no\ + /pdb:"$(OUTDIR)/as68hc11.pdb" /machine:I386 /out:"$(OUTDIR)/as68hc11.exe" +LINK32_OBJS= \ + "$(INTDIR)\asm6811.obj" \ + "$(INTDIR)\Cacheblk.obj" \ + "$(INTDIR)\Fmtlines.obj" \ + "$(INTDIR)\instrctn.obj" \ + "$(INTDIR)\Main.obj" \ + "$(INTDIR)\mode.obj" \ + "$(INTDIR)\Parse.obj" \ + "$(INTDIR)\Scan.obj" \ + "$(INTDIR)\symbol.obj" \ + "$(INTDIR)\Table.obj" \ + "..\Exe\mscommon.lib" + +"$(OUTDIR)\as68hc11.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ELSEIF "$(CFG)" == "as68hc11 - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "msvcobj" +# PROP Intermediate_Dir "msvcobj" +# PROP Target_Dir "" +OUTDIR=.\msvcobj +INTDIR=.\msvcobj + +ALL : "$(OUTDIR)\as68hc11.exe" + +CLEAN : + -@erase "$(INTDIR)\asm6811.obj" + -@erase "$(INTDIR)\Cacheblk.obj" + -@erase "$(INTDIR)\Fmtlines.obj" + -@erase "$(INTDIR)\instrctn.obj" + -@erase "$(INTDIR)\Main.obj" + -@erase "$(INTDIR)\mode.obj" + -@erase "$(INTDIR)\Parse.obj" + -@erase "$(INTDIR)\Scan.obj" + -@erase "$(INTDIR)\symbol.obj" + -@erase "$(INTDIR)\Table.obj" + -@erase "$(INTDIR)\vc40.idb" + -@erase "$(INTDIR)\vc40.pdb" + -@erase "$(OUTDIR)\as68hc11.exe" + -@erase "$(OUTDIR)\as68hc11.ilk" + -@erase "$(OUTDIR)\as68hc11.pdb" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /Zp1 /MTd /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "STRICT" /D "__FLAT__" /YX /c +CPP_PROJ=/nologo /Zp1 /MTd /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\ + /D "STRICT" /D "__FLAT__" /Fp"$(INTDIR)/as68hc11.pch" /YX /Fo"$(INTDIR)/"\ + /Fd"$(INTDIR)/" /c +CPP_OBJS=.\msvcobj/ +CPP_SBRS=.\. +# ADD BASE MTL /nologo /D "_DEBUG" /win32 +# ADD MTL /nologo /D "_DEBUG" /win32 +MTL_PROJ=/nologo /D "_DEBUG" /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/as68hc11.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\ + advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\ + odbccp32.lib /nologo /subsystem:windows /incremental:yes\ + /pdb:"$(OUTDIR)/as68hc11.pdb" /debug /machine:I386\ + /out:"$(OUTDIR)/as68hc11.exe" +LINK32_OBJS= \ + "$(INTDIR)\asm6811.obj" \ + "$(INTDIR)\Cacheblk.obj" \ + "$(INTDIR)\Fmtlines.obj" \ + "$(INTDIR)\instrctn.obj" \ + "$(INTDIR)\Main.obj" \ + "$(INTDIR)\mode.obj" \ + "$(INTDIR)\Parse.obj" \ + "$(INTDIR)\Scan.obj" \ + "$(INTDIR)\symbol.obj" \ + "$(INTDIR)\Table.obj" \ + "..\Exe\mscommon.lib" + +"$(OUTDIR)\as68hc11.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +!ENDIF + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +################################################################################ +# Begin Target + +# Name "as68hc11 - Win32 Release" +# Name "as68hc11 - Win32 Debug" + +!IF "$(CFG)" == "as68hc11 - Win32 Release" + +!ELSEIF "$(CFG)" == "as68hc11 - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE=.\Table.cpp +DEP_CPP_TABLE=\ + {$(INCLUDE)}"\.\Instrctn.hpp"\ + {$(INCLUDE)}"\.\Mode.hpp"\ + {$(INCLUDE)}"\.\Symbol.hpp"\ + {$(INCLUDE)}"\.\Table.hpp"\ + {$(INCLUDE)}"\Bsptree\Bintree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.tpp"\ + {$(INCLUDE)}"\Bsptree\Treenode.hpp"\ + {$(INCLUDE)}"\Bsptree\Treenode.tpp"\ + {$(INCLUDE)}"\Common\Array.hpp"\ + {$(INCLUDE)}"\Common\Assert.hpp"\ + {$(INCLUDE)}"\Common\Block.hpp"\ + {$(INCLUDE)}"\Common\Block.tpp"\ + {$(INCLUDE)}"\Common\Except.hpp"\ + {$(INCLUDE)}"\Common\Fixup.hpp"\ + {$(INCLUDE)}"\Common\Pointer.hpp"\ + {$(INCLUDE)}"\Common\Pvector.hpp"\ + {$(INCLUDE)}"\Common\Pvector.tpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Types.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\Table.obj" : $(SOURCE) $(DEP_CPP_TABLE) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\instrctn.cpp +DEP_CPP_INSTR=\ + {$(INCLUDE)}"\.\Instrctn.hpp"\ + {$(INCLUDE)}"\.\Mode.hpp"\ + {$(INCLUDE)}"\Common\Array.hpp"\ + {$(INCLUDE)}"\Common\Except.hpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\instrctn.obj" : $(SOURCE) $(DEP_CPP_INSTR) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Main.cpp + +!IF "$(CFG)" == "as68hc11 - Win32 Release" + +DEP_CPP_MAIN_=\ + {$(INCLUDE)}"\.\asm6811.hpp"\ + {$(INCLUDE)}"\.\Cacheblk.hpp"\ + {$(INCLUDE)}"\.\codeptr.hpp"\ + {$(INCLUDE)}"\.\Emit.hpp"\ + {$(INCLUDE)}"\.\equate.hpp"\ + {$(INCLUDE)}"\.\Fixup.hpp"\ + {$(INCLUDE)}"\.\Label.hpp"\ + {$(INCLUDE)}"\.\labelgen.hpp"\ + {$(INCLUDE)}"\.\Parse.hpp"\ + {$(INCLUDE)}"\.\Psymbol.hpp"\ + {$(INCLUDE)}"\.\Psymbolc.hpp"\ + {$(INCLUDE)}"\.\Scan.hpp"\ + {$(INCLUDE)}"\.\Table.hpp"\ + {$(INCLUDE)}"\Bsptree\Bintree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.hpp"\ + {$(INCLUDE)}"\Common\Assert.hpp"\ + {$(INCLUDE)}"\Common\Block.hpp"\ + {$(INCLUDE)}"\Common\Block.tpp"\ + {$(INCLUDE)}"\Common\Except.hpp"\ + {$(INCLUDE)}"\Common\Filemap.hpp"\ + {$(INCLUDE)}"\Common\Filetime.hpp"\ + {$(INCLUDE)}"\Common\Openfile.hpp"\ + {$(INCLUDE)}"\Common\overlap.hpp"\ + {$(INCLUDE)}"\Common\Pointer.hpp"\ + {$(INCLUDE)}"\Common\Puredwrd.hpp"\ + {$(INCLUDE)}"\Common\Pvector.hpp"\ + {$(INCLUDE)}"\Common\Pview.hpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Systime.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\Main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "as68hc11 - Win32 Debug" + +DEP_CPP_MAIN_=\ + {$(INCLUDE)}"\.\asm6811.hpp"\ + {$(INCLUDE)}"\.\Cacheblk.hpp"\ + {$(INCLUDE)}"\.\codeptr.hpp"\ + {$(INCLUDE)}"\.\Emit.hpp"\ + {$(INCLUDE)}"\.\equate.hpp"\ + {$(INCLUDE)}"\.\Fixup.hpp"\ + {$(INCLUDE)}"\.\Instrctn.hpp"\ + {$(INCLUDE)}"\.\Label.hpp"\ + {$(INCLUDE)}"\.\labelgen.hpp"\ + {$(INCLUDE)}"\.\Mode.hpp"\ + {$(INCLUDE)}"\.\Parse.hpp"\ + {$(INCLUDE)}"\.\Psymbol.hpp"\ + {$(INCLUDE)}"\.\Psymbolc.hpp"\ + {$(INCLUDE)}"\.\Scan.hpp"\ + {$(INCLUDE)}"\.\Symbol.hpp"\ + {$(INCLUDE)}"\.\Table.hpp"\ + {$(INCLUDE)}"\Bsptree\Bintree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.tpp"\ + {$(INCLUDE)}"\Bsptree\Treenode.hpp"\ + {$(INCLUDE)}"\Bsptree\Treenode.tpp"\ + {$(INCLUDE)}"\Common\Array.hpp"\ + {$(INCLUDE)}"\Common\Assert.hpp"\ + {$(INCLUDE)}"\Common\Block.hpp"\ + {$(INCLUDE)}"\Common\Block.tpp"\ + {$(INCLUDE)}"\Common\Except.hpp"\ + {$(INCLUDE)}"\Common\Filemap.hpp"\ + {$(INCLUDE)}"\Common\Filetime.hpp"\ + {$(INCLUDE)}"\Common\Fixup.hpp"\ + {$(INCLUDE)}"\Common\Openfile.hpp"\ + {$(INCLUDE)}"\Common\overlap.hpp"\ + {$(INCLUDE)}"\Common\Pointer.hpp"\ + {$(INCLUDE)}"\Common\Puredwrd.hpp"\ + {$(INCLUDE)}"\Common\Pvector.hpp"\ + {$(INCLUDE)}"\Common\Pvector.tpp"\ + {$(INCLUDE)}"\Common\Pview.hpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Systime.hpp"\ + {$(INCLUDE)}"\Common\Types.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\Main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\mode.cpp +DEP_CPP_MODE_=\ + {$(INCLUDE)}"\.\Mode.hpp"\ + {$(INCLUDE)}"\Common\Stdio.hpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\mode.obj" : $(SOURCE) $(DEP_CPP_MODE_) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Parse.cpp + +!IF "$(CFG)" == "as68hc11 - Win32 Release" + +DEP_CPP_PARSE=\ + {$(INCLUDE)}"\.\Cacheblk.hpp"\ + {$(INCLUDE)}"\.\codeptr.hpp"\ + {$(INCLUDE)}"\.\Emit.hpp"\ + {$(INCLUDE)}"\.\equate.hpp"\ + {$(INCLUDE)}"\.\Fixup.hpp"\ + {$(INCLUDE)}"\.\Label.hpp"\ + {$(INCLUDE)}"\.\labelgen.hpp"\ + {$(INCLUDE)}"\.\Parse.hpp"\ + {$(INCLUDE)}"\.\Psymbol.hpp"\ + {$(INCLUDE)}"\.\Psymbolc.hpp"\ + {$(INCLUDE)}"\.\Scan.hpp"\ + {$(INCLUDE)}"\.\Table.hpp"\ + {$(INCLUDE)}"\Bsptree\Bintree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.hpp"\ + {$(INCLUDE)}"\Common\Assert.hpp"\ + {$(INCLUDE)}"\Common\Block.hpp"\ + {$(INCLUDE)}"\Common\Block.tpp"\ + {$(INCLUDE)}"\Common\Except.hpp"\ + {$(INCLUDE)}"\Common\Filemap.hpp"\ + {$(INCLUDE)}"\Common\Filetime.hpp"\ + {$(INCLUDE)}"\Common\Openfile.hpp"\ + {$(INCLUDE)}"\Common\overlap.hpp"\ + {$(INCLUDE)}"\Common\Pointer.hpp"\ + {$(INCLUDE)}"\Common\Puredwrd.hpp"\ + {$(INCLUDE)}"\Common\Pvector.hpp"\ + {$(INCLUDE)}"\Common\Pview.hpp"\ + {$(INCLUDE)}"\Common\Stdio.hpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Systime.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\Parse.obj" : $(SOURCE) $(DEP_CPP_PARSE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "as68hc11 - Win32 Debug" + +DEP_CPP_PARSE=\ + {$(INCLUDE)}"\.\Cacheblk.hpp"\ + {$(INCLUDE)}"\.\codeptr.hpp"\ + {$(INCLUDE)}"\.\Emit.hpp"\ + {$(INCLUDE)}"\.\equate.hpp"\ + {$(INCLUDE)}"\.\Fixup.hpp"\ + {$(INCLUDE)}"\.\Instrctn.hpp"\ + {$(INCLUDE)}"\.\Label.hpp"\ + {$(INCLUDE)}"\.\labelgen.hpp"\ + {$(INCLUDE)}"\.\Mode.hpp"\ + {$(INCLUDE)}"\.\Parse.hpp"\ + {$(INCLUDE)}"\.\Psymbol.hpp"\ + {$(INCLUDE)}"\.\Psymbolc.hpp"\ + {$(INCLUDE)}"\.\Scan.hpp"\ + {$(INCLUDE)}"\.\Symbol.hpp"\ + {$(INCLUDE)}"\.\Table.hpp"\ + {$(INCLUDE)}"\Bsptree\Bintree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.tpp"\ + {$(INCLUDE)}"\Bsptree\Treenode.hpp"\ + {$(INCLUDE)}"\Bsptree\Treenode.tpp"\ + {$(INCLUDE)}"\Common\Array.hpp"\ + {$(INCLUDE)}"\Common\Assert.hpp"\ + {$(INCLUDE)}"\Common\Block.hpp"\ + {$(INCLUDE)}"\Common\Block.tpp"\ + {$(INCLUDE)}"\Common\Except.hpp"\ + {$(INCLUDE)}"\Common\Filemap.hpp"\ + {$(INCLUDE)}"\Common\Filetime.hpp"\ + {$(INCLUDE)}"\Common\Fixup.hpp"\ + {$(INCLUDE)}"\Common\Openfile.hpp"\ + {$(INCLUDE)}"\Common\overlap.hpp"\ + {$(INCLUDE)}"\Common\Pointer.hpp"\ + {$(INCLUDE)}"\Common\Puredwrd.hpp"\ + {$(INCLUDE)}"\Common\Pvector.hpp"\ + {$(INCLUDE)}"\Common\Pvector.tpp"\ + {$(INCLUDE)}"\Common\Pview.hpp"\ + {$(INCLUDE)}"\Common\Stdio.hpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Systime.hpp"\ + {$(INCLUDE)}"\Common\Types.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\Parse.obj" : $(SOURCE) $(DEP_CPP_PARSE) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Scan.cpp +DEP_CPP_SCAN_=\ + {$(INCLUDE)}"\.\Emit.hpp"\ + {$(INCLUDE)}"\.\Instrctn.hpp"\ + {$(INCLUDE)}"\.\Mode.hpp"\ + {$(INCLUDE)}"\.\Scan.hpp"\ + {$(INCLUDE)}"\.\Symbol.hpp"\ + {$(INCLUDE)}"\.\Table.hpp"\ + {$(INCLUDE)}"\Bsptree\Bintree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.tpp"\ + {$(INCLUDE)}"\Bsptree\Treenode.hpp"\ + {$(INCLUDE)}"\Bsptree\Treenode.tpp"\ + {$(INCLUDE)}"\Common\Array.hpp"\ + {$(INCLUDE)}"\Common\Assert.hpp"\ + {$(INCLUDE)}"\Common\Block.hpp"\ + {$(INCLUDE)}"\Common\Block.tpp"\ + {$(INCLUDE)}"\Common\Except.hpp"\ + {$(INCLUDE)}"\Common\Filemap.hpp"\ + {$(INCLUDE)}"\Common\Fixup.hpp"\ + {$(INCLUDE)}"\Common\Pointer.hpp"\ + {$(INCLUDE)}"\Common\Puredwrd.hpp"\ + {$(INCLUDE)}"\Common\Pvector.hpp"\ + {$(INCLUDE)}"\Common\Pvector.tpp"\ + {$(INCLUDE)}"\Common\Pview.hpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Types.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\Scan.obj" : $(SOURCE) $(DEP_CPP_SCAN_) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\symbol.cpp +DEP_CPP_SYMBO=\ + {$(INCLUDE)}"\.\Instrctn.hpp"\ + {$(INCLUDE)}"\.\Mode.hpp"\ + {$(INCLUDE)}"\.\Symbol.hpp"\ + {$(INCLUDE)}"\Common\Array.hpp"\ + {$(INCLUDE)}"\Common\Except.hpp"\ + {$(INCLUDE)}"\Common\Stdio.hpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\symbol.obj" : $(SOURCE) $(DEP_CPP_SYMBO) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Cacheblk.cpp +DEP_CPP_CACHE=\ + {$(INCLUDE)}"\.\Cacheblk.hpp"\ + {$(INCLUDE)}"\.\Emit.hpp"\ + {$(INCLUDE)}"\.\Psymbol.hpp"\ + {$(INCLUDE)}"\.\Psymbolc.hpp"\ + {$(INCLUDE)}"\.\Scan.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.tpp"\ + {$(INCLUDE)}"\Bsptree\Treenode.hpp"\ + {$(INCLUDE)}"\Bsptree\Treenode.tpp"\ + {$(INCLUDE)}"\Common\Assert.hpp"\ + {$(INCLUDE)}"\Common\Block.hpp"\ + {$(INCLUDE)}"\Common\Block.tpp"\ + {$(INCLUDE)}"\Common\Except.hpp"\ + {$(INCLUDE)}"\Common\Filemap.hpp"\ + {$(INCLUDE)}"\Common\Fixup.hpp"\ + {$(INCLUDE)}"\Common\Pointer.hpp"\ + {$(INCLUDE)}"\Common\Puredwrd.hpp"\ + {$(INCLUDE)}"\Common\Pvector.hpp"\ + {$(INCLUDE)}"\Common\Pvector.tpp"\ + {$(INCLUDE)}"\Common\Pview.hpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Types.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\Cacheblk.obj" : $(SOURCE) $(DEP_CPP_CACHE) "$(INTDIR)" + + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=\Work\Exe\mscommon.lib + +!IF "$(CFG)" == "as68hc11 - Win32 Release" + +!ELSEIF "$(CFG)" == "as68hc11 - Win32 Debug" + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\asm6811.cpp + +!IF "$(CFG)" == "as68hc11 - Win32 Release" + +DEP_CPP_ASM68=\ + {$(INCLUDE)}"\.\asm6811.hpp"\ + {$(INCLUDE)}"\.\Cacheblk.hpp"\ + {$(INCLUDE)}"\.\codeptr.hpp"\ + {$(INCLUDE)}"\.\Emit.hpp"\ + {$(INCLUDE)}"\.\equate.hpp"\ + {$(INCLUDE)}"\.\Fixup.hpp"\ + {$(INCLUDE)}"\.\Fmtlines.hpp"\ + {$(INCLUDE)}"\.\Label.hpp"\ + {$(INCLUDE)}"\.\labelgen.hpp"\ + {$(INCLUDE)}"\.\Parse.hpp"\ + {$(INCLUDE)}"\.\Psymbol.hpp"\ + {$(INCLUDE)}"\.\Psymbolc.hpp"\ + {$(INCLUDE)}"\.\Scan.hpp"\ + {$(INCLUDE)}"\.\Table.hpp"\ + {$(INCLUDE)}"\Bsptree\Bintree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.hpp"\ + {$(INCLUDE)}"\Common\Assert.hpp"\ + {$(INCLUDE)}"\Common\Block.hpp"\ + {$(INCLUDE)}"\Common\Block.tpp"\ + {$(INCLUDE)}"\Common\Diskinfo.hpp"\ + {$(INCLUDE)}"\Common\Except.hpp"\ + {$(INCLUDE)}"\Common\Filemap.hpp"\ + {$(INCLUDE)}"\Common\Filetime.hpp"\ + {$(INCLUDE)}"\Common\Finddata.hpp"\ + {$(INCLUDE)}"\Common\Gdata.hpp"\ + {$(INCLUDE)}"\Common\Gdata.tpp"\ + {$(INCLUDE)}"\Common\Openfile.hpp"\ + {$(INCLUDE)}"\Common\overlap.hpp"\ + {$(INCLUDE)}"\Common\Pointer.hpp"\ + {$(INCLUDE)}"\Common\Puredwrd.hpp"\ + {$(INCLUDE)}"\Common\Pvector.hpp"\ + {$(INCLUDE)}"\Common\Pview.hpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Systime.hpp"\ + {$(INCLUDE)}"\Common\Types.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\asm6811.obj" : $(SOURCE) $(DEP_CPP_ASM68) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "as68hc11 - Win32 Debug" + +DEP_CPP_ASM68=\ + {$(INCLUDE)}"\.\asm6811.hpp"\ + {$(INCLUDE)}"\.\Cacheblk.hpp"\ + {$(INCLUDE)}"\.\codeptr.hpp"\ + {$(INCLUDE)}"\.\Emit.hpp"\ + {$(INCLUDE)}"\.\equate.hpp"\ + {$(INCLUDE)}"\.\Fixup.hpp"\ + {$(INCLUDE)}"\.\Fmtlines.hpp"\ + {$(INCLUDE)}"\.\Instrctn.hpp"\ + {$(INCLUDE)}"\.\Label.hpp"\ + {$(INCLUDE)}"\.\labelgen.hpp"\ + {$(INCLUDE)}"\.\Mode.hpp"\ + {$(INCLUDE)}"\.\Parse.hpp"\ + {$(INCLUDE)}"\.\Psymbol.hpp"\ + {$(INCLUDE)}"\.\Psymbolc.hpp"\ + {$(INCLUDE)}"\.\Scan.hpp"\ + {$(INCLUDE)}"\.\Symbol.hpp"\ + {$(INCLUDE)}"\.\Table.hpp"\ + {$(INCLUDE)}"\Bsptree\Bintree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.hpp"\ + {$(INCLUDE)}"\Bsptree\Btree.tpp"\ + {$(INCLUDE)}"\Bsptree\Treenode.hpp"\ + {$(INCLUDE)}"\Bsptree\Treenode.tpp"\ + {$(INCLUDE)}"\Common\Array.hpp"\ + {$(INCLUDE)}"\Common\Assert.hpp"\ + {$(INCLUDE)}"\Common\Block.hpp"\ + {$(INCLUDE)}"\Common\Block.tpp"\ + {$(INCLUDE)}"\Common\Diskinfo.hpp"\ + {$(INCLUDE)}"\Common\Except.hpp"\ + {$(INCLUDE)}"\Common\Filemap.hpp"\ + {$(INCLUDE)}"\Common\Filetime.hpp"\ + {$(INCLUDE)}"\Common\Finddata.hpp"\ + {$(INCLUDE)}"\Common\Fixup.hpp"\ + {$(INCLUDE)}"\Common\Gdata.hpp"\ + {$(INCLUDE)}"\Common\Gdata.tpp"\ + {$(INCLUDE)}"\Common\Openfile.hpp"\ + {$(INCLUDE)}"\Common\overlap.hpp"\ + {$(INCLUDE)}"\Common\Pointer.hpp"\ + {$(INCLUDE)}"\Common\Puredwrd.hpp"\ + {$(INCLUDE)}"\Common\Pvector.hpp"\ + {$(INCLUDE)}"\Common\Pvector.tpp"\ + {$(INCLUDE)}"\Common\Pview.hpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Systime.hpp"\ + {$(INCLUDE)}"\Common\Types.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\asm6811.obj" : $(SOURCE) $(DEP_CPP_ASM68) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\Fmtlines.cpp +DEP_CPP_FMTLI=\ + {$(INCLUDE)}"\.\Fmtlines.hpp"\ + {$(INCLUDE)}"\Common\Block.hpp"\ + {$(INCLUDE)}"\Common\Block.tpp"\ + {$(INCLUDE)}"\Common\Except.hpp"\ + {$(INCLUDE)}"\Common\Gdata.hpp"\ + {$(INCLUDE)}"\Common\Gdata.tpp"\ + {$(INCLUDE)}"\Common\Stdio.hpp"\ + {$(INCLUDE)}"\Common\Stdlib.hpp"\ + {$(INCLUDE)}"\Common\String.hpp"\ + {$(INCLUDE)}"\Common\Types.hpp"\ + {$(INCLUDE)}"\Common\Windows.hpp"\ + + +"$(INTDIR)\Fmtlines.obj" : $(SOURCE) $(DEP_CPP_FMTLI) "$(INTDIR)" + + +# End Source File +# End Target +# End Project +################################################################################ diff --git a/as68hc11/Asm6811.cpp b/as68hc11/Asm6811.cpp new file mode 100644 index 0000000..f07c7ae --- /dev/null +++ b/as68hc11/Asm6811.cpp @@ -0,0 +1,325 @@ +#include +#include +#include +#include +#include + +M68Assembler::M68Assembler(void) +: mLastLineNumber(0) +{ + createSymbolTable(mSymbolTable); +} + +M68Assembler::M68Assembler(const M68Assembler &someM68Assembler) +{ // private implementation + *this=someM68Assembler; +} + +M68Assembler::~M68Assembler() +{ +} + +M68Assembler &M68Assembler::operator=(const M68Assembler &/*someM68Assembler*/) +{ // private implementation + return *this; +} + +bool M68Assembler::operator==(const M68Assembler &/*someM68Assembler*/)const +{ // private implementation + return FALSE; +} + +const String &M68Assembler::strLastMessage(void)const +{ + return mLastMessage; +} + +DWORD M68Assembler::lastLineNumber(void)const +{ + return mLastLineNumber; +} + +void M68Assembler::createSymbolTable(Table &symbolTable) +{ + Block symbols; + + symbolTable.remove(); + + symbols.insert(&Symbol("aba",Scan::aba1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x1B)))); + symbols.insert(&Symbol("abx",Scan::abx1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3A)))); + symbols.insert(&Symbol("aby",Scan::aby1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3A,0x18)))); + symbols.insert(&Symbol("adca",Scan::adca1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x89),AddressMode(AddressMode::Direct,0x99),AddressMode(AddressMode::Extended,0xB9),AddressMode(AddressMode::Indexed,0xA9),AddressMode(AddressMode::Indexed,0xA9,0x18)))); + symbols.insert(&Symbol("adcb",Scan::adcb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC9),AddressMode(AddressMode::Direct,0xD9),AddressMode(AddressMode::Extended,0xF9),AddressMode(AddressMode::Indexed,0xE9),AddressMode(AddressMode::Indexed,0xE9,0x18)))); + symbols.insert(&Symbol("adda",Scan::adda1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x8B),AddressMode(AddressMode::Direct,0x9B),AddressMode(AddressMode::Extended,0xBB),AddressMode(AddressMode::Indexed,0xAB),AddressMode(AddressMode::Indexed,0xAB,0x18)))); + symbols.insert(&Symbol("addb",Scan::addb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xCB),AddressMode(AddressMode::Direct,0xDB),AddressMode(AddressMode::Extended,0xFB),AddressMode(AddressMode::Indexed,0xEB),AddressMode(AddressMode::Indexed,0xEB,0x18)))); + symbols.insert(&Symbol("addd",Scan::addd1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0xC3),AddressMode(AddressMode::Direct,0xD3),AddressMode(AddressMode::Extended,0xF3),AddressMode(AddressMode::Indexed,0xE3),AddressMode(AddressMode::Indexed,0xE3,0x18)))); + symbols.insert(&Symbol("anda",Scan::anda1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x84),AddressMode(AddressMode::Direct,0x94),AddressMode(AddressMode::Extended,0xB4),AddressMode(AddressMode::Indexed,0xA4),AddressMode(AddressMode::Indexed,0xA4,0x18)))); + symbols.insert(&Symbol("andb",Scan::andb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC4),AddressMode(AddressMode::Direct,0xD4),AddressMode(AddressMode::Extended,0xF4),AddressMode(AddressMode::Indexed,0xE4),AddressMode(AddressMode::Indexed,0xE4,0x18)))); + symbols.insert(&Symbol("asl",Scan::asl1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x78),AddressMode(AddressMode::Indexed,0x68),AddressMode(AddressMode::Indexed,0x68,0x18)))); + symbols.insert(&Symbol("asla",Scan::asla1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x48)))); + symbols.insert(&Symbol("aslb",Scan::aslb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x58)))); + symbols.insert(&Symbol("asld",Scan::asld1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x05)))); + symbols.insert(&Symbol("asr",Scan::asr1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x77),AddressMode(AddressMode::Indexed,0x67),AddressMode(AddressMode::Indexed,0x67,0x18)))); + symbols.insert(&Symbol("asra",Scan::asra1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x47)))); + symbols.insert(&Symbol("asrb",Scan::asrb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x57)))); + symbols.insert(&Symbol("bcc",Scan::bcc1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x24)))); + symbols.insert(&Symbol("bclr",Scan::bclr1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::DirectMask,0x15),AddressMode(AddressMode::IndexedMask,0x1D),AddressMode(AddressMode::IndexedMask,0x1D,0x18)))); + symbols.insert(&Symbol("bcs",Scan::bcs1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x25)))); + symbols.insert(&Symbol("beq",Scan::beq1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x27)))); + symbols.insert(&Symbol("bge",Scan::bge1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x2C)))); + symbols.insert(&Symbol("bgt",Scan::bgt1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x2E)))); + symbols.insert(&Symbol("bhi",Scan::bhi1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x22)))); + symbols.insert(&Symbol("bhs",Scan::bhs1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x24)))); + symbols.insert(&Symbol("bita",Scan::bita1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x85),AddressMode(AddressMode::Direct,0x95),AddressMode(AddressMode::Extended,0xB5),AddressMode(AddressMode::Indexed,0xA5),AddressMode(AddressMode::Indexed,0xA5,0x18)))); + symbols.insert(&Symbol("bitb",Scan::bitb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC5),AddressMode(AddressMode::Direct,0xD5),AddressMode(AddressMode::Extended,0xF5),AddressMode(AddressMode::Indexed,0xE5),AddressMode(AddressMode::Indexed,0xE5,0x18)))); + symbols.insert(&Symbol("ble",Scan::ble1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x2F)))); + symbols.insert(&Symbol("blo",Scan::blo1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x25)))); + symbols.insert(&Symbol("bls",Scan::bls1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x23)))); + symbols.insert(&Symbol("blt",Scan::blt1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x2D)))); + symbols.insert(&Symbol("bmi",Scan::bmi1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x2B)))); + symbols.insert(&Symbol("bne",Scan::bne1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x26)))); + symbols.insert(&Symbol("bpl",Scan::bpl1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x2A)))); + symbols.insert(&Symbol("bra",Scan::bra1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x20)))); + symbols.insert(&Symbol("brclr",Scan::brclr1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::DirectRelativeMask,0x13),AddressMode(AddressMode::IndexedRelativeMask,0x1F),AddressMode(AddressMode::IndexedRelativeMask,0x1F,0x18)))); + symbols.insert(&Symbol("brn",Scan::brn1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x21)))); + symbols.insert(&Symbol("brset",Scan::brset1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::DirectRelativeMask,0x12),AddressMode(AddressMode::IndexedRelativeMask,0x1E),AddressMode(AddressMode::IndexedRelativeMask,0x1E,0x18)))); + symbols.insert(&Symbol("bset",Scan::bset1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::DirectMask,0x14),AddressMode(AddressMode::IndexedMask,0x1C),AddressMode(AddressMode::IndexedMask,0x1C,0x18)))); + symbols.insert(&Symbol("bsr",Scan::bsr1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x8D)))); + symbols.insert(&Symbol("bvc",Scan::bvc1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x28)))); + symbols.insert(&Symbol("bvs",Scan::bvs1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Relative,0x29)))); + symbols.insert(&Symbol("cba",Scan::cba1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x11)))); + symbols.insert(&Symbol("clc",Scan::clc1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x0C)))); + symbols.insert(&Symbol("cli",Scan::cli1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x0E)))); + symbols.insert(&Symbol("clr",Scan::clr1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x7F),AddressMode(AddressMode::Indexed,0x6F),AddressMode(AddressMode::Indexed,0x6F,0x18)))); + symbols.insert(&Symbol("clra",Scan::clra1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x4F)))); + symbols.insert(&Symbol("clrb",Scan::clrb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x5F)))); + symbols.insert(&Symbol("clv",Scan::clv1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x0A)))); + symbols.insert(&Symbol("cmpa",Scan::cmpa1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x81),AddressMode(AddressMode::Direct,0x91),AddressMode(AddressMode::Extended,0xB1),AddressMode(AddressMode::Indexed,0xA1),AddressMode(AddressMode::Indexed,0xA1,0x18)))); + symbols.insert(&Symbol("cmpb",Scan::cmpb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC1),AddressMode(AddressMode::Direct,0xD1),AddressMode(AddressMode::Extended,0xF1),AddressMode(AddressMode::Indexed,0xE1),AddressMode(AddressMode::Indexed,0xE1,0x18)))); + symbols.insert(&Symbol("com",Scan::com1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x73),AddressMode(AddressMode::Indexed,0x63),AddressMode(AddressMode::Indexed,0x63,0x18)))); + symbols.insert(&Symbol("coma",Scan::coma1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x43)))); + symbols.insert(&Symbol("comb",Scan::comb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x53)))); + symbols.insert(&Symbol("cpd",Scan::cpd1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0x83,0x1A),AddressMode(AddressMode::Direct,0x93,0x1A),AddressMode(AddressMode::Extended,0xB3,0x1A),AddressMode(AddressMode::Indexed,0xA3,0x1A),AddressMode(AddressMode::Indexed,0xA3,0xCD)))); + symbols.insert(&Symbol("cpx",Scan::cpx1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0x8C),AddressMode(AddressMode::Direct,0x9C),AddressMode(AddressMode::Extended,0xBC),AddressMode(AddressMode::Indexed,0xAC),AddressMode(AddressMode::Indexed,0xAC,0xCD)))); + symbols.insert(&Symbol("cpy",Scan::cpy1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0x8C,0x18),AddressMode(AddressMode::Direct,0x9C,0x18),AddressMode(AddressMode::Extended,0xBC,0x18),AddressMode(AddressMode::Indexed,0xAC,0x1A),AddressMode(AddressMode::Indexed,0xAC,0x18)))); + symbols.insert(&Symbol("daa",Scan::daa1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x19)))); + symbols.insert(&Symbol("dec",Scan::dec1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x7A),AddressMode(AddressMode::Indexed,0x6A),AddressMode(AddressMode::Indexed,0x6A,0x18)))); + symbols.insert(&Symbol("deca",Scan::deca1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x4A)))); + symbols.insert(&Symbol("decb",Scan::decb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x5A)))); + symbols.insert(&Symbol("des",Scan::des1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x34)))); + symbols.insert(&Symbol("dex",Scan::dex1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x09)))); + symbols.insert(&Symbol("dey",Scan::dey1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x09,0x18)))); + symbols.insert(&Symbol("eora",Scan::eora1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x88),AddressMode(AddressMode::Direct,0x98),AddressMode(AddressMode::Extended,0xB8),AddressMode(AddressMode::Indexed,0xA8),AddressMode(AddressMode::Indexed,0xA8,0x18)))); + symbols.insert(&Symbol("eorb",Scan::eorb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC8),AddressMode(AddressMode::Direct,0xD8),AddressMode(AddressMode::Extended,0xF8),AddressMode(AddressMode::Indexed,0xE8),AddressMode(AddressMode::Indexed,0xE8,0x18)))); + symbols.insert(&Symbol("fdiv",Scan::fdiv1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x03)))); + symbols.insert(&Symbol("idiv",Scan::idiv1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x02)))); + symbols.insert(&Symbol("inc",Scan::inc1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x7C),AddressMode(AddressMode::Indexed,0x6C),AddressMode(AddressMode::Indexed,0x6C,0x18)))); + symbols.insert(&Symbol("inca",Scan::inca1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x4C)))); + symbols.insert(&Symbol("incb",Scan::incb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x5C)))); + symbols.insert(&Symbol("ins",Scan::ins1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x31)))); + symbols.insert(&Symbol("inx",Scan::inx1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x08)))); + symbols.insert(&Symbol("iny",Scan::iny1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x08,0x18)))); + symbols.insert(&Symbol("jmp",Scan::jmp1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x7E),AddressMode(AddressMode::Indexed,0x6E),AddressMode(AddressMode::Indexed,0x6E,0x18)))); + symbols.insert(&Symbol("jsr",Scan::jsr1,Symbol::KeywordSymbol,Instruction(4,Instruction::NotApplicable,AddressMode(AddressMode::Direct,0x9D),AddressMode(AddressMode::Extended,0xBD),AddressMode(AddressMode::Indexed,0xAD),AddressMode(AddressMode::Indexed,0xAD,0x18)))); + symbols.insert(&Symbol("ldaa",Scan::ldaa1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x86),AddressMode(AddressMode::Direct,0x96),AddressMode(AddressMode::Extended,0xB6),AddressMode(AddressMode::Indexed,0xA6),AddressMode(AddressMode::Indexed,0xA6,0x18)))); + symbols.insert(&Symbol("ldab",Scan::ldab1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC6),AddressMode(AddressMode::Direct,0xD6),AddressMode(AddressMode::Extended,0xF6),AddressMode(AddressMode::Indexed,0xE6),AddressMode(AddressMode::Indexed,0xE6,0x18)))); + symbols.insert(&Symbol("ldd",Scan::ldd1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0xCC),AddressMode(AddressMode::Direct,0xDC),AddressMode(AddressMode::Extended,0xFC),AddressMode(AddressMode::Indexed,0xEC),AddressMode(AddressMode::Indexed,0xEC,0x18)))); + symbols.insert(&Symbol("lds",Scan::lds1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0x8E),AddressMode(AddressMode::Direct,0x9E),AddressMode(AddressMode::Extended,0xBE),AddressMode(AddressMode::Indexed,0xAE),AddressMode(AddressMode::Indexed,0xAE,0x18)))); + symbols.insert(&Symbol("ldx",Scan::ldx1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0xCE),AddressMode(AddressMode::Direct,0xDE),AddressMode(AddressMode::Extended,0xFE),AddressMode(AddressMode::Indexed,0xEE),AddressMode(AddressMode::Indexed,0xEE,0xCD)))); + symbols.insert(&Symbol("ldy",Scan::ldy1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0xCE,0x18),AddressMode(AddressMode::Direct,0xDE,0x18),AddressMode(AddressMode::Extended,0xFE,0x18),AddressMode(AddressMode::Indexed,0xEE,0x1A),AddressMode(AddressMode::Indexed,0xEE,0x18)))); + symbols.insert(&Symbol("lsl",Scan::lsl1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x78),AddressMode(AddressMode::Indexed,0x68),AddressMode(AddressMode::Indexed,0x68,0x18)))); + symbols.insert(&Symbol("lsla",Scan::lsla1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x48)))); + symbols.insert(&Symbol("lslb",Scan::lslb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x58)))); + symbols.insert(&Symbol("lsld",Scan::lsld1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x05)))); + symbols.insert(&Symbol("lsr",Scan::lsr1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x74),AddressMode(AddressMode::Indexed,0x64),AddressMode(AddressMode::Indexed,0x64,0x18)))); + symbols.insert(&Symbol("lsra",Scan::lsra1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x44)))); + symbols.insert(&Symbol("lsrb",Scan::lsrb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x54)))); + symbols.insert(&Symbol("lsrd",Scan::lsrd1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x04)))); + symbols.insert(&Symbol("mul",Scan::mul1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3D)))); + symbols.insert(&Symbol("neg",Scan::neg1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x70),AddressMode(AddressMode::Indexed,0x60),AddressMode(AddressMode::Indexed,0x60,0x18)))); + symbols.insert(&Symbol("nega",Scan::nega1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x40)))); + symbols.insert(&Symbol("negb",Scan::negb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x50)))); + symbols.insert(&Symbol("nop",Scan::nop1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x01)))); + symbols.insert(&Symbol("oraa",Scan::oraa1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x8A),AddressMode(AddressMode::Direct,0x9A),AddressMode(AddressMode::Extended,0xBA),AddressMode(AddressMode::Indexed,0xAA),AddressMode(AddressMode::Indexed,0xAA,0x18)))); + symbols.insert(&Symbol("orab",Scan::orab1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xCA),AddressMode(AddressMode::Direct,0xDA),AddressMode(AddressMode::Extended,0xFA),AddressMode(AddressMode::Indexed,0xEA),AddressMode(AddressMode::Indexed,0xEA,0x18)))); + symbols.insert(&Symbol("psha",Scan::psha1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x36)))); + symbols.insert(&Symbol("pshb",Scan::pshb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x37)))); + symbols.insert(&Symbol("pshx",Scan::pshx1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3C)))); + symbols.insert(&Symbol("pshy",Scan::pshy1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3C,0x18)))); + symbols.insert(&Symbol("pula",Scan::pula1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x32)))); + symbols.insert(&Symbol("pulb",Scan::pulb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x33)))); + symbols.insert(&Symbol("pulx",Scan::pulx1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x38)))); + symbols.insert(&Symbol("puly",Scan::puly1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x38,0x18)))); + symbols.insert(&Symbol("rol",Scan::rol1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x79),AddressMode(AddressMode::Indexed,0x69),AddressMode(AddressMode::Indexed,0x69,0x18)))); + symbols.insert(&Symbol("rola",Scan::rola1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x49)))); + symbols.insert(&Symbol("rolb",Scan::rolb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x59)))); + symbols.insert(&Symbol("ror",Scan::ror1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x76),AddressMode(AddressMode::Indexed,0x66),AddressMode(AddressMode::Indexed,0x66,0x18)))); + symbols.insert(&Symbol("rora",Scan::rora1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x46)))); + symbols.insert(&Symbol("rorb",Scan::rorb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x56)))); + symbols.insert(&Symbol("rti",Scan::rti1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3B)))); + symbols.insert(&Symbol("rts",Scan::rts1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x39)))); + symbols.insert(&Symbol("sba",Scan::sba1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x10)))); + symbols.insert(&Symbol("sbca",Scan::sbca1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x82),AddressMode(AddressMode::Direct,0x92),AddressMode(AddressMode::Extended,0xB2),AddressMode(AddressMode::Indexed,0xA2),AddressMode(AddressMode::Indexed,0xA2,0x18)))); + symbols.insert(&Symbol("sbcb",Scan::sbcb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC2),AddressMode(AddressMode::Direct,0xD2),AddressMode(AddressMode::Extended,0xF2),AddressMode(AddressMode::Indexed,0xE2),AddressMode(AddressMode::Indexed,0xE2,0x18)))); + symbols.insert(&Symbol("sec",Scan::sec1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x0D)))); + symbols.insert(&Symbol("sei",Scan::sei1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x0F)))); + symbols.insert(&Symbol("sev",Scan::sev1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x0B)))); + symbols.insert(&Symbol("staa",Scan::staa1,Symbol::KeywordSymbol,Instruction(4,Instruction::SingleByte,AddressMode(AddressMode::Direct,0x97),AddressMode(AddressMode::Extended,0xB7),AddressMode(AddressMode::Indexed,0xA7),AddressMode(AddressMode::Indexed,0xA7,0x18)))); + symbols.insert(&Symbol("stab",Scan::stab1,Symbol::KeywordSymbol,Instruction(4,Instruction::SingleByte,AddressMode(AddressMode::Direct,0xD7),AddressMode(AddressMode::Extended,0xF7),AddressMode(AddressMode::Indexed,0xE7),AddressMode(AddressMode::Indexed,0xE7,0x18)))); + symbols.insert(&Symbol("std",Scan::std1,Symbol::KeywordSymbol,Instruction(4,Instruction::NotApplicable,AddressMode(AddressMode::Direct,0xDD),AddressMode(AddressMode::Extended,0xFD),AddressMode(AddressMode::Indexed,0xED),AddressMode(AddressMode::Indexed,0xED,0x18)))); + symbols.insert(&Symbol("stop",Scan::stop1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0xCF)))); + symbols.insert(&Symbol("sts",Scan::sts1,Symbol::KeywordSymbol,Instruction(4,Instruction::NotApplicable,AddressMode(AddressMode::Direct,0x9F),AddressMode(AddressMode::Extended,0xBF),AddressMode(AddressMode::Indexed,0xAF),AddressMode(AddressMode::Indexed,0xAF,0x18)))); + symbols.insert(&Symbol("stx",Scan::stx1,Symbol::KeywordSymbol,Instruction(4,Instruction::NotApplicable,AddressMode(AddressMode::Direct,0xDF),AddressMode(AddressMode::Extended,0xFF),AddressMode(AddressMode::Indexed,0xEF),AddressMode(AddressMode::Indexed,0xEF,0xCD)))); + symbols.insert(&Symbol("sty",Scan::sty1,Symbol::KeywordSymbol,Instruction(4,Instruction::NotApplicable,AddressMode(AddressMode::Direct,0xDF,0x18),AddressMode(AddressMode::Extended,0xFF,0x18),AddressMode(AddressMode::Indexed,0xEF,0x1A),AddressMode(AddressMode::Indexed,0xEF,0x18)))); + symbols.insert(&Symbol("suba",Scan::suba1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0x80),AddressMode(AddressMode::Direct,0x90),AddressMode(AddressMode::Extended,0xB0),AddressMode(AddressMode::Indexed,0xA0),AddressMode(AddressMode::Indexed,0xA0,0x18)))); + symbols.insert(&Symbol("subb",Scan::subb1,Symbol::KeywordSymbol,Instruction(5,Instruction::SingleByte,AddressMode(AddressMode::Immediate,0xC0),AddressMode(AddressMode::Direct,0xD0),AddressMode(AddressMode::Extended,0xF0),AddressMode(AddressMode::Indexed,0xE0),AddressMode(AddressMode::Indexed,0xE0,0x18)))); + symbols.insert(&Symbol("subd",Scan::subd1,Symbol::KeywordSymbol,Instruction(5,Instruction::DoubleByte,AddressMode(AddressMode::Immediate,0x83),AddressMode(AddressMode::Direct,0x93),AddressMode(AddressMode::Extended,0xB3),AddressMode(AddressMode::Indexed,0xA3),AddressMode(AddressMode::Indexed,0xA3,0x18)))); + symbols.insert(&Symbol("swi",Scan::swi1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3F)))); + symbols.insert(&Symbol("tab",Scan::tab1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x16)))); + symbols.insert(&Symbol("tap",Scan::tap1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x06)))); + symbols.insert(&Symbol("tba",Scan::tba1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x17)))); + symbols.insert(&Symbol("test",Scan::test1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x00)))); + symbols.insert(&Symbol("tpa",Scan::tpa1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x07)))); + symbols.insert(&Symbol("tst",Scan::tst1,Symbol::KeywordSymbol,Instruction(3,Instruction::NotApplicable,AddressMode(AddressMode::Extended,0x7D),AddressMode(AddressMode::Indexed,0x6D),AddressMode(AddressMode::Indexed,0x6D,0x18)))); + symbols.insert(&Symbol("tsta",Scan::tsta1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x4D)))); + symbols.insert(&Symbol("tstb",Scan::tstb1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x5D)))); + symbols.insert(&Symbol("tsx",Scan::tsx1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x30)))); + symbols.insert(&Symbol("tsy",Scan::tsy1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Indexed,0x30,0x18)))); + symbols.insert(&Symbol("txs",Scan::txs1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x35)))); + symbols.insert(&Symbol("tys",Scan::tys1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x35,0x18)))); + symbols.insert(&Symbol("wai",Scan::wai1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x3E)))); + symbols.insert(&Symbol("xgdx",Scan::xgdx1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x8F)))); + symbols.insert(&Symbol("xgdy",Scan::xgdy1,Symbol::KeywordSymbol,Instruction(1,Instruction::NotApplicable,AddressMode(AddressMode::Inherent,0x8F,0x18)))); + symbols.insert(&Symbol("ix",Scan::ix1,Symbol::RegisterSymbol)); + symbols.insert(&Symbol("iy",Scan::iy1,Symbol::RegisterSymbol)); + symbols.insert(&Symbol("org",Scan::origin1,Symbol::DirectiveSymbol)); + symbols.insert(&Symbol("equ",Scan::equ1,Symbol::DirectiveSymbol)); + symbols.insert(&Symbol("rmb",Scan::rmb1,Symbol::DirectiveSymbol)); + shuffle(symbols); + for(int index=0;index &symbols) +{ + int swapFrom; + int swapTo; + double ratio; + Symbol swapItem; + + if(!symbols.size())return; + ratio=((double)symbols.size()-1.00)/(double)RAND_MAX; + for(int index=0;index &includePath) +{ + String strPathOutFile(strPathFileName); + + strPathOutFile=strPathFileName.betweenString(0,'.'); + if(strPathOutFile==strPathFileName)return FALSE; + strPathOutFile+=String(".bin"); + return assemble(strPathFileName,strPathOutFile,includePath); +} + +bool M68Assembler::assemble(const String &strPathFileName,const String &strPathOutFile,Block &includePath) +{ + FileHandle inFile; + bool returnCode; + + mCodeSize=0; + if(!inFile.open(strPathFileName,FileHandle::Read,FileHandle::ShareRead))return FALSE; + FileMap inMap(inFile); + FileMap outMap("SCANOUT",0,MaxScanBytes); + FileMap parseMap("PARSEOUT",0,MaxParseBytes); + PureViewOfFile inView(inMap); + PureViewOfFile outView(outMap); + PureViewOfFile parseView(parseMap); + Scan scanner(inView,outView,mSymbolTable,includePath); + if(!scanner.analyze()) + { + mLastMessage=scanner.lastMessage(); + return returnCode=false; + } + outView.rewind(); + for(int index=0;index codeLines; + GlobalData codeBytes; + DiskInfo diskInfo; + + strPathHexFile=strPathOutFile.betweenString(0,'.'); + if(strPathHexFile==strPathOutFile)return false; + strPathHexFile+=".lst"; + diskInfo.unlink(strPathHexFile); + if(!codeLength)return FALSE; + codeBytes.size(codeLength); + ::memcpy((BYTE*)&codeBytes[0],(BYTE*)parseView.base(),codeLength); + formatLines.hexLines(codeLines,codeBytes); + if(!outFile.open(strPathHexFile,FileHandle::Write,FileHandle::ShareRead,FileHandle::Overwrite))return FALSE; + for(int index=0;index +#endif + +template +class MRUCache +{ +public: + enum{CacheLength=10}; + MRUCache(void); + virtual ~MRUCache(); + WORD isInCache(CacheItem &cacheItem); + void insert(CacheItem &cacheItem); + void clear(void); +private: + void pullCache(void); + + Block > mCacheBlock; +}; + +template +inline +MRUCache::MRUCache(void) +{ +} + +template +inline +MRUCache::~MRUCache() +{ +} + +template +inline +void MRUCache::clear(void) +{ + mCacheBlock.remove(); +} +#if defined(_MSC_VER) +#include +#endif +#endif diff --git a/as68hc11/CACHE.TPP b/as68hc11/CACHE.TPP new file mode 100644 index 0000000..a2a57e3 --- /dev/null +++ b/as68hc11/CACHE.TPP @@ -0,0 +1,39 @@ +#ifndef _AS68HC11_CACHE_TPP_ +#define _AS68HC11_CACHE_TPP_ + +template +WORD MRUCache::isInCache(CacheItem &cacheItem) +{ + for(short itemIndex=0;itemIndex +void MRUCache::insert(CacheItem &cacheItem) +{ + if(mCacheBlock.size()()); + pullCache(); + mCacheBlock[0]=cacheItem; + } + else + { + pullCache(); + mCacheBlock[0]=cacheItem; + } +} + +template +void MRUCache::pullCache(void) +{ + for(short itemIndex=mCacheBlock.size()-1;itemIndex>0;itemIndex--) + mCacheBlock[itemIndex]=mCacheBlock[itemIndex-1]; +} +#endif \ No newline at end of file diff --git a/as68hc11/CACHEBLK.CPP b/as68hc11/CACHEBLK.CPP new file mode 100644 index 0000000..f1b9bc9 --- /dev/null +++ b/as68hc11/CACHEBLK.CPP @@ -0,0 +1,43 @@ +#include +#include + +void CacheBlock::insert(Block &parseSymbols) +{ + for(int itemIndex=0;itemIndex parseSymbolNodePtr; + if(!searchItem(parseSymbolCount,parseSymbolNodePtr))return; + parseSymbolNodePtr->refCount(parseSymbolNodePtr->refCount()-1); + if(parseSymbolNodePtr->refCount()<0)parseSymbolNodePtr->refCount(0); +} + +BOOL CacheBlock::symbolIn(Scan::ScanSymbols scanSymbol) +{ + ParseSymbol parseSymbol(scanSymbol); + ParseSymbolCount parseSymbolCount(parseSymbol); + SmartPointer parseSymbolNodePtr; + if(!searchItem(parseSymbolCount,parseSymbolNodePtr))return FALSE; + return parseSymbolNodePtr->refCount(); +} + +void CacheBlock::insert(const ParseSymbol &parseSymbol) +{ + ParseSymbolCount parseSymbolCount(parseSymbol); + SmartPointer parseSymbolNodePtr; + if(!searchItem(parseSymbolCount,parseSymbolNodePtr)) + { + parseSymbolCount.refCount(1); + BTree::insert(parseSymbolCount); + } + else parseSymbolNodePtr->refCount(parseSymbolNodePtr->refCount()+1); +} + +void CacheBlock::remove(Block &parseSymbols) +{ + for(int itemIndex=0;itemIndex +#endif +#ifndef _AS68HC11_SCAN_HPP_ +#include +#endif + +class ParseSymbolCount; +class ParseSymbol; + +class CacheBlock : private BTree +{ +public: + CacheBlock(void); + virtual ~CacheBlock(); + void insert(const ParseSymbol &parseSymbol); + void insert(Block &parseSymbols); + void remove(const ParseSymbol &parseSymbol); + void remove(Block &parseSymbols); + BOOL symbolIn(Scan::ScanSymbols symbolValue); + DWORD size(void)const; +private: +}; + +inline +CacheBlock::CacheBlock(void) +{ +} + +inline +CacheBlock::~CacheBlock() +{ +} + +inline +DWORD CacheBlock::size(void)const +{ + return leaves(); +} +#endif \ No newline at end of file diff --git a/as68hc11/CACHEITM.HPP b/as68hc11/CACHEITM.HPP new file mode 100644 index 0000000..ce04180 --- /dev/null +++ b/as68hc11/CACHEITM.HPP @@ -0,0 +1,89 @@ +#ifndef _AS68HC11_CACHEITEM_HPP_ +#define _AS68HC11_CACHEITEM_HPP_ +#ifndef _COMMON_SMARTPOINTER_HPP_ +#include +#endif + +template +class CacheItem +{ +public: + CacheItem(void); + CacheItem(const CacheItem &someCacheItem); + virtual ~CacheItem(); + CacheItem &operator=(const CacheItem &someCacheItem); + WORD operator==(const CacheItem &someCacheItem)const; + const SmartPointer &cacheItem(void)const; + void cacheItem(const SmartPointer &cacheItem); + const T &cacheExtraInfo(void)const; + void cacheExtraInfo(const T &cacheExtraInfo); +private: + SmartPointer mCacheItem; + T mCacheExtraInfo; +}; + + +template +inline +CacheItem::CacheItem(void) +{ +} + +template +inline +CacheItem::CacheItem(const CacheItem &someCacheItem) +{ + *this=someCacheItem; +} + +template +inline +CacheItem::~CacheItem() +{ +} + +template +inline +CacheItem &CacheItem::operator=(const CacheItem &someCacheItem) +{ + mCacheItem=someCacheItem.mCacheItem; + mCacheExtraInfo=someCacheItem.mCacheExtraInfo; + return *this; +} + +template +inline +WORD CacheItem::operator==(const CacheItem &someCacheItem)const +{ + return (mCacheItem==someCacheItem.mCacheItem&& + mCacheExtraInfo==someCacheItem.mCacheExtraInfo); +} + +template +inline +const SmartPointer &CacheItem::cacheItem(void)const +{ + return mCacheItem; +} + +template +inline +void CacheItem::cacheItem(const SmartPointer &cacheItem) +{ + mCacheItem=cacheItem; +} + +template +inline +const T &CacheItem::cacheExtraInfo(void)const +{ + return mCacheExtraInfo; +} + +template +inline +void CacheItem::cacheExtraInfo(const T &cacheExtraInfo) +{ + mCacheExtraInfo=cacheExtraInfo; +} +#endif diff --git a/as68hc11/CODEPTR.HPP b/as68hc11/CODEPTR.HPP new file mode 100644 index 0000000..3f9b542 --- /dev/null +++ b/as68hc11/CODEPTR.HPP @@ -0,0 +1,125 @@ +#ifndef _AS68HC11_CODEPOINTER_HPP_ +#define _AS68HC11_CODEPOINTER_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif + +class CodePointer +{ +public: + CodePointer(void); + CodePointer(const CodePointer &someCodePointer); + CodePointer(DWORD origin,DWORD position); + virtual ~CodePointer(); + CodePointer &operator=(const CodePointer &someCodePointer); + BOOL operator==(const CodePointer &someCodePointer)const; + CodePointer &operator++(void); + CodePointer &operator++(int postFixDummy); + CodePointer &operator+=(DWORD value); + CodePointer &operator-=(DWORD value); + DWORD origin(void)const; + void origin(DWORD origin); + DWORD position(void)const; + void position(DWORD position); + void reset(void); +private: + DWORD mOrigin; + DWORD mPosition; +}; + +inline +CodePointer::CodePointer(void) +: mOrigin(0), mPosition(0) +{ +} + +inline +CodePointer::CodePointer(DWORD origin,DWORD position) +: mOrigin(origin), mPosition(position) +{ +} + +inline +CodePointer::CodePointer(const CodePointer &someCodePointer) +{ + *this=someCodePointer; +} + +inline +CodePointer::~CodePointer() +{ +} + +inline +CodePointer &CodePointer::operator=(const CodePointer &someCodePointer) +{ + origin(someCodePointer.origin()); + position(someCodePointer.position()); + return *this; +} + +inline +BOOL CodePointer::operator==(const CodePointer &someCodePointer)const +{ + return (origin()==someCodePointer.origin()&&position()==someCodePointer.position()); +} + +inline +CodePointer &CodePointer::operator++(void) +{ + position(position()+1); + return *this; +} + +inline +CodePointer &CodePointer::operator++(int postfixDummy) +{ + return operator++(); +} + +inline +CodePointer &CodePointer::operator+=(DWORD value) +{ + position(position()+value); + return *this; +} + +inline +CodePointer &CodePointer::operator-=(DWORD value) +{ + position(position()-value); + return *this; +} + +inline +DWORD CodePointer::origin(void)const +{ + return mOrigin; +} + +inline +void CodePointer::origin(DWORD origin) +{ + mOrigin=origin; + position(origin); +} + +inline +DWORD CodePointer::position(void)const +{ + return mPosition; +} + +inline +void CodePointer::position(DWORD position) +{ + mPosition=position; +} + +inline +void CodePointer::reset(void) +{ + origin(0); + position(0); +} +#endif \ No newline at end of file diff --git a/as68hc11/DOCS/S-RECORD.TXT b/as68hc11/DOCS/S-RECORD.TXT new file mode 100644 index 0000000..0d7ce54 --- /dev/null +++ b/as68hc11/DOCS/S-RECORD.TXT @@ -0,0 +1,361 @@ +S-Record Format + + A file in Motorola S-record format is an ASCII file. There are three different + formats: + + S19 for 16-bit address + S2 for 24-bit address + S3 for 32-bit address + + + The files consist of optional symbol table information, data specifications + for loading memory, and a terminator record. + + [ $$ {module_record} + symbol records + $$ [ module_record ] + symbol_records + $$] + header_record + data_records + record_count_record + terminator_record + + +Module Record (Optional) + + Each object file contains one record for each module that is a component of it. This + record contains the name of the module. There is one module record for each relocatable + object created by the assembler. The name of the relocatable object module + contained in the record comes from the IDNT directive. For absolute objects created + by the linker, there is one module record for each relocatable object file linked, + plus an additional record whose name comes from the NAME command for the + linker. + + Example: + + $$ MODNAME + + +Symbol Record (Optional) + + As many symbol records as needed can be contained in the object module. Up to 4 + symbols per line can be used, but it is not mandatory that each line contain 4 + symbols. A module can contain only symbol records. + + Example: + + APPLE $00000 LABEL1 $ODOC3 + MEM $OFFFF ZEEK $01947 + + The module name associated with the symbols can be specified in the + module_record preceding the symbol records. + + Example: + + $$MAIN + + Symbols are assumed to be in the module named in the preceding module_record + until another module is specified with another module_record. Symbols defined by + the linker's PUBLIC command appear following the first module record, which + indicates the name of the output object module specified by the linker's NAME + command. + + +***************************************************************************************** + +Header Record (SO) + + Each object module has exactly one header record with the following format: + + S00600004844521B + + Description: + + S0 Identifies the record as a header record + 06 The number of bytes following this one + 0000 The address field, which is ignored + 484452 The string HDR in ASCII + 1B The checksum + + + +***************************************************************************************** + +Data Record (S1) + + A data record specifies data bytes that are to be loaded into memory. Figure 1 + shows the format for such a record. The columns shown in the figure represent half + of a byte (4 bits). + + --------------------------------------------- + | 1 2 3 4 5 6 7 8 9 ... 40 41 42 | + | | + | S ID byte load data...data checksum | + | count address 1 n | + --------------------------------------------- + Figure 1: Data Record Formatter 16-Bit Load Address + + + Column Description + + 1 Contains the ASCII character S, which indicates the start of + a record in Motorola S-record format. + + 2 Contains the ASCII character identifying the record type. + For data records, this character is 1. + + 3 to 4 Contain the count of the number of bytes following this one + within the record. The count includes the checksum and the + load address bytes but not the byte count itself. + + 5 to 8 Contain the load address. The first data byte is to be loaded + into this address and subsequent bytes into the next sequential + address. Columns 5 and 6 contain the high-order address + byte, and columns 7 and 8 contain the low-order address byte. + + 9 to 40 Contain the specifications for up to 16 bytes of data. + + 41 to 42 Contain a checksum for the record. To calculate this, take the + sum of the values of all bytes from the byte count up to the + last data byte, inclusive, modulo 256. Subtract this result + from 255. + + +***************************************************************************************** + +Data Record (S2) + + + A data record specifies data bytes that are to be loaded into memory. Figure 2 + shows the format for such a record. The columns shown in the figure represent half + of a byte (4 bits). + + + ---------------------------------------------------- + | 1 2 3 4 5 6 7 8 9 10 11 ... 42 43 44 | + | | + | S ID byte load data...data checksum | + | count address 1 n | + ---------------------------------------------------- + Figure 2: Data Record Format for 24-Bit Load Address + + Column Description + + 1 Contains the ASCII character S, which indicates the start of + a record in Motorola S-record format. + + 2 Contains the ASCII character identifying the record type. + For data records, this character is 2. + + 3 to 4 Contain the count of the number of bytes following this one + within the record. The count includes the checksum and the + load address bytes but not the byte count itself. + + 5 to 10 Contain the load address. The first data byte is to be loaded + into this address and subsequent bytes into the next sequential + address. Columns 5 and 6 contain the high-order address + byte, and columns 9 and 10 contain the low-order address byte. + + 11 to 42 Contain the specifications for up to 16 bytes of data. + + 43 to 44 Contain a checksum for the record. To calculate this, take the + sum of the values of all bytes from the byte count up to the + last data byte, inclusive, modulo 256. Subtract this result + from 255. + + +***************************************************************************************** + +Data Record (S3) + + + A data record specifies data bytes that are to be loaded into memory. Figure 3 + shows the format for such a record. The columns shown in the figure represent half + of a byte (4 bits). + + ---------------------------------------------------------- + | 1 2 3 4 5 6 7 8 9 10 11 12 13 ... 44 45 46 | + | | + | S ID byte load data...data checksum | + | count address 1 n | + ---------------------------------------------------------- + Figure 3: Data Record Format for 32-Bit Load Address + + Column Description + + 1 Contains the ASCII character S, which indicates the start of + a record in Motorola S-record format. + + 2 Contains the ASCII character identifying the record type. + For data records, this digit is 3 for 32-bit addresses. + + 3 to 4 Contain the count of the number of bytes following this one + within the record. The count includes the checksum and the + load address bytes but not the byte count itself. + + 5 to 12 Contain the load address. The first data byte is to be loaded + into this address and subsequent bytes into the next sequential + address. Columns 5 and 6 contain the high-order address + byte, and columns 11 and 12 contain the low-order address byte. + + 13 to 44 Contain the specifications for up to 15 bytes of data. + + 45 to 46 Contain a checksum for the record. To calculate this, take the + sum of the values of all bytes from the byte count up to the + last data byte, inclusive, modulo 256. Subtract this result + from 255. + + +***************************************************************************************** + +Record Count Record (S5) + + + The record count record verifies the number of data records preceding it. Figure 4 + shows the format for such a record. The columns shown in the figure represent half + of a byte (4 bits). + + -------------------------------------- + | 1 2 3 4 5 6 7 8 9 10 | + | | + | S ID byte # of data checksum | + | count records | + -------------------------------------- + Figure 4: Record Count Record Format + + Column Description + + 1 Contains the ASCII character S, which indicates the start of + a record in Motorola S-record format. + + 2 Contains the ASCII character 5, which indicates a record + count record. + + 3 to 4 Contain the byte count, ASCII string 03. + + 5 to 8 Contain the number of data records in this file. The high- + order byte is in columns 5 and 6. + + 9 to 10 Contain the checksum for the record. + + Example: + + S503010DEE + + The example above shows a record count record indicating a total of 269 records + (0x010D) and a checksum of 0xEE. + + + +***************************************************************************************** + +Terminator Record for 32-bit address (S7) + + A terminator record specifies the end of the data records. Figure 5 shows the + format for such a record. The columns shown in the figure represent half of a byte + (4 bits). + + ------------------------------------- + | 1 2 3 4 5...12 13 14 | + | | + | S ID byte load checksum | + | count address | + ------------------------------------- + Figure5: Terminator Record Format for 32-Bit Load Address + + Column Description + + 1 Contains the ASCII character S, which indicates the start of + a record in Motorola S-record format. + + 2 Contains the ASCII character 7, which indicates a 32-bit + load address. + + 3 to 4 Contain the byte count, ASCII string 04. + + 5 to 12 Contain the load address that is either set to zero or to the + starting address specified in the END directive or START + command (there are no data bytes). + + 13 to 14 Contain the checksum for the record. + +***************************************************************************************** + +Terminator Record for 24-bit address (S8) + + + A terminator record specifies the end of the data records. Figure 6 shows the + format for such a record. The columns shown in the figure represent half of a byte + (4 bits). + + ---------------------------------------- + | 1 2 3 4 5 6 7 8 9 10 11 12 | + | | + | S ID byte load checksum | + | count address | + ---------------------------------------- + Figure 6: Terminator Record Format for 24-Bit Load Address + + Column Description + + 1 Contains the ASCII character S, which indicates the start of + a record in Motorola S-record format. + + 2 Contains the ASCII character 8, which indicates a 24-bit + load address. + + 3 to 4 Contain the byte count, ASCII string 04. + + 5 to 10 Contain the load address, which is either set to zero or to the + starting address specified in the END directive or START + command. There are no data bytes. + + 11 to 12 Contain the checksum for the record. + + Example: + + S804000AF0001 + + The previous example shows a terminator record with a 24-bit load address of + 0x000AF0 and a checksum of 0x01. + + +***************************************************************************************** + +Terminator Record for 16-bit address (S9) + + + A terminator record specifies the end of the data records. Figure 7 shows the + format for such a record. The columns shown in the figure represent half of a byte + (4 bits). + + ------------------------------------- + | 1 2 3 4 5 6 7 8 9 10 | + | | + | S ID byte load checksum | + | count address | + ------------------------------------- + Figure 7: Terminator Record Format for 16-Bit Load Address + + + Column Description + + 1 Contains the ASCII character S, which indicates the start of + a record in Motorola S-record format. + + 2 Contains the ASCII character 9, which indicates a 16-bit + load address. + + 3 to 4 Contain the byte count, ASCII string 04. + + 5 to 8 Contain the load address, which is either set to zero or to the + starting address specified in the END directive or START + command (there are no data bytes). + + 9 to 10 Contain the checksum for the record. + + + +***************************************************************************************** + hagen.v.tronje@on-line.de diff --git a/as68hc11/DOCS/S19.TXT b/as68hc11/DOCS/S19.TXT new file mode 100644 index 0000000..b989ef5 --- /dev/null +++ b/as68hc11/DOCS/S19.TXT @@ -0,0 +1,100 @@ + A brief explanation of the Motorola S19 file format. + +Motorola S19 file records are a text representation of Hexadecimal coded binary +data. All data uses only ASCII characters, so the format is portable across +virtually all computer platforms. The S19 format, described here, is for +eight bit data. + +(The '$' will be used throughout to indicate a hexadecimal value.) + +Each line in a Motorola S19 file is called a 'record'. Records always begin with a +the letter 'S', followed by a '1' if the record contains data, or a '9' if this +is the last record in the file. + +The next byte represents the number of bytes in this record, including the +starting address, data bytes, and the checksum. + +The next pair of numbers represent the 16-bit starting address of the data in +the record. This is the absolute location in the EPROM. + +Following the address are the hex representations of the data to be stored. + +The last byte is an eight-bit one's-complement checksum of all of the bytes in +the record (not including the S1). Note that this value is derived from the +binary values of the bytes, not the ASCII representation. + +A standard CR/LF pair (carriage return/linefeed, $0D $0A) terminates each line. + + +This a sample Motorola S19 record. + +S1130170707172737475767778797A7B7C7D7E7F03 + +Broken down, it looks as follows: + +S - Indicates that this is Motorola + +1 - 1 means this is a data record + +13 - Number of bytes to follow = $13, or 19 decimal. This number + can be thought of as the number of data bytes plus three. + Therefore there will be 16 data bytes in the record. + +0170 - Starting address in the EPROM for this record. + +70 - These are the data bytes (in hex) - 16 of them as noted above +71 The first byte ($70) will be stored at $0170, with the +72 remaining bytes following in sequence. +73 +74 +75 +76 +77 +78 +79 +7A +7B +7C +7D +7E +7F + +03 - This is the checksum. If you add all of the successive bytes + (note that the address is treated as two individual bytes) the + result is $7FC. Truncating this to eight bits yields $FC. The + one's complement of $FC is $06. (This may be derived by + subtracting $FC from $FF, or by inverting the bits.) + +(CR/LF) - End of this record -- I think the linefeed may be optional. + +The use of the starting address in each record makes it possible to store data +in non-contiguous areas of the EPROM. Each line of data is therefore entirely +self-contained. This is useful when areas of the EPROM are unused, as no space +in the Motorola S19 file need be wasted by representation of blank data. It is +perfectly possible, albeit not recommended, to scramble all of the record lines +in a Motorola S19 file and still end up with a correct EPROM image. + +The end record (end of file) is almost the same: + +S9030000FC + +S - Indicates that this is Motorola + +9 - 9 means this is the end record + +03 - Number of bytes - should be three, as no data bytes will be in + this record. + +0000 - Address, usually zero. + + - Zero data bytes here (obviously) + +FC - The checksum, calculated as above. + + +You may also see records starting with S0 - I believe these are called comment +records. They do not contain any data that will be stored in the EPROM. + +I hope this helps. + Sanjaya Vatuk 11/4/96 + sanjaya@concentric.net diff --git a/as68hc11/DOCS/SREC.TXT b/as68hc11/DOCS/SREC.TXT new file mode 100644 index 0000000..5de8ebf --- /dev/null +++ b/as68hc11/DOCS/SREC.TXT @@ -0,0 +1,447 @@ +S-Records + + + -S-Record Format- + + Chaplin@keinstr.uucp (Roger Chaplin) reposted an article written + by mcdchg!motmpl!ron (Ron Widell) that explained how Motorola + S-Records are formatted. This comes from a unix man page. No + mention of which version of Unix is specified. This section + of the FAQ is a bit long. An anonymous ftp archive is currently + being sought. When one is found, the section will be placed in + the archive. + + + SREC(4) UNIX 5.0 (03/21/84) SREC(4) + + + An S-record file consists of a sequence of specially formatted + ASCII character strings. An S-record will be less than or equal to + 78 bytes in length. + + The order of S-records within a file is of no significance and no + particular order may be assumed. + + The general format of an S-record follow: + + +------------------//-------------------//-----------------------+ + | type | count | address | data | checksum | + +------------------//-------------------//-----------------------+ + + type A char-2- field. These characters describe the + type of record (S0, S1, S2, S3, S5, S7, S8, or + S9). + count A char-2- field. These characters when paired and + interpreted as a hexadecimal value, display the + count of remaining character pairs in the record. + + address A char-4,6, or 8- field. These characters grouped + and interpreted as a hexadecimal value, display + the address at which the data field is to be + loaded into memory. The length of the field + depends on the number of bytes necessary to hold + the address. A 2-byte address uses 4 characters, + a 3-byte address uses 6 characters, and a 4-byte + address uses 8 characters. + data A char -0-64- field. These characters when paired + and interpreted as hexadecimal values represent + the memory loadable data or descriptive + information. + + checksum A char-2- field. These characters when paired and + interpreted as a hexadecimal value display the + least significant byte of the ones complement of + the sum of the byte values represented by the + pairs of characters making up the count, the + address, and the data fields. + + Each record is terminated with a line feed. If any + additional or different record terminator(s) or delay + characters are needed during transmission to the target + system it is the responsibility of the transmitting program + to provide them. + + S0 Record The type of record is 'S0' (0x5330). The address + + + field is unused and will be filled with zeros + (0x0000). The header information within the data + field is divided into the following subfields. + + mname is char-20- and is the + module name. + ver is char-2- and is the + version number. + + rev is char-2- and is the + revision number. + description is char-0-36- and is a + text comment. + + Each of the subfields is composed of ASCII bytes + whose associated characters, when paired, + represent one byte hexadecimal values in the case + of the version and revision numbers, or represent + the hexadecimal values of the ASCII characters + comprising the module name and description. + + S1 Record The type of record field is 'S1' (0x5331). The + address field is interpreted as a 2-byte address. + The data field is composed of memory loadable + data. + S2 Record The type of record field is 'S2' (0x5332). The + address field is interpreted as a 3-byte address. + The data field is composed of memory loadable + data. + + S3 Record The type of record field is 'S3' (0x5333). The + address field is interpreted as a 4-byte address. + The data field is composed of memory loadable + data. + S5 Record The type of record field is 'S5' (0x5335). The + address field is interpreted as a 2-byte value + and contains the count of S1, S2, and S3 records + previously transmitted. There is no data field. + + S7 Record The type of record field is 'S7' (0x5337). The + address field contains the starting execution + address and is interpreted as 4-byte address. + There is no data field. + S8 Record The type of record field is 'S8' (0x5338). The + address field contains the starting execution + address and is interpreted as 3-byte address. + There is no data field. + + S9 Record The type of record field is 'S9' (0x5339). The + address field contains the starting execution + address and is interpreted as 2-byte address. + There is no data field. + + EXAMPLE + + Shown below is a typical S-record format file. + + S00600004844521B + S1130000285F245F2212226A000424290008237C2A + S11300100002000800082629001853812341001813 + S113002041E900084E42234300182342000824A952 + S107003000144ED492 + S5030004F8 + S9030000FC + + The file consists of one S0 record, four S1 records, one S5 + record and an S9 record. + + The S0 record is comprised as follows: + + S0 S-record type S0, indicating it is a header + record. + 06 Hexadecimal 06 (decimal 6), indicating that six + character pairs (or ASCII bytes) follow. + + 00 00 Four character 2-byte address field, zeroes in + this example. + 48 ASCII H, D, and R - "HDR". + + 1B The checksum. + + The first S1 record is comprised as follows: + S1 S-record type S1, indicating it is a data record + to be loaded at a 2-byte address. + + 13 Hexadecimal 13 (decimal 19), indicating that + nineteen character pairs, representing a 2 byte + address, 16 bytes of binary data, and a 1 byte + checksum, follow. + 00 00 Four character 2-byte address field; hexidecimal + address 0x0000, where the data which follows is to + be loaded. + + 28 5F 24 5F 22 12 22 6A 00 04 24 29 00 08 23 7C Sixteen + character pairs representing the actual binary + data. + 2A The checksum. + + The second and third S1 records each contain 0x13 (19) + character pairs and are ended with checksums of 13 and 52, + respectively. The fourth S1 record contains 07 character + pairs and has a checksum of 92. + + The S5 record is comprised as follows: + + S5 S-record type S5, indicating it is a count record + indicating the number of S1 records. + + + + 03 Hexadecimal 03 (decimal 3), indicating that three + character pairs follow. + + 00 04 Hexadecimal 0004 (decimal 4), indicating that + there are four data records previous to this + record. + F8 The checksum. + + The S9 record is comprised as follows: + + S9 S-record type S9, indicating it is a termination + record. + 03 Hexadecimal 03 (decimal 3), indicating that three + character pairs follow. + + 00 00 The address field, hexadecimal 0 (decimal 0) + indicating the starting execution address. + FC The checksum. + + + -Intel Hex ASCII Format- + + Intel HEX-ASCII format takes the form: + + +----------------------------------- Start Character + | + | +-------------------------------- Byte Count + | | (# of data bytes) + | | + | | +-------------------------- Address of first data. + | | | + | | | +-------------------- Record Type (00 data, + | | | | 01 end of record) + | | | | + | | | | +------------ Data Bytes + | | | | | + | | | | | +---- Checksum + | | | | | | + | / \ / \ / \ / \ / \ + : B C A A A A T T H H ... H H C C + + An examples: + + :10000000DB00E60F5F1600211100197ED300C3004C + :1000100000000101030307070F0F1F1F3F3F7F7FF2 + :01002000FFE0 + :00000001FF + + This information comes from _Microprocessors and Programmed + Logic_, Second Edition, Kenneth L. Short, 1987, Prentice-Hall, + ISBN 0-13-580606-2. + + Provisions have been made for data spaces larger than 64 kBytes. + The above reference does not discuss them. I suspect there is + a start of segment type record, but I do not know how it is + implemented. + +---------------------------------------------------------------------------- + +/* This file contains source code to read a Motorola S-record file into +** a memory image. The size of the file cannot exceed BUFSIZE of data. +** The image is then written to disk either as binary data starting at +** address 0 with no data gaps, or as a C array of unsigned longs. +** Input lines must be no longer than MAXLINE. No check is made! +** +** Author: Eric McRae, Electro-Logic Machines, Inc. +** Date: Copyright 1994 +** +** This source code is made available to the public "as is". No +** warranty is given or implied for it's proper operation. This source +** code may be used in whole or in part as long as this copyright is +** included. +*/ +#include +#include +#include + +/* Comment the following line for non PC applications */ +#define PCDOS + +/* Uncomment the following line if you want a binary output instead of +** a structure +*/ +/* #define BINARY */ + +#ifdef PCDOS /* Intel x86 architecture */ +#define BUFSIZE 49152 /* 48K to avoid segment hopping */ +#else /* Any reasonable (non-segmented) arch... */ +#define BUFSIZE 65536 /* As big as you want */ +#endif + +#define MAXLINE 256 /* Length of longest input line + 1 */ +/* Globals */ +FILE *infilePH, *outfilePH; /* Handles for input and output files */ +unsigned char *bufAC, /* Allocated image buffer */ + *highestPC = NULL; /* Highest buffer address written */ + +/* Change this string to reflect the name of the output array */ +char headerAC[] = "unsigned long sRec[] =\n{\n"; + +/* Predeclarations */ +int parsebufN( char * ); /* Does the actual parsing */ + +void main(int argc, const char * argv[]) +{ + int c, /* Temp char storage */ + resN; /* result status */ + char *lbufPC, lbufAC[MAXLINE]; + int linectrN = 0; /* Used to correlate parse fail to input line */ + +#ifndef BINARY + int i; + unsigned long *codePL; + unsigned char *codePC; +#endif + + /* Check the argument count */ + if( argc != 3 ) /* If didn't specify input and output files */ + { + printf("Usage: %s: infile outfile\n", argv[0] ); + exit(1); + } + + /* OK, let's open some files */ + if( ( infilePH = fopen( argv[1], "r" ) )== NULL ) + { + printf("%s: Couldn't open input file %s\n", argv[0], argv[1] ); + exit(2); + } + + if( ( outfilePH = fopen( argv[2], "w" ) ) == NULL ) + { + printf("%s: Couldn't open output file %s\n", argv[0], argv[3] ); + exit(3); + } + + /* OK, get a buffer and clear it. */ + if( (bufAC = calloc( (size_t)BUFSIZE, (size_t)1 )) == NULL ) + { + printf("%s: Couldn't malloc memory for buffer\n", argv[0] ); + exit(4); + } + + lbufPC = lbufAC; /* Point at beginning of line buffer */ + while( c = fgetc( infilePH )) + { + if( (c == '\n') || (c == EOF) ) /* If found end of line or file */ + { /* Parse the Line */ + if( ( c == EOF ) && ( ferror( infilePH ) ) ) + { + printf("%s: Error reading input file\n", argv[0] ); + exit(5); + } + else + { /* OK, have a complete line in buffer */ + linectrN++; /* Increment line counter */ + if( lbufPC == lbufAC ) + break; /* ignore blank lines */ + *lbufPC = 0; /* Terminate the line string */ + if( resN = parsebufN( lbufAC ) ) /* Parse data record to mem */ + { + printf("%s: Error reading input file at line %d, return code = %d\n", + argv[0], linectrN, resN ); + exit( resN ); + } + lbufPC = lbufAC; /* Repoint line buffer pointer */ + } /* End of have a complete line */ + } + else + *lbufPC++ = c; /* Place char into line buffer */ + } + + /* At this point, the input file has been emptied. Now dispose of the + ** output data according to compilation mode. + */ + +#ifdef BINARY + + /* Write the buffer back to disk as a binary image */ + resN = fwrite( bufAC, 1, (size_t)((highestPC - bufAC) + 1), outfilePH ); + if( resN != (int)( (highestPC - bufAC) + 1) ) + { + printf("%s: Error writing output file\n", argv[0] ); + exit( 6 ); + } + +#else + /* Produce a file that can be included in a C program. Data is read + ** from buffer as bytes to avoid portability/endian problems with + ** this program. + */ + /* Output header first, then 1 long per line */ + fwrite( (void *)headerAC, 1, (size_t)(sizeof( headerAC )-1), outfilePH ); + + codePL = (unsigned long *)bufAC; + for( i = (highestPC - bufAC + 1) / 4; i; i-- ) /* for each long */ + { + codePC = (unsigned char *)codePL++; + sprintf(lbufAC, "0x%02x%02x%02x%02x%s", + *codePC, *(codePC + 1), *(codePC + 2), *(codePC + 3), + i == 1 ? "\n" : ",\n" ); /* No comma after final long */ + fwrite( lbufAC, 1, (size_t)(strlen( lbufAC )), outfilePH ); + } + /* OK, data has been written out, close end of array */ + fwrite( "};\n", 1, (size_t)3, outfilePH ); +#endif +} + +/* Function: parsebufV +** Parses an S-record in the buffer and writes it into the buffer +** if it is has a valid checksum. +** +** Args: pointer to character buffer for null terminated line +** Returns: int result code: 0 = success, else failure +*/ +int parsebufN( char *lbufPC ) +{ + unsigned long addrL; + unsigned char cksmB, /* checksum of addr, count, & data length */ + *bufPC; /* Pointer into memory array */ + int i, countN, /* Number of bytes represented in record */ + oheadN, /* Number of overhead (addr + chksum) bytes */ + tvalN; /* Temp for check checksum */ + + switch( *(lbufPC+1) ) /* examine 2nd character on the line */ + { + case '1': /* 16 bit address field */ + if( sscanf(lbufPC, "S1%2x%4lx", &countN, &addrL ) != 2 ) + return( 10 ); /* Flag error in S1 record */ + oheadN = 3; /* 2 address + 1 checksum */ + break; + + case '2': /* 24 bit address field */ + if( sscanf(lbufPC, "S2%2x%6lx", &countN, &addrL ) != 2 ) + return( 11 ); /* Flag error in S2 record */ + oheadN = 4; /* 3 address + 1 checksum */ + break; + + case '3': /* 32 bit address field */ + if( sscanf(lbufPC, "S3%2x%8lx", &countN, &addrL ) != 2 ) + return( 12 ); /* Flag error in S3 record */ + oheadN = 5; /* 4 address + 1 checksum */ + break; + + default: /* ignore all but S1,2,3 records. */ + return( 0 ); + } + + if( addrL > BUFSIZE ) return( 13 ); /* if address exceeds buffer size */ + bufPC = bufAC + addrL; /* otherwise, point to right spot in buffer */ + + /* OK now see if checksum is OK, while reading data to buffer */ + cksmB = 0; + countN++; /* Bump counter to read final checksum too */ + for( i = 1; i <= countN; i++ ) + { + sscanf( lbufPC + i*2, "%2x", &tvalN ); /* Scan a 2 hex digit byte */ + cksmB += (unsigned char)tvalN; + if( ( i > oheadN ) && ( i < countN ) ) /* If scanned a data byte */ + *bufPC++ = (unsigned char) tvalN; /* write it to the buffer */ + } + if( cksmB += 1 ) return( 14 ); /* flag checksum error */ + + if( (bufPC - 1) > highestPC ) + highestPC = bufPC - 1; /* track highest address loaded */ + + return( 0 ); /* Successful return */ +} + + + diff --git a/as68hc11/Emit.hpp b/as68hc11/Emit.hpp new file mode 100644 index 0000000..29a8350 --- /dev/null +++ b/as68hc11/Emit.hpp @@ -0,0 +1,237 @@ +#ifndef _AS68HC11_EMIT_HPP_ +#define _AS68HC11_EMIT_HPP_ +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_PUREVIEWOFFILE_HPP_ +#include +#endif +#ifndef _AS68HC11_CODEPOINTER_HPP_ +#include +#endif +#ifndef _AS68HC11_ORIGIN_HPP_ +#include +#endif + +class Emit +{ +public: + Emit(PureViewOfFile &inputView,PureViewOfFile &outputView); + Emit(PureViewOfFile &inputView,PureViewOfFile &outputView,const CodePointer &codePointer); + virtual ~Emit(); + void emit(const char *lpLiteralValue); + void emit(const String &literalValue); + void emit(int code,int type,int identifier); + void emit(int code); + void emit(int code,double value); + void emit(int code,int op); + void emit(BYTE value); + void emit(WORD value); + int peek(int &someInt); + int read(void); + int read(void *variable,size_t size); + int read(String &strLiteralString); + int read(int &someInt); + int read(double &someDouble); + int read(BYTE &value); + BYTE hiByte(DWORD value)const; + BYTE loByte(DWORD value)const; + void emitting(int); + int emitting(void)const; + PureViewOfFile &inputView(void); + PureViewOfFile &outputView(void); + CodePointer &codePointer(void); +private: + int mIsEmitting; + char mLastSymbol; + PureViewOfFile &mInputView; + PureViewOfFile &mOutputView; + CodePointer mCodePointer; +}; + +inline +Emit::Emit(PureViewOfFile &inputView,PureViewOfFile &outputView) +: mIsEmitting(true), mInputView(inputView), mOutputView(outputView) +{ +} + +inline +Emit::Emit(PureViewOfFile &inputView,PureViewOfFile &outputView,const CodePointer &codePointer) +: mIsEmitting(true), mInputView(inputView), mOutputView(outputView), mCodePointer(codePointer) +{ +} + +inline +Emit::~Emit() +{ +} + +inline +void Emit::emitting(int isEmitting) +{ + mIsEmitting=isEmitting; +} + +inline +int Emit::emitting(void)const +{ + return mIsEmitting; +} + +inline +int Emit::read(void) +{ + if(!mInputView.read((unsigned char&)mLastSymbol))return 0xFFFF; + return mLastSymbol; +} + +inline +int Emit::read(void *variable,size_t size) +{ + if(!mInputView.read((char*)variable,size))return 0xFFFF; + return 0; +} + +inline +int Emit::read(String &strLiteralString) +{ + String strLiteral; + int strLength; + + read(strLength); + strLiteral.reserve(strLength+1); + if(0xFFFF==read((char*)strLiteral,strLength))return 0xFFFF; + strLiteralString=strLiteral; + return 0; +} + +inline +int Emit::peek(int &someInt) +{ + if(!mInputView.peek(someInt))return 0xFFFF; + return 0; +} + +inline +int Emit::read(BYTE &value) +{ + if(!mInputView.read(value))return 0xFFFF; + return 0; +} + +inline +int Emit::read(int &someInt) +{ + if(!mInputView.read(someInt))return 0xFFFF; + return 0; +} + +inline +int Emit::read(double &someDouble) +{ + if(!mInputView.read(someDouble))return 0xFFFF; + return 0; +} + +inline +void Emit::emit(int code) +{ + if(!mIsEmitting)return; + mOutputView.write(code); + mCodePointer+=sizeof(code); +} + +inline +void Emit::emit(int code,int type,int identifier) +{ + if(!mIsEmitting)return; + mOutputView.write(code); + mOutputView.write(type); + mOutputView.write(identifier); + mCodePointer+=sizeof(code)+sizeof(type)+sizeof(identifier); +} + +inline +void Emit::emit(int code,double value) +{ + if(!mIsEmitting)return; + mOutputView.write(code); + mOutputView.write(value); + mCodePointer+=sizeof(code)+sizeof(value); +} + +inline +void Emit::emit(int code,int op) +{ + if(!mIsEmitting)return; + mOutputView.write(code); + mOutputView.write(op); + mCodePointer+=sizeof(code)+sizeof(op); +} + +inline +void Emit::emit(WORD value) +{ + if(!mIsEmitting)return; + mOutputView.write(hiByte(value)); + mOutputView.write(loByte(value)); + mCodePointer+=sizeof(value); +} + +inline +void Emit::emit(BYTE value) +{ + if(!mIsEmitting)return; + mOutputView.write(value); + mCodePointer+=sizeof(value); +} + +inline +void Emit::emit(const char *lpLiteralValue) +{ + if(!mIsEmitting||!lpLiteralValue)return; + String strLiteral(lpLiteralValue); + mOutputView.write(strLiteral); + mCodePointer+=strLiteral.length(); +} + +inline +void Emit::emit(const String &literalValue) +{ + if(!mIsEmitting)return; + int stringLength(literalValue.length()); + mOutputView.write(stringLength); + mOutputView.write(literalValue); + mCodePointer+=sizeof(stringLength)+stringLength; +} + +inline +BYTE Emit::hiByte(DWORD value)const +{ + return (BYTE)(((WORD)value)>>0x08); +} + +inline +BYTE Emit::loByte(DWORD value)const +{ + return (BYTE)value; +} + +inline +PureViewOfFile &Emit::inputView(void) +{ + return mInputView; +} + +inline +PureViewOfFile &Emit::outputView(void) +{ + return mOutputView; +} + +inline +CodePointer &Emit::codePointer(void) +{ + return mCodePointer; +} +#endif diff --git a/as68hc11/Equate.hpp b/as68hc11/Equate.hpp new file mode 100644 index 0000000..d069f16 --- /dev/null +++ b/as68hc11/Equate.hpp @@ -0,0 +1,113 @@ +#ifndef _AS68HC11_EQUATE_HPP_ +#define _AS68HC11_EQUATE_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif + +class Equate +{ +public: + enum Disposition{Absolute,Reference}; + Equate(void); + Equate(const Equate &someEquate); + Equate(const String &strLabel,DWORD value=0,Disposition disposition=Reference); + virtual ~Equate(); + Equate &operator=(const Equate &someEquate); + BOOL operator==(const Equate &someEquate)const; + BOOL operator<(const Equate &someEquate)const; + const String &strLabel(void)const; + void strLabel(const String &strLabel); + DWORD value(void)const; + void value(DWORD value); + Disposition disposition(void)const; + void disposition(Disposition disposition); +private: + String mStrLabel; + DWORD mValue; + Disposition mDisposition; +}; + +inline +Equate::Equate(void) +: mValue(0), mDisposition(Reference) +{ +} + +inline +Equate::Equate(const Equate &someEquate) +{ + *this=someEquate; +} + +inline +Equate::Equate(const String &strLabel,DWORD value,Disposition disposition) +: mStrLabel(strLabel), mValue(value), mDisposition(disposition) +{ +} + +inline +Equate::~Equate() +{ +} + +inline +Equate &Equate::operator=(const Equate &someEquate) +{ + strLabel(someEquate.strLabel()); + value(someEquate.value()); + disposition(someEquate.disposition()); + return *this; +} + +inline +BOOL Equate::operator==(const Equate &someEquate)const +{ + return (strLabel()==someEquate.strLabel()); +} + + +inline +BOOL Equate::operator<(const Equate &someEquate)const +{ + return (strLabel() +#include + +DWORD FormatLines::hexasciiLines(Block &lineStrings,GlobalData &globalData) +{ + Block asciiLines; + Block hexLines; + String tmpString; + DWORD lineCount; + + formatLines(asciiLines,globalData,HexCharsPerLine,ASCIILine); + formatLines(hexLines,globalData,HexCharsPerLine,HexLine); + lineCount=asciiLines.size(); + for(DWORD itemIndex=0;itemIndex &lineStrings,GlobalData &globalData,WORD charsPerLine,LineType lineType) +{ + DWORD byteCount(globalData.size()); + WORD charCount; + String charString; + String charLine; + BYTE charByte; + BYTE prevByte; + + if(!byteCount)return byteCount; + charCount=0; + for(DWORD itemIndex=0;itemIndex +#endif +#ifndef _COMMON_STRING_HPP_ +#include +#endif +#ifndef _COMMON_BLOCK_HPP_ +#include +#endif +#ifndef _COMMON_GLOBALDATA_HPP_ +#include +#endif + +class FormatLines +{ +public: + enum{HexCharsPerLine=0x10,ASCIICharsPerLine=0x20}; + FormatLines(void); + virtual ~FormatLines(); + DWORD hexLines(Block &lineStrings,GlobalData &globalData,WORD hexCharsPerLine=HexCharsPerLine); + DWORD asciiLines(Block &lineStrings,GlobalData &globalData,WORD asciiCharsPerLine=ASCIICharsPerLine); + DWORD hexasciiLines(Block &lineStrings,GlobalData &globalData); +private: + enum LineType{HexLine,ASCIILine}; + DWORD formatLines(Block &lineStrings,GlobalData &globalData,WORD charsPerLine,LineType lineType); +}; + +inline +FormatLines::FormatLines(void) +{ +} + +inline +FormatLines::~FormatLines() +{ +} + +inline +DWORD FormatLines::hexLines(Block &lineStrings,GlobalData &globalData,WORD hexCharsPerLine) +{ + return formatLines(lineStrings,globalData,hexCharsPerLine,HexLine); +} + +inline +DWORD FormatLines::asciiLines(Block &lineStrings,GlobalData &globalData,WORD asciiCharsPerLine) +{ + return formatLines(lineStrings,globalData,asciiCharsPerLine,ASCIILine); +} +#endif diff --git a/as68hc11/INSTRCTN.CPP b/as68hc11/INSTRCTN.CPP new file mode 100644 index 0000000..48f3a01 --- /dev/null +++ b/as68hc11/INSTRCTN.CPP @@ -0,0 +1,257 @@ +#include + +Instruction::operator String(void) +{ + String strInstruction; + + strInstruction.reserve(1024); + for(int index=0;index +#endif +#ifndef _COMMON_ARRAY_HPP_ +#include +#endif + +class Instruction : public Array +{ +public: + enum RegisterLength{SingleByte,DoubleByte,NotApplicable}; + Instruction(void); + Instruction(const Instruction &someInstruction); + Instruction(int count,RegisterLength registerLength=NotApplicable,...); + virtual ~Instruction(); + Instruction &operator=(const Instruction &someInstruction); + BOOL operator==(const Instruction &someInstruction)const; + operator String(void); + RegisterLength registerLength(void)const; + void registerLength(RegisterLength registerLength); + BOOL hasInherentMode(void)const; + BOOL hasImmediateMode(void)const; + BOOL hasDirectMode(void)const; + BOOL hasExtendedMode(void)const; + BOOL hasRelativeMode(void)const; + BOOL hasIndexedMode(void)const; + BOOL hasIndexedRelativeMaskMode(void)const; + BOOL hasDirectRelativeMaskMode(void)const; + BOOL hasRelativeMaskMode(void)const; + BOOL hasMaskMode(void)const; + BOOL hasPreByte(void)const; + BOOL hasInherentMode(WORD &indexForm)const; + BOOL hasImmediateMode(WORD &indexForm)const; + BOOL hasDirectMode(WORD &indexForm)const; + BOOL hasExtendedMode(WORD &indexForm)const; + BOOL hasRelativeMode(WORD &indexForm)const; + BOOL hasIndexedMode(WORD &indexForm)const; + BOOL hasIndexedRelativeMaskMode(WORD &indexForm)const; + BOOL hasDirectRelativeMaskMode(WORD &indexForm)const; + BOOL hasRelativeMaskMode(WORD &indexForm)const; + BOOL hasMaskMode(WORD &indexForm)const; + BOOL hasPreByte(WORD &indexForm)const; +private: + RegisterLength mRegisterLength; +}; + +inline +Instruction::Instruction(void) +: mRegisterLength(NotApplicable) +{ +} + +inline +Instruction::Instruction(int count,RegisterLength registerLength,...) +: mRegisterLength(registerLength) +{ + va_list varList; + + size(count); + va_start(varList,registerLength); + for(int index=0;index::operator[](index)=va_arg(varList,AddressMode); +} + +inline +Instruction::Instruction(const Instruction &someInstruction) +{ + *this=someInstruction; +} + +inline +Instruction::~Instruction() +{ +} + +inline +Instruction &Instruction::operator=(const Instruction &someInstruction) +{ + Array::operator=(someInstruction); + registerLength(someInstruction.registerLength()); + return *this; +} + +inline +BOOL Instruction::operator==(const Instruction &someInstruction)const +{ + return (Array::operator==(someInstruction)&& + registerLength()==someInstruction.registerLength()); +} + +inline +Instruction::RegisterLength Instruction::registerLength(void)const +{ + return mRegisterLength; +} + +inline +void Instruction::registerLength(RegisterLength registerLength) +{ + mRegisterLength=registerLength; +} +#endif \ No newline at end of file diff --git a/as68hc11/LIBASM68.PLG b/as68hc11/LIBASM68.PLG new file mode 100644 index 0000000..f18d408 --- /dev/null +++ b/as68hc11/LIBASM68.PLG @@ -0,0 +1,62 @@ + + +
+

Build Log

+

+--------------------Configuration: libasm68 - Win32 Debug-------------------- +

+

Command Lines

+Creating temporary file "C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP239.tmp" with contents +[ +/nologo /MTd /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "STRICT" /D "__FLAT__" /Fp".\msvcobj/libasm68.pch" /YX /Fo".\msvcobj/" /Fd".\msvcobj/" /FD /c +"F:\as68hc11\asm6811.cpp" +"F:\as68hc11\Cacheblk.cpp" +"F:\as68hc11\Fmtlines.cpp" +"F:\as68hc11\instrctn.cpp" +"F:\as68hc11\Main.cpp" +"F:\as68hc11\mode.cpp" +"F:\as68hc11\Parse.cpp" +"F:\as68hc11\S19Generator.cpp" +"F:\as68hc11\Scan.cpp" +"F:\as68hc11\symbol.cpp" +"F:\as68hc11\Table.cpp" +] +Creating command line "cl.exe @C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP239.tmp" +Creating temporary file "C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP23A.tmp" with contents +[ +/nologo /out:"..\exe\asm6811.lib" +.\msvcobj\asm6811.obj +.\msvcobj\Cacheblk.obj +.\msvcobj\Fmtlines.obj +.\msvcobj\instrctn.obj +.\msvcobj\Main.obj +.\msvcobj\mode.obj +.\msvcobj\Parse.obj +.\msvcobj\S19Generator.obj +.\msvcobj\Scan.obj +.\msvcobj\symbol.obj +.\msvcobj\Table.obj +] +Creating command line "link.exe -lib @C:\DOCUME~1\TERNET~1\LOCALS~1\Temp\RSP23A.tmp" +

Output Window

+Compiling... +asm6811.cpp +Cacheblk.cpp +Fmtlines.cpp +instrctn.cpp +Main.cpp +mode.cpp +Parse.cpp +S19Generator.cpp +Scan.cpp +symbol.cpp +Table.cpp +Creating library... + + + +

Results

+asm6811.lib - 0 error(s), 0 warning(s) +
+ + diff --git a/as68hc11/Labelgen.hpp b/as68hc11/Labelgen.hpp new file mode 100644 index 0000000..b6be519 --- /dev/null +++ b/as68hc11/Labelgen.hpp @@ -0,0 +1,72 @@ +#ifndef _AS68HC11_LABELGENERATOR_HPP_ +#define _AS68HC11_LABELGENERATOR_HPP_ +#ifndef _COMMON_WINDOWS_HPP_ +#include +#endif +#ifndef _BSPTREE_BINARYTREE_HPP_ +#include +#endif +#ifndef _AS68HC11_LABEL_HPP_ +#include +#endif + +class LabelGenerator : private BinaryTree