Function ADCSVR_Events(CtrlEntId, Event, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10) /******************************************************************************** *********************************************************************************/ #pragma precomp SRP_PreCompiler #Window ADCSVR $INSERT ENVIRON_CONSTANTS $INSERT LOGICAL EQU STOP$ TO 0 EQU START$ TO 1 EQU CRLF$ TO \0D0A\ ErrTitle = 'Error in Comm_Dialog_ADCSVR routine' DECLARE SUBROUTINE Center_Window, StatusLine, Set_Property, End_Dialog, Send_Event, Set_Status, Adios DECLARE SUBROUTINE ErrMsg, Send_Message, obj_Tables, Post_Event, ShowWindow, obj_ADCSVR, Yield, Utility DECLARE FUNCTION Get_Property, Get_Status, Dialog_Box, FindWindow GoToEvent Event for CtrlEntId Return RetVal else 1 ////////////////////////////////////////////////////////////////////////////// // Events ////////////////////////////////////////////////////////////////////////////// Event WINDOW.CREATE(CreateParam) Set_Status(0) otParms = 'SYSOBJ':@RM:'ADC_SERVER' obj_Tables('LockRec',otParms) ;* Places lock on fictional record IF Get_Status(errCode) THEN ErrorMsg = ErrTitle:@SVM:'Another ADC server is already running.' ErrMsg(ErrorMsg) Post_Event(@WINDOW,'CLOSE') end else Set_Property(@WINDOW,'@ADC_SERVER',STOP$) ;* Set ADC server property '@ADC_SERVER' to stop GoSub StartStop end end event Event WINDOW.TIMER() Yield(); Yield(); Yield(); Yield(); Yield(); Yield(); Yield(); Yield(); Yield() StartStop = Get_Property(@WINDOW,'@ADC_SERVER') IF (StartStop = START$) THEN obj_ADCSVR('MetrologyData','') END end event Event WINDOW.CLOSE(CancelFlag) otParms = 'SYSOBJ':@RM:'ADC_SERVER' obj_Tables('LockRec',otParms) ;* Places lock on fictional record Set_Status(0) obj_Tables('UnlockRec',otParms) ;* Removes lock on fictional record Utility('DESTROY', 'SYSTEM') end event Event START_STOP_BUTTON.CLICK() GoSub StartStop end event ////////////////////////////////////////////////////////////////////////////// // Internal GoSubs ////////////////////////////////////////////////////////////////////////////// ********** StartStop: ********** StartStop = Get_Property(@WINDOW:'.START_STOP_BUTTON','TEXT') IF (StartStop = 'Stop ADC Server') THEN * ADC server is running Set_Property(@WINDOW, 'TIMER', '') Set_Property(@WINDOW,'@ADC_SERVER',STOP$) ;* Turn off ADC server Set_Property(@WINDOW:'.START_STOP_BUTTON','TEXT', 'Start ADC Server') Set_Property(@WINDOW:'.CLOSE_BUTTON','ENABLED',1) END ELSE Interval = Get_Property(@Window : '.INTERVAL', 'INVALUE') If Interval EQ '' then Interval = 5 Set_Property(@WINDOW:'.INTERVAL','INVALUE',Interval) end Set_Property(@WINDOW, 'TIMER', Interval * 1000) ;* Set timer event to 5000 msecs (5 seconds) to check for shutdown time. Set_Property(@WINDOW:'.START_STOP_BUTTON','TEXT', 'Stop ADC Server') Set_Property(@WINDOW,'@ADC_SERVER',START$) ;* Start the ADC server process Set_Property(@WINDOW:'.CLOSE_BUTTON','ENABLED',0) END return