SDMaster

Previous  Next



SDMaster to moduł umożliwiający tworzenie własnego Mastera magistrali, który wysyła ramki z zapytaniami do urządzeń i przetwarza ramki z odpowiedziami.

graphic


Powyższa przykładowa konfiguracja przedstawia urządzenie SDevice0 zdefinionane na magistrali SBUSMaster, które może odpytywać urządzenie Slave o blok danych IOBlock0 w którym znajduje się jeden kanał.
Moduł zapewnia konfigurowalność oraz prowadzenie procesu komunikacji, natomiast po stronie użytkownika jest napisanie własnych procedur obsługujące podstawowe operacje wymiany danych.

Wzorzec skryptu Mastera
  
######################################
# DeviceLibrary\SDMasterTemplate.tcl #
#                                    #
# ScriptedDevice Master 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 notify_procedure

}

###################################
# Called once per each ioblock when scripts exits
proc Ioblockuninitialize { block_name } {
}

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

proc Ioshutdown { } {
}

###################################
# called when master ask slave about data

proc Ioreadchannels { block_name  } {
  # build frame
  # send frame and wait for good answer
  # set result [ antIOSerialExchange verify_procedure notify_procedure  frame timeout ]
  # when good answer not appears - throw exception  
}

###################################
# called when any data appears on input, answer frame from slave recognition

proc verify_procedure { frame } {
  # use regexp for quick frame examine
  #This function must return 0 or 1
  #1 means that frame is ok
  return 1
}

# when Verify_procedure returns 1 - process data

proc notify_procedure { frame } {
  # read frame and set block channel values
  # antIOSetBlockChannel channel_name value  
}

################################################
# called when it is time for write data to slave

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

proc Iowritechannel { channel_name } {
}

################################################
# after successful read of ioblock this method is called in order to process read channel values

proc notifyIOBlock { block_name } {
}

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

proc notifyIODeviceChannel { channel_name } {
}