########################################################################
### FILE: system.mod
### PUROPSE: Generic system functions
###
### Copyrights (C) 2006 Applied Biosystems. All rights reserved.
########################################################################
########################################################################
### MACRO: UPGRADE
### PURPOSE: Invoke the Upgrade Package SCPI Macro.
###
DEFine -asynchronous UPGRade
PUBLish Upgrade Starting Instrument Upgrade.
PUBLish Upgrade Validating Instrument Upgrade Package.
VAR result $(SYST:EXEC '/sbin/gpgVerify.sh')
IF $[ ${result:-0} > 0 ]
FILe:REMove -recursive UPGRADE:*
PUBLish Upgrade upgrade aborted GPG Validation Failure!
ERRor -id=InvalidSignature 'Failed to verify upgrade package signature!'
ELSe
PUBLish Upgrade Performing Instrument Upgrade.
MODule upgrade.mod
########################################################################
### MACRO: ClientCONFig, ClientCONFig?
### PURPOSE: Set and get key/value pairs for Client configurations
###
DEFine ClientCONFig $section$=default $key$ $value$
TRY
CONF+ client $section$
CONF= -createMissing client $section$ $key$ "$value$"
CONF= -createMissing client $section$ $key$ "$value$"
PUBLish Configuration cconf/$section$/$key$ = $value$
DEFine ClientCONFig? $section$=default $key$
RETurn $(CONF? client $section$ $key$)
DEFine ClientCONFig- $section$=default $key$
CONF- client $section$ $key$
PUBLish Configuration cconf/$section$/$key$ removed
########################################################################
### MACRO: UserCONFig, UserCONFig?
### PURPOSE: Set and get key/value pairs for users configurations
###
DEFine UserCONFig $user$=default $key$ $value$
TRY
CONF+ user $user$
CONF= -createMissing user $user$ $key$ "$value$"
CONF= -createMissing user $user$ $key$ "$value$"
PUBLish Configuration uconf/$user$/$key$ = $value$
DEFine UserCONFig? $user$=default $key$
RETurn $(CONF? user $user$ $key$)
DEFine UserCONFig- $user$=default $key$
CONF- user $user$ $key$
PUBLish Configuration uconf/$user$/$key$ removed
########################################################################
### MACRO: TIMe, TIMe?, TimeSync
### PURPOSE: Set/read system time, synchronize time w/subsystems
###
DEFine TIMe $seconds$
IF ${#RunTitle:-}
ERRor -id=TimeChangeDuringRun "Cannot change system time while a run is in progress"
SYSTem:TIMe $seconds$
TimeSync $seconds$
ALIas TIMe? SYSTem:TIMe?
VARiable TimeSync ""
DEFINT TimeSync $Time$=''
VAR time $[ int(float("$Time$" or time.time())) ]
RUN ${TimeSync}
DEFine ModeSwitchWait $applicationTypeRegister$=8 $node$ $mode$ $delay$
IF $[ "$mode$" not in "$(LLAC:TEXT? -size=4 $node$ $applicationTypeRegister$)" ]
WAIT $delay$
IF $[ "$mode$" not in "$(LLAC:TEXT? -size=4 $node$ $applicationTypeRegister$)" ]
ERRor "Unable to switch to $mode$ mode"
DEFine FirmWareUPgrade $appSwitchDelay$=2 $applicationTableRegister$=7 $applicationTypeRegister$=8 $firmwareResetControlRegister$=10 $bootDeviceBlockOffset$=1 $firmwareResetCommand$=1 $node$ $applicationType$ $file$
IF $[ "BOOT" not in "$(LLAC:TEXT? -size=4 $node$ $applicationTypeRegister$)" ]
LLAC:INT -size=2 $node$ $firmwareResetControlRegister$ $firmwareResetCommand$
ModeSwitchWait -applicationTypeRegister=$applicationTypeRegister$ $node$ BOOT $appSwitchDelay$
LVAR AppTableAddr $(LLAC:HEX? -size=2 $node$ $applicationTableRegister$)
LVAR BootTableAddr $(LLAC:HEX? -size=2 $node$ ${AppTableAddr})
LVAR BootDeviceBlock $(LLAC:HEX? -size=2 $node$ $[ ${BootTableAddr} + $bootDeviceBlockOffset$ ])
LLAC:FIRMWAREDOWNLOAD $node$ ${BootDeviceBlock} $file$
ModeSwitchWait -applicationTypeRegister=$applicationTypeRegister$ $node$ $applicationType$ $appSwitchDelay$
########################################################################
### MACROS: NICK=, NICK?
### PURPOSE: Set/get instrument nick name
SYStem:SETTing:ALIas NICK= :CONF= -createMissing server.ini server nickname
SYSTem:SETTing:ALIas NICK? :CONF? -default="-" server.ini server nickname