GeoCOM Reference Manual 3. Fundamentals of Programming geoCOM 3.1.3 Modes of Operation Concerning Communication Section 3.5- TPS1 100 Instrument Modes of Operation-explains the different modes of operation of GeoCOM concerning communication. Similar to that the following is valid for the ASCiI protocol Since the client has to remind which mode is active, no support can be given from the tps 1100 instrument. The only way to distinguish between modes is to remind he actions an application has initiated and their resulting replies. So far no other possibility exists to determine the current mode To switch on the instrument a single character is sufficient. It is recommended to gnore the subsequent reply (one or two lines). Please note, that if the main menu is not selected as autoexec application, then the instrument will not switch into Remote mode, but will start the autoexec application (i.e. Electronic Level Measure Record, Setup or a loaded GeoBASIC or C application) instead. In the default configuration the autoexec selection is in the"Power On, Power off dialog in the"Instrument config. -menu When turning into local mode the TPS1100 instrument sends the"sign-on 8N1,0,255,,0器T0,0,0,:器R1P,0,0:0 If the"sign-off"message is enabled(see COM Enablesignoff)then the following message will be sent if the instrument goes into sleep mode 8N1,0,255,,0T0,0,0,:R1P,1,0:0,1 and the following message will be sent if the instrument shuts down 8N1,0,255,,0号T0,0,0,:器R1P,1,0:0,0 Please notice that these two messages are different in the last character 3.2 C/C++- PROGRAMMING rogramming in C/C++ is based on the well-known DLL concept, defined by microsoft Corp. To compile a project successfully first you have to include the file oubhpp, which defines all necessary constants, data types and function prototypes. Second gcom100.lib has to be included in the project, which enables the linker to resolve the DLL exported functions. To operate successfully the gcom100.dll file must be accessible for the operating system, hence it must be located in a directory which the operating system looks up for the requested DLL TPS1100-Version l01
GeoCOM Reference Manual 3 . Fundamentals of Programming GeoCOM TPS1100-Version 1.01 3-5 3.1.3 Modes of Operation Concerning Communication Section 3.5 - TPS1100 Instrument Modes of Operation - explains the different modes of operation of GeoCOM concerning communication. Similar to that the following is valid for the ASCII protocol. Since the client has to remind which mode is active, no support can be given from the TPS1100 instrument. The only way to distinguish between modes is to remind the actions an application has initiated and their resulting replies. So far no other possibility exists to determine the current mode. To switch on the instrument a single character is sufficient. It is recommended to ignore the subsequent reply (one or two lines). Please note, that if the main menu is not selected as autoexec application, then the instrument will not switch into Remote mode, but will start the autoexec application (i.e. Electronic Level, Measure & Record, Setup or a loaded GeoBASIC or C application) instead. In the default configuration the autoexec selection is in the “Power On, Power Off”- dialog in the “Instrument config.”-menu. When turning into local mode the TPS1100 instrument sends the “sign-on” message: “%N1,0,255,,0%T0,0,0,:%R1P,0,0:0”. If the “sign-off” message is enabled (see COM_EnableSignOff) then the following message will be sent if the instrument goes into sleep mode: “%N1,0,255,,0%T0,0,0,:%R1P,1,0:0,1”, and the following message will be sent if the instrument shuts down: “%N1,0,255,,0%T0,0,0,:%R1P,1,0:0,0”. Please notice that these two messages are different in the last character. 3.2 C/C++ - PROGRAMMING Programming in C/C++ is based on the well-known DLL concept, defined by Microsoft Corp. To compile a project successfully first you have to include the file com_pub.hpp, which defines all necessary constants, data types and function prototypes. Second gcom100.lib has to be included in the project, which enables the linker to resolve the DLL exported functions. To operate successfully the gcom100.dll file must be accessible for the operating system, hence it must be located in a directory which the operating system looks up for the requested DLL file
GeoCOM Reference Manual 3. Fundamentals of Programming geoCOM Project Options GCOM1O0 lib Structure byte-alignment 4 bytes Memory model Special #defines (if not using MFC)STRICT 3.2.1 Data Types in C/C++ Firmware is C/C++ all data types are initially defined in C/C++. Therefore, lnts ince the main programming language of implementation of TPS1100 instrume conversion of values or data types is necessary 3.2.2 Basic GeoCOM Application Frame for C/C++ A C/C++ GeoCOM application consists at least of the following parts Initialise GeoCOM Open a connection to the server One or more geocom rpc's Close the active connection to the server Finalise geoCOM sample implementation of above points could b nclude standard system headers #include " com pub. hpp include application headers #define retrIes 1 1 RC TYPE Recode BOOLE bOpenAndRunning FALSE OM BAUD RATE bAudrAte COM BAUD 19200 init Geo CoM encode if(RecOde = RC OK) // open a connection to the TPS1000 instrument Retcode COM OpenConnection COM 1, eBaudRate RETRIES 1) if (RecOde = RC OK) TPS1100-Version l01
GeoCOM Reference Manual 3 . Fundamentals of Programming GeoCOM TPS1100-Version 1.01 3-6 Project Options GCOM100.lib Structure byte-alignment 4 bytes Memory model N/A Special #defines (if not using MFC) STRICT 3.2.1 Data Types in C/C++ Since the main programming language of implementation of TPS1100 instruments Firmware is C/C++ all data types are initially defined in C/C++. Therefore, no conversion of values or data types is necessary. 3.2.2 Basic GeoCOM Application Frame for C/C++ A C/C++ GeoCOM application consists at least of the following parts: - Initialise GeoCOM - Open a connection to the server - One or more GeoCOM RPC’s - Close the active connection to the server - Finalise GeoCOM A sample implementation of above points could be: // include standard system headers #include "com_pub.hpp" // include application headers #define RETRIES_1 1 RC_TYPE RetCode; BOOLE bOpenAndRunning = FALSE; COM_BAUD_RATE eBaudRate = COM_BAUD_19200; // initialize GeoCOM RetCode = COM_Init(); if (RetCode == RC_OK) { // open a connection to the TPS1000 instrument RetCode = COM_OpenConnection ( COM_1, eBaudRate, RETRIES_1); if (RetCode == RC_OK) {
GeoCOM Reference Manual 3. Fundamentals of Programming geoCOM bOpenAndRunning TRUE // optionally set up other comm. parameters here if (Recode - functionality of the application here we just test if communication is up RecOde COM NullProc ( / handle error / close channel Retcode CoM CloseConnection ()i / handle error // anytime finalize and reset GeoCoM Recode COM End if(Recode RC OK) / handle erro 3.2.3 C/C++ Development System Support GeoCOM system files have been developed using Microsoft Visual C/C++ 5.0 Although this development environment were the basis for the current GeoCOM implementation, it has been emphasised that it is independent of it, hence other development environments can be used too. But please notice that it has not been TPS1100-Version l01
GeoCOM Reference Manual 3 . Fundamentals of Programming GeoCOM TPS1100-Version 1.01 3-7 bOpenAndRunning = TRUE; } } // optionally set up other comm. parameters here if (RetCode == RC_OK) { // -- functionality of the application -- // here we just test if communication is up RetCode = COM_NullProc(); if (RetCode != RC_OK) { // handle error } } // close channel if (bOpenAndRunning) { RetCode = COM_CloseConnection (); if (RetCode != RC_OK) { // handle error } } // anytime finalize and reset GeoCOM RetCode = COM_End(); if (RetCode != RC_OK) { // handle error } 3.2.3 C/C++ Development System Support GeoCOM system files have been developed using Microsoft Visual C/C++ 5.0. Although this development environment were the basis for the current GeoCOM implementation, it has been emphasised that it is independent of it, hence other development environments can be used too. But please notice that it has not been tested thoroughly so far
GeoCOM Reference Manual 3. Fundamentals of Programming geoCOM 3.2.4 Programming hints Order of Include statements Since GeoCOM redefines TRUE, FALSE and NULL we recommend the following include order. 1. Include system headers like stdio. h or stdafx. hpp 2. Include com pub. hpp 3. Include the current project headers BOOLE Definition GeoCOM defines its own Boolean type as an enumeration type of FALSE and TRUE. It is called BOOLE. With one exception, this does not produce any problems Only if a BooL type value will be assigned to a BoOLE type variable or parameter the compiler(MS-VisualC/C++)generates an error. To solve this problem the expression, which will be assigned to, has to be converted by a CAST statement to BOOLE 3.3 VBA-PROGRAMMING Similar to C/C++ programming the programming of VBa is based on the DLL concept. To enable access to GeoCOM the special module stubs 32p. bas has to included in the project. stubs 32p. bas includes all constants, data types and ction prototypes, which are available in GeoCOM 3.3.1 Data Types in VBA-General rules for derivation This subsection gives a summary of general derivation rules VBA-parameters fror C-data types. Basically the C/C++- data types are given in a C/C++ notation before they are used in a RPC-description If the appearance of a vba data type does not follow the general rules then they are described explicitly In general, the following rules can be applied Numerical data type The numerical data types correspond to the C/C++-parameters in value and range as close as possible. If it cannot be replaced directly then the best possible replacement will be taken TPS1100-Version l01
GeoCOM Reference Manual 3 . Fundamentals of Programming GeoCOM TPS1100-Version 1.01 3-8 3.2.4 Programming Hints Order of Include Statements Since GeoCOM redefines TRUE, FALSE and NULL we recommend the following include order: 1. Include system headers like stdio.h or stdafx.hpp 2. Include com_pub.hpp 3. Include the current project headers BOOLE Definition GeoCOM defines its own Boolean type as an enumeration type of FALSE and TRUE. It is called BOOLE. With one exception, this does not produce any problems. Only if a BOOL type value will be assigned to a BOOLE type variable or parameter the compiler (MS-VisualC/C++) generates an error. To solve this problem the expression, which will be assigned to, has to be converted by a CAST statement to BOOLE. 3.3 VBA – PROGRAMMING Similar to C/C++ programming the programming of VBA is based on the DLL concept. To enable access to GeoCOM the special module stubs32p.bas has to be included in the project. stubs32p.bas includes all constants, data types and function prototypes, which are available in GeoCOM. 3.3.1 Data Types in VBA - General rules for derivation This subsection gives a summary of general derivation rules VBA-parameters from C-data types. Basically the C/C++ - data types are given in a C/C++ notation before they are used in a RPC-description. If the appearance of a VBA data type does not follow the general rules then they are described explicitly. In general, the following rules can be applied: Numerical data type The numerical data types correspond to the C/C++-parameters in value and range as close as possible. If it cannot be replaced directly then the best possible replacement will be taken
GeoCOM Reference Manual 3. Fundamentals of Programming geoCOM String data type Character and string types are replaced by string data types. Since string data types of C/C++ and VBA are not directly interchangeable, the programmer has to take certain care of the necessary pre-and post processing of variables of this data type. Please refer to the example be Enumeration data type Conceptually vba does not have enumeration data types. Therefore, Long data types will be used instead. The enumeration values will be defined by enumeration values are reserved words in VBA. That is why we had e constants. Using the numerical value is also valid. Notice that some of the define different identifiers. Enumerated return values are numerical values and correspond to the position of the enumeration value in the C/C++- definition For clarification, also the numerical values are given in the description of an enumeration data type Structures and Arrays They are defined as in C/C++. Example for Enumeration Data Types and structures declaration usua ample gives the data type declaration and the procedure TMC GetsimpleMea from the subsystem Theodolite Measurement and Calculation) VBA-Declaration VB TMC GetSimpleMea( As Lond OnlyAngle V ANG slopeDistance A Mode As Long) In the file stubs 32p. bas the corresponding items are defined Global Const TMC MEA INC 0 Global Const TMC AUTO INC 1 Global Const TMC PLANE INC 2 Global Const TMC APRIORI INC 3 Global Const TMC ADJ INC 4 Global Const TMC REQUIRE INC 5 dv TPS1100-Version l01
GeoCOM Reference Manual 3 . Fundamentals of Programming GeoCOM TPS1100-Version 1.01 3-9 String data type Character and string types are replaced by string data types. Since string data types of C/C++ and VBA are not directly interchangeable, the programmer has to take certain care of the necessary pre- and postprocessing of variables of this data type. Please refer to the example below. Enumeration data type Conceptually VBA does not have enumeration data types. Therefore, Long data types will be used instead. The enumeration values will be defined by constants. Using the numerical value is also valid. Notice that some of the enumeration values are reserved words in VBA. That is why we had to define different identifiers. Enumerated return values are numerical values and correspond to the position of the enumeration value in the C/C++- definition. For clarification, also the numerical values are given in the description of an enumeration data type. Structures and Arrays They are defined as in C/C++. Example for Enumeration Data Types and Structures The following example gives the data type declaration and the procedure declaration usually used in this manual for an example procedure (TMC_GetSimpleMea from the subsystem Theodolite Measurement and Calculation): VBA-Declaration VB_TMC_GetSimpleMea( WaitTime As Long, OnlyAngle As TMC_HZ_V_ANG, SlopeDistance As Double, Mode As Long) In the file stubs32p.bas the corresponding items are defined: Global Const TMC_MEA_INC = 0 Global Const TMC_AUTO_INC = 1 Global Const TMC_PLANE_INC = 2 Global Const TMC_APRIORI_INC = 3 Global Const TMC_ADJ_INC = 4 Global Const TMC_REQUIRE_INC = 5 Type TMC_HZ_V_ANG dHz As Double dV As Double