SDSlave

Previous  Next



SDSlave służy do tworzenia własnych modułów komunikacji typu slave.


graphic




Wzorzec skryptu Slave
DeviceLibrary\SDSlaveTemplate.tcl

  
#####################################
# DeviceLibrary\SDSlaveTemplate.tcl #
#                                   # 
# ScriptedDevice Slave Template     #
#                                   #                               
#####################################

# Set of procedures called during communication process
#####################################
# Called once when script starts

proc Iostartup { } {
  # configure Your driver here
  set cfg [ antIOGetDeviceConfig ]
  # cfg it is a list |devicename |name |iotype |value |address |value |timeout |value
  # You can use this settings in startup procedure
}
###################################
# Called once per each ioblock when scripts starts

proc Ioblockinitialize { block_name } {

# install waitable handlers for frames You expected
  antIOInstallWaitable $block_name verify_procedure
# Waitable Buffer Length s-length, default 65535
      antIOSetWaitableBufferLength s
 notify_procedure
}

###################################
# Called once per each ioblock when scripts exits

proc Ioblockuninitialize { block_name } {
}

###################################
# Called once when script exits

proc Ioshutdown { } {
}


################################################
# this procedure is called when any device input value changes

proc notifyIODeviceChannel { channel_name } {
}

################################################
# this procedure is called when any ioblock input value changes

proc Iowritechannels { block_name data } {
#data it is a list containing channel_name and value pairs
}

# the value of input channel is stored in the global variable, named as the channel

###################################
# Define Your verify and notify procedures

proc verify_procedure { frame } {
  #this function must return value 0 or 1.
  #1 means that received frame is valid
return 1
}

proc notify_procedure { frame } {
# called after verify_procedure returns 1
# Here You should receive data from frame and set channel values
  # antIOSetBlockChannel channel_name value
}