######################################################################## ### FILE: llacinit.mod ### PURPOSE: Low Level Auxillary Control setup ### AUTHOR: Tor Slettnes ### ### Copyrights (C) 2006 Applied Biosystems. All rights reserved. ######################################################################## ### Asynchronous Event Handler LLAC:EVENt+ Events -control=0x00 -controlMask=0x40 SET Message "-subsystem=$device$ -node=$source$" \ "-control=$control$ -severity=$severity$" \ "-id=$id$ -data=$0h$,$1h$,$2h$,$3h$ -text=\"$text$\"" PUBLish Event ${Message} LLAC:EVENT+ Warnings -control=0x10 -controlMask=0x70 PUBLish Warning "$device$ Warning $id$: $text$ (data=$0123h$)" LLAC:EVENT+ Errors -control=0x20 -controlmask=0x70 PUBLish Warning "$device$ Error $id$: $text$ (data=$0123h$)" LLAC:EVENT+ Fatals -control=0x30 -controlmask=0x70 PUBLish Error "$device$ Fatal Event $id$: $text$ (data=$0123h$)" IF $(STATE:EXISTS? $device$) SET id $device$.$[ "$id$"[2:] ] STATe:ERRor= $device$ ${id} "$text$ (data=$0123h$)" ### Synchronization event handler LLAC:EVENt+ LLACSync -id=0x0000 -idMask=0x8000 -control=0x00 -controlMask=0x40 PUBLish SyncEvent '-target=$target$ -id=$id$ -source=$source$ -control=$control$ -data=$0h$,$1h$,$2h$,$3h$' ### Registration event handler STATe:NEW LLAC:Registration LLAC:DEFINT DEVice+ $AppType$ $Node$ SET StateName LLAC:Registration:$AppType$ VAR $AppType$-Retries 0 UNLess $(:STATe:EXISTS? ${StateName}) :STATe:NEW ${StateName} :STATe:DEPendency+ LLAC:Registration -requires=${StateName} :STATe:TRIGGer+ -states=${StateName} -edge=Set LLACRegister INFO "Registering $AppType$ at node address $Node$" $AppType$+ $Node$ :STATe:TRIGGer+ -states=${StateName} -edge=Clear LLACUnregister INFO "Deregistering $AppType$ at node address $Node$" TRY '$AppType$- $Node$' \ 'WARNing "Unable to unregister $AppType$: [${error}] ${message}"' NEXT :STATe:SETTing ${StateName} True DEFINT BOOT+ $SourceNode$ INFO "Bootload handler for device $SourceNode$ -- not implemented yet" LLAC:EVENt+ LLACRegEvent -control=0x40 -controlMask=0x40 SET LLACVersion $01h$ SET TABLEOffset $23h$ SET DeviceType $(:LLAC:DEVice? -ignoreMissing $source$) UNLess ${#DeviceType} SET AppType $(:LLAC:TEXT? -nonprint="" $source 0x0008) IF $(:STATe:EXISTS? ${AppType:-.}) SET DeviceType $(:STATe:NAME? ${AppType}) :LLAC:DEVice= $source$ ${DeviceType} IF ${#DeviceType} :LLAC:DEVICE+ ${DeviceType} $source$ ### Send Registration Requests at regular intervals LLAC:SCHedule+ CheckRegistrations 2.0 ITERate -key=state $(:STATe:DEPendency* LLAC:Registration) SET Device $[ "${state}".split(":")[-1] ] SET RetryCounter ${Device}-Retries SET Retries ${${RetryCounter}:-0} IF ${Retries} SET LogMessage "RegistrationCheck: No response from ${Device} after ${Retries} requests" IF $[ ${Retries} < 3 ] WARNing "${LogMessage}; retrying..." ELIF $(:STATe:SETTing? -errorState=False ${state}) WARNing "${LogMessage}; deregistering!" :STATe:SETTing ${state} False ADDValue ${RetryCounter} 1 RegistrationRequest 0x81 ### TBC does not support broadcast address RegistrationRequest