GeoCOM Reference Manual 3. Fundamentals of Programming geoCOM End Type Obviously all enumeration values are encoded as global constants. The VBA structure definition equals to the C structure definition. A valid procedure call would be Dim wartIme As Long Dim OnlyAngle AS TMC HZ V ANG Dim SlopeDistance As Double Waitrime 1000 VB TMC GetSimpleMea( WaitTime OnlyAngle Slope Distance, TMC AUTO工NC) 3.3.2 Basic GeoCOM Application Frame for VBA Like in section 3.2.2- Basic GeoCOM Application Frame for C/C++-a VBA GeoCOM application consists at least of the following parts Initialise GeoCOM Open a connection to the serve Close the active connection to the server Finalise geoCOM A sample implementation of above points could be DIM RetCode As Integer M bOpenAndRunning as Integer initialize GeocoM bOpenAndRunning False Retcode VB COM Init If (RetCode RC OK) Then TPS1100-Version l01 3-10
GeoCOM Reference Manual 3 . Fundamentals of Programming GeoCOM TPS1100-Version 1.01 3-10 End Type Obviously all enumeration values are encoded as global constants. The VBA structure definition equals to the C structure definition. A valid procedure call would be: Dim WaitTime As Long Dim OnlyAngle As TMC_HZ_V_ANG Dim SlopeDistance As Double WaitTime = 1000 VB_TMC_GetSimpleMea( WaitTime, OnlyAngle, SlopeDistance, TMC_AUTO_INC) 3.3.2 Basic GeoCOM Application Frame for VBA Like in section 3.2.2 - Basic GeoCOM Application Frame for C/C++ - a VBA 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: CONST RETRIES_1 = 1 DIM RetCode As Integer DIM bOpenAndRunning as Integer ' initialize GeoCOM bOpenAndRunning = False RetCode = VB_COM_Init() If (RetCode = RC_OK) Then
GeoCOM Reference Manual 3. Fundamentals of Programming GeoCOM open a channel to the TPS1100 instrument Retcode VB COM OpenConnection(COM 1, COM BAUD 19200, RETRIES 1) If (Recode Rc OK)Then End if End if optionally set up other comm. parameters here If (RetCode RC OK) Then functionality of the application we just test if communication is up Retcode VB COM NullProc ( If (RetCode < RC OK) Then handle error End if End if If (bopenAndRunning)Then Retcode VB CoM CloseConnection ( RC OK) Then handle error End if i finalize and reset GeocoM Retcode VB COM End( If (RecOde RC OK) Then 3.3.3 VBA Development System Support This interface has been written for Microsoft Visual Basic for Applications 5.0 and higher only. Hence, no other development environment will be supported 3.3.4 Programming Hints Output Parameters of String Data Type TPS1100-Version l01 3-11
GeoCOM Reference Manual 3 . Fundamentals of Programming GeoCOM TPS1100-Version 1.01 3-11 ' open a channel to the TPS1100 instrument RetCode = VB_COM_OpenConnection(COM_1, COM_BAUD_19200, RETRIES_1) If (RetCode = RC_OK) Then bOpenAndRunning = True End If End If ' optionally set up other comm. parameters here If (RetCode = RC_OK) Then ' functionality of the application ' we just test if communication is up RetCode = VB_COM_NullProc() If (RetCode <> RC_OK) Then ' handle error End If End If If (bOpenAndRunning) Then ' close channel RetCode = VB_COM_CloseConnection () If (RetCode <> RC_OK) Then ' handle error End If End If ' finalize and reset GeoCOM RetCode = VB_COM_End() If (RetCode <> RC_OK) Then ' handle error End If 3.3.3 VBA Development System Support This interface has been written for Microsoft Visual Basic for Applications 5.0 and higher only. Hence, no other development environment will be supported. 3.3.4 Programming Hints Output Parameters of String Data Type
GeoCOM Reference manual 3. Fundamentals of Programming geoCOM The internal representation of strings is not directly compatible between C/C++ and VBA. Therefore the one has to pre-and post-process such an output parameter In the following example, we know that the output parameter will be less than 255 characters in length from the description of the RPC Dim s As String initialise string s= Space(255) Call VB COM GetErrorText(RC IVPARAM, s) trim string, justify string length s= Trims (s) Note: Incorrectly handled string output parameters may lead to severe runtime 3.4 UNITS OF VALUES All parameters are based on the SI unit definition, if not explicitly indicated differently. The SI units, and their derivatives, used are Abbreviation Unit Description Meters for lengths co-ordinates Radians angles Seconds for time Hekto Pascal for pressure celsius for temperature Table 3-2: SI Units 3.5 TPSI100 INSTRUMENT MODES OF OPERATION In respect to communication, the TPs1100 instrument knows several states in which it reacts differently. The main state for GeoCOM is online state or mode There it is possible to use all RPCS, which are described in this manual. Especially we will describe the possibilities of changing the state by the built-in RPC's. For the asCll protocol refer to section 3. 1.3-Modes of Operation Concerning TPS1100-Version l01
GeoCOM Reference Manual 3 . Fundamentals of Programming GeoCOM TPS1100-Version 1.01 3-12 The internal representation of strings is not directly compatible between C/C++ and VBA. Therefore the one has to pre- and post-process such an output parameter. In the following example, we know that the output parameter will be less than 255 characters in length from the description of the RPC. Dim s As String ' initialise string s = Space(255) Call VB_COM_GetErrorText(RC_IVPARAM, s) ' trim string, justify string length s = Trim$(s) Note: Incorrectly handled string output parameters may lead to severe runtime problems. 3.4 UNITS OF VALUES All parameters are based on the SI unit definition, if not explicitly indicated differently. The SI units, and their derivatives, used are: Abbreviation Unit Description m Meters for lengths, co-ordinates, ... rad Radians for angles sec Seconds for time hpa Hekto Pascal for pressure C Celsius for temperature Table 3-2: SI Units 3.5 TPS1100 INSTRUMENT MODES OF OPERATION In respect to communication, the TPS1100 instrument knows several states in which it reacts differently. The main state for GeoCOM is online state or mode. There it is possible to use all RPC’s, which are described in this manual. Especially we will describe the possibilities of changing the state by the built-in RPC’s. For the ASCII protocol refer to section 3.1.3 - Modes of Operation Concerning Communication
GeoCOM Reference manual 3. Fundamentals of Programming geoCOM The possible states can be described as follows e instrument is switched off and can be switched on and put into online mode by using CoM SwitchonTPS Local The instrument is in local mode geoCOM is not active hence. RPC's cannot be used To switch into online mode start the "Configuration menu on the instrument, open the submenu"Communication mode and select"GeoCOM On-Line mode"(in default configuration) Online so called Remote mode. The instrument accepts RPCS. COM Local can be used to switch into local mode. com Switchofftps will switch off the instrument or put it into sleep mode RCS The instrument accepts Remote Control sequences. This is not subject of this manual and will be described elsewhere GSI/Meas In this mode the user can measure coordinates and save the values onto the PC-Card GSI commands will be accepted in this mode. Since his is not subject of this manual this mode will not described here in more detail Either because of reaching the time out or by using the function COM Switchoff(COM TPS SLEEP) this state has been reached when starting from online mode. Only if the previous mode was online mode it can be switched back to it with COM SwitchonTPS(COM TPS REMOTE) 3.5.1 Getting Mode of Operation Concerning Communicati This is available only when the application uses the function call protocol. Hence a DLL is used to automate RPC calls. That is why the current implementation does not log the current state per default. Logging can be switched on by using COM Enablesignoff(TRUE). After enabling state changes to and from online mode will be logged and can be requested with CoM GetTPSState Note: The mode can be determined only if GeoCOM is active and the sign-off message is activated. In any other situation, CoM GetrPSState will yield the state COM TPS UNKNOWN TPS1100-Version l01 3-13
GeoCOM Reference Manual 3 . Fundamentals of Programming GeoCOM TPS1100-Version 1.01 3-13 The possible states can be described as follows: Off The instrument is switched off and can be switched on and put into online mode by using COM_SwitchOnTPS. Local The instrument is in local mode. GeoCOM is not active hence, RPC’s cannot be used. To switch into online mode start the “Configuration” menu on the instrument, open the submenu “Communication mode” and select “GeoCOM On-Line mode” (in default configuration). Online Also called Remote mode. The instrument accepts RPC’s. COM_Local can be used to switch into local mode. COM_SwitchOffTPS will switch off the instrument or put it into sleep mode. RCS The instrument accepts Remote Control sequences. This is not subject of this manual and will be described elsewhere. GSI/Meas In this mode the user can measure coordinates and save the values onto the PC-Card. GSI commands will be accepted in this mode. Since this is not subject of this manual this mode will not described here in more detail. Sleep Either because of reaching the time out or by using the function COM_SwitchOff(COM_TPS_SLEEP) this state has been reached when starting from online mode. Only if the previous mode was online mode it can be switched back to it with COM_SwitchOnTPS(COM_TPS_REMOTE). 3.5.1 Getting Mode of Operation Concerning Communication This is available only when the application uses the function call protocol. Hence a DLL is used to automate RPC calls. That is why the current implementation does not log the current state per default. Logging can be switched on by using COM_EnableSignOff(TRUE). After enabling state changes to and from online mode will be logged and can be requested with COM_GetTPSState. Note: The mode can be determined only if GeoCOM is active and the sign-off message is activated. In any other situation, COM_GetTPSState will yield the state COM_TPS_UNKNOWN
GeoCOM Reference manual 3. Fundamentals of Programming geoCOM The following picture shows the dependencies graphically. Instead of the correctly defined identifiers shortcuts have been used powe Switchoff(SHUT DOWN) ON/OFF-Key Switchon(REMOTE ON/OFF-Key if Localarex-set to RCS [FISetOnlineDlg9个 IFISetRcsDig旧 MeasRecor Meas Time Out/ KeyPress KeyPress SwitchOff (SLEEP SwitchOn(ONLINE) sends signOn message on arrival [FISetonline DIg modem can ces on which shows a dialog for switching to online default configuration [FSetRcsDIg System function which shows a dialog for switching to remote control mode Can be started with the RCs key in the "PROG the default configuration. event which causes the starting of the measurement Can be generated by pressing the mEAs key in the " Main menu on the default configuration. Picture 3-1 TPS1100 modes of operation in respect to communication TPS1100-Version l01 3-14
GeoCOM Reference Manual 3 . Fundamentals of Programming GeoCOM TPS1100-Version 1.01 3-14 The following picture shows the dependencies graphically. Instead of the correctly defined identifiers, shortcuts have been used. Picture 3-1 TPS1100 modes of operation in respect to communication Off Online RCS Local GSI/ Meas Sleep ON/OFF-Key [F]SetOnlineDlg TimeOut/ KeyPress [F]SetRcsDlg TimeOut/ KeyPres TimeOut/ KeyPress SwitchOn(REMOTE) Local() SwitchOn(ONLINE) SwitchOff(SLEEP) TimeOut/ KeyPress if enabled: sends SignOff message when leaving, sends SignOn message on arrival SwitchOff(SHUT_DOWN) Online [E]MeasRecord ON/OFF-Key if AUTOEXEC = Meas RPC which can change a state off active sleep power states ON/OFF-Key if prev. set to RCS System function which shows a dialog for switching to online mode. Can be started in "Communication mode" menu on the default configuration. [F]SetRcsDlg System function which shows a dialog for switching to remote control mode. Can be started with the RCS key in the "PROG" menu on the default configuration. [E]MeasRecord System event which causes the starting of the measurement dialog. Can be generated by pressing the MEAS key in the "Main" menu on the default configuration. [F]SetOnlineDlg