logo资料库

Tango manual 9.pdf

第1页 / 共267页
第2页 / 共267页
第3页 / 共267页
第4页 / 共267页
第5页 / 共267页
第6页 / 共267页
第7页 / 共267页
第8页 / 共267页
资料共267页,剩余部分请下载后查看
Introduction
Introduction to device server
Device server history
Getting Started
A C++ TANGO client
A TANGO device server
The commands and attributes code
The DevSimple command
The DevArray command
The DevString command
The DevStrArray command
The DevStruct command
The three attributes
The TANGO device server model
Introduction to CORBA
The model
The device
The commands
The TANGO attributes
The TANGO pipes
Command, attributes or pipes ?
The CORBA attributes
The remaining CORBA operations
The special case of the device state and status
The device polling
The server
The Tango Logging Service
The database
The controlled access
The Application Programmers Interfaces
Rules of the API
Communication between client and server using the API
Tango events
Writing a TANGO client using TANGO APIs
Introduction
Getting Started
Basic Philosophy
Data types
Request model
Synchronous model
Asynchronous model
Events
Introduction
Event definition
Event types
Event filtering (Removed in Tango release 8 and above)
Application Programmer's Interface
Configuring events
change
periodic
archive
C++ Clients
Subscribing to events
The CallBack class
Unsubscribing from an event
Extract buffered event data
Example
Group
Getting started with Tango group
Forward or not forward?
Executing a command
Obtaining command results
Case 1: a command, no argument
A few words on error handling and data extraction
Case 2: a command, one argument
Case 3: a command, several arguments
Reading attribute(s)
Obtaining attribute values
A few words on error handling and data extraction
Writing an attribute
Obtaining acknowledgement
Case 1: one value for all devices
Case 2: a specific value per device
Reading/Writing device pipe
Reading a pipe
Extracting data with pipe content prior knowledge
Extracting data in a generic way (without prior knowledge)
Error management
Writing a pipe
Error management
Device locking
Reconnection and exception
Thread safety
Compiling and linking a Tango client
TangoATK Programmer's Guide
Introduction
Assumptions
The key concepts of TangoATK
Minimize development time
Minimize bugs in applications
Attributes and commands from different devices
Avoid code duplication
The real getting started
Single device applications
Multi device applications
More on displaying attributes
Connecting an attribute to a viewer
Synoptic viewer
A short note on the relationship between models and viewers
Listeners
The key objects of TangoATK
The Refreshers
What happens on a refresh
The DeviceFactory
The AttributeFactory and the CommandFactory
The AttributeList and the CommandList
The Attributes
The hierarchy
The Commands
Events and listeners
Writing a TANGO device server
The device server framework
Naming convention and programming language
The device pattern
The Tango base class (DeviceImpl class)
Description
Contents
The DbDevice class
The Command class
Description of the inheritance model
Description of the template model
Contents
The DeviceClass class
Description
Contents
The DbClass class
The MultiAttribute class
Description
Contents
The Attribute class
Description
Contents
The WAttribute class
Description
Contents
The Attr class
The SpectrumAttr class
The ImageAttr class
The StepperMotor class
Description
Definition
The StepperMotorClass class
Description
Definition
The DevReadPosition class
Description
Definition
The PositionAttr class
Description
Definition
Startup of a device pattern
Command execution sequence
The automatically added commands
Reading/Writing attributes
Reading attributes
Writing attributes
The device server framework
Vocabulary
The DServer class
The Tango::Util class
Description
Contents
A complete device server
Device server startup sequence
Exchanging data between client and server
Command / Attribute data types
Using data types with C++
Basic types
Strings
Sequences
Structures
The DevState data type
Passing data between client and server
C++ mapping for IDL any type
Inserting/Extracting TANGO basic types
Inserting/Extracting TANGO strings
Inserting/Extracting TANGO sequences
Inserting/Extracting TANGO structures
Inserting/Extracting TANGO enumeration
The insert and extract methods of the Command class
C++ memory management
For string
For array/sequence
For string array/sequence
For Tango composed types
Reporting errors
Example of throwing exception
The Tango Logging Service
Logging Targets
Logging Levels
Sending TANGO Logging Messages
Logging macros in C++
C++ logging in the name of a device
Writing a device server process
Understanding the device
Defining device commands
Standard commands
Choosing device state
Device server utilities to ease coding/debugging
The device server verbose option
C++ utilities to ease device server coding
Avoiding name conflicts
The device server main function
The DServer::class_factory method
Writing the StepperMotorClass class
The class declaration file
The singleton related methods
The command_factory method
The device_factory method
The attribute_factory method
The DevReadPositionCmd class
The class declaration file
The class constructor
The is_allowed method
The execute method
The PositionAttr class
The class declaration file
The class constructor
The is_allowed method
The read method
The StepperMotor class
The class declaration file
The constructors
The methods used for the DevReadDirection command
The methods used for the Position attribute
The methods used for the SetPosition attribute
Retrieving device properties
The remaining methods
Device server under Windows
The Tango device server graphical interface
The device server main window
The console window
The help window
MFC device server
The InitInstance method
The ExitInstance method
Example of how to build a Windows device server MFC based
Win32 application
Device server as service
The service class
The main function
Service options and messages
Tango device server using MFC as Windows service
Compiling, linking and executing a TANGO device server process
Compiling and linking a C++ device server
On UNIX like operating system
Supported development tools
Compiling
Linking
On Windows using Visual Studio
Running a C++ device server
Advanced programming techniques
Receiving signal
Using signal
Exiting a device server gracefully
Inheriting
Writing the BClass
Writing the B class
Writing B class specific command
Redefining A class command
Using another device pattern implementation within the same server
Device pipe
Client reading a pipe
Client writing a pipe
Advanced features
Attribute alarms
The level alarms
The Read Different than Set (RDS) alarm
Enumerated attribute
Usage in a Tango class
Setting the labels with enumeration compile time knowledge
Setting the labels without enumeration compile time knowledge
Setting the attribute value
Usage in a Tango client
Device polling
Introduction
Configuring the polling system
Configuring what has to be polled and how
Configuring the polling threads pool
Choosing polling algorithm
Reading data from the polling buffer
Retrieving command/attribute result history
Externally triggered polling
Filling polling buffer
Setting and tuning the polling in a Tango class
Threading
Device server process
Serialization model within a device server
Attribute Serialization model
Client process
Generating events in a device server
Using multicast protocol to transfer events
Configuring events to use multicast transport
Default multicast related properties
Memorized attribute
Forwarded attribute
Definition
Coding
Transferring images
Device server with user defined event loop
Device server using file as database
Device server without database
Example of device server started without database usage
Connecting client to device within a device server started without database
Multiple database servers within a Tango control system
The Tango controlled access system
User rights definition
Running a Tango control system with the controlled access
Reference part
Device parameter
The device black box
The device description field
The device state and status
The device polling
The device logging
Device attribute
Hard-coded device attribute parameters
The Attribute data type
The attribute data format
The max_dim_x and max_dim_y parameters
The attribute read/write type
The associated write attribute parameter
The attribute display level parameter
The root attribute name parameter
Modifiable attribute parameters
General purpose parameters
The format attribute parameter
The min_value and max_value parameters
The memorized attribute parameter
The alarm related configuration parameters
The min_alarm and max_alarm parameters
The min_warning and max_warning parameters
The delta_t and delta_val parameters
The event related configuration parameters
The rel_change and abs_change parameters
The periodic period parameter
The archive_rel_change, archive_abs_change and archive_period parameters
Setting modifiable attribute parameters
Resetting modifiable attribute parameters
Device pipe
Hard-coded device pipe parameters
The pipe read/write type.
The pipe display level parameter
Modifiable pipe parameters
Setting modifiable pipe parameters
Resetting modifiable pipe parameters
Device class parameter
The device black box
Automatically added commands
The State command
The Status command
The Init command
DServer class device commands
The State command
The Status command
The DevRestart command
The RestartServer command
The QueryClass command
The QueryDevice command
The Kill command
The QueryWizardClassProperty command
The QueryWizardDevProperty command
The QuerySubDevice command
The StartPolling command
The StopPolling command
The AddObjPolling command
The RemObjPolling command
The UpdObjPollingPeriod command
The PolledDevice command
The DevPollStatus command
The LockDevice command
The UnLockDevice command
The ReLockDevices command
The DevLockStatus command
The EventSubscriptionChange command (C++ server only)
The ZmqEventSubscriptionChange command
The EventConfirmSubscription command
The AddLoggingTarget command
The RemoveLoggingTarget command
The GetLoggingTarget command
The GetLoggingLevel command
The SetLoggingLevel command
The StopLogging command
The StartLogging command
DServer class device properties
Tango log consumer
The available Log Consumer
The Log Consumer interface
Control system specific
The device class documentation default value
The services definition
Tuning the event system buffers (HWM)
Allowing NaN when writing attributes (floating point)
Tuning multicasting event propagation
Summary of CtrlSystem free object properties
C++ specific
The Tango master include file (tango.h)
Tango specific pre-processor define
Tango specific types
Template command model related type
Tango device state code
Tango data type
Tango command display level
Device server process option and environment variables
Classical device server
Device server process as Windows service
Environment variables
TANGO_HOST
Tango Logging Service (TANGO_LOG_PATH)
The database and controlled access server (MYSQL_USER, MYSQL_PASSWORD and MYSQL_HOST)
The controlled access
The event buffer size
The TANGO IDL file : Module Tango
Aliases
Enums
Structs
Unions
Exceptions
Interface Tango::Device
Attributes
Operations
Interface Tango::Device_2
Operations
Interface Tango::Device_3
Operations
Interface Tango::Device_4
Operations
Interface Tango::Device_5
operations
Tango object naming (device, attribute and property)
Device name
Full object name
Some examples
Full device name examples
Attribute name examples
Attribute property name
Device property name
Class property name
Device and attribute name alias
Reserved words and characters, limitations
Starting a Tango control system
Without database
With database
With database and event
For Tango releases lower than 8
For release 8 and above
With file used as database
With file used as database and event
For Tango releases lower than 8
For release 8 and above
With the controlled access
The notifd2db utility
The notifd2db utility usage (For Tango releases lower than 8)
The property file syntax
Property file usage
Property file syntax
The TANGO Control System Manual Version 9.1 The TANGO Team September 18, 2015
Contents 1 Introduction 1.1 1.2 Device server history . Introduction to device server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Getting Started . . . . . 2.1 A C++ TANGO client . 2.2 A TANGO device server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.1 The commands and attributes code . . . . . . . . . . . . . . . . . . . . . . . . . . The DevSimple command . . . . . . . . . . . . . . . . . . . . . . . . . The DevArray command . . . . . . . . . . . . . . . . . . . . . . . . . The DevString command . . . . . . . . . . . . . . . . . . . . . . . . . The DevStrArray command . . . . . . . . . . . . . . . . . . . . . . . . The DevStruct command . . . . . . . . . . . . . . . . . . . . . . . . . The three attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.1.1 2.2.1.2 2.2.1.3 2.2.1.4 2.2.1.5 2.2.1.6 . . . . . . . . . . . . . . . . . . 3 The TANGO device server model . . . . 3.1 3.2 The model . 3.3 The device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Introduction to CORBA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.1 The commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.2 The TANGO attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.3 The TANGO pipes . 3.3.4 Command, attributes or pipes ? . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.5 The CORBA attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.6 The remaining CORBA operations . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.7 The special case of the device state and status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.8 The device polling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4 The server . . 3.5 The Tango Logging Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.6 The database . 3.7 The controlled access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.8 The Application Programmers Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.8.1 Rules of the API 3.8.2 Communication between client and server using the API . . . . . . . . . . . . . . 3.8.3 Tango events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Writing a TANGO client using TANGO APIs . Introduction . . 4.1 . 4.2 Getting Started . . 4.3 Basic Philosophy . . 4.4 Data types . . 4.5 Request model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 12 12 13 14 14 15 15 16 16 17 17 18 19 22 22 23 23 23 24 24 25 25 25 26 26 26 26 27 27 27 27 28 29 33 33 33 33 33 34
CONTENTS . . . . . . . . . . . . . . . . . . . . . . 4.6.5.2 4.6.5.1 . . . . . . . . . 4.7 Group . 4.6 Events . C++ Clients . . . . . . Introduction . . . Synchronous model . 4.6.5.1.1 4.6.5.1.2 4.6.5.1.3 change . . . periodic . . archive . . . 4.6.5.2.1 4.6.5.2.2 4.6.5.2.3 4.6.5.2.4 4.6.5.2.5 . . 4.5.1 . 4.5.2 Asynchronous model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6.2 Event definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6.3 Event types . . . . . . . . . . . . . . . . 4.6.4 Event filtering (Removed in Tango release 8 and above) 4.6.5 Application Programmer’s Interface . . . . . . . . . . . . . . . . . . . . . . . . . Configuring events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Subscribing to events . . . . . . . . . . . . . . . . . . . . . . The CallBack class . . . . . . . . . . . . . . . . . . . . . . . Unsubscribing from an event . . . . . . . . . . . . . . . . . . Extract buffered event data . . . . . . . . . . . . . . . . . . . Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.1 Getting started with Tango group . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.2 Forward or not forward? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.3 Executing a command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.3.1 Obtaining command results . . . . . . . . . . . . . . . . . . . . . . . . 4.7.3.2 Case 1: a command, no argument . . . . . . . . . . . . . . . . . . . . . 4.7.3.3 A few words on error handling and data extraction . . . . . . . . . . . . Case 2: a command, one argument 4.7.3.4 . . . . . . . . . . . . . . . . . . . . Case 3: a command, several arguments . . . . . . . . . . . . . . . . . . 4.7.3.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.4.1 Obtaining attribute values . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.4.2 A few words on error handling and data extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Case 1: one value for all devices . . . . . . . . . . . . . . . . . . . . . Case 2: a specific value per device . . . . . . . . . . . . . . . . . . . . 4.8 Reading/Writing device pipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Extracting data with pipe content prior knowledge . . . . . . . . . . . . Extracting data in a generic way (without prior knowledge) . . . . . . . Error management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Error management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.9 Device locking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.10 Reconnection and exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.11 Thread safety . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.12 Compiling and linking a Tango client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.7.5.1 Obtaining acknowledgement 4.7.5.2 4.7.5.3 4.7.4 Reading attribute(s) 4.7.5 Writing an attribute 4.8.1 Reading a pipe . 4.8.2 Writing a pipe 4.8.1.1 4.8.1.2 4.8.1.3 4.8.2.1 . . . . . . . . . . . . . . . . . 5 TangoATK Programmer’s Guide . . Introduction . . 5.1.1 Assumptions . . . . . . . . . 5.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 The key concepts of TangoATK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.1 Minimize development time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.2 Minimize bugs in applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.3 Attributes and commands from different devices . . . . . . . . . . . . . . . . . . 5.2.4 Avoid code duplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 35 35 36 36 36 36 38 39 39 39 40 40 40 40 41 42 42 43 45 45 47 47 47 48 49 51 52 55 55 55 57 57 57 58 60 61 61 62 63 63 65 65 66 66 66 68 68 68 68 69 69 69 69
CONTENTS . . 5.3.4.1 Listeners . 5.3.3.1 5.3.3.2 5.3 The real getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.1 Single device applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.2 Multi device applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.3 More on displaying attributes Connecting an attribute to a viewer . . . . . . . . . . . . . . . . . . . . Synoptic viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3.4 A short note on the relationship between models and viewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4 The key objects of TangoATK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.1.1 What happens on a refresh . . . . . . . . . . . . . . . . . . . . . . . . 5.4.2 The DeviceFactory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.3 The AttributeFactory and the CommandFactory . . . . . . . . . . . . . . . . . . . 5.4.4 The AttributeList and the CommandList . . . . . . . . . . . . . . . . . . . . . . . 5.4.5 The Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Events and listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4.1 The Refreshers . 5.4.6 The Commands . The hierarchy . . . 5.4.5.1 5.4.6.1 . . . . . . . . . . . . 6 Writing a TANGO device server 6.1.2.4 6.1.2.1 6.1.2.5 6.1.2.6 6.1.2.2 6.1.2.3 6.1.2.4.1 6.1.2.4.2 6.1.2.1.1 6.1.2.1.2 6.1.2.3.1 6.1.2.3.2 6.1.2.3.3 Description . Contents . . . Description . Contents . . . Description of the inheritance model Description of the template model Contents . . . 6.1 The device server framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.1 Naming convention and programming language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2 The device pattern . The Tango base class (DeviceImpl class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The DbDevice class . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Command class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The DeviceClass class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The DbClass class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The MultiAttribute class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.10 The SpectrumAttr class . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.11 The ImageAttr class . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.12 The StepperMotor class . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.12.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.12.2 Definition . . 6.1.2.13 The StepperMotorClass class . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.13.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.13.2 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.14 The DevReadPosition class . . . . . . . . . . . . . . . . . . . . . . . . Description . Contents . . . Description . Contents . . . Description . Contents . . . The WAttribute class The Attribute class . 6.1.2.7.1 6.1.2.7.2 6.1.2.8.1 6.1.2.8.2 6.1.2.6.1 6.1.2.6.2 The Attr class 6.1.2.7 6.1.2.8 3 70 70 74 75 75 78 82 82 83 83 84 84 84 84 84 85 85 86 88 88 88 88 90 90 90 91 91 91 91 92 92 92 92 93 93 93 93 93 93 93 93 93 93 94 94 94 94 94 94 95 95 95 96
CONTENTS 4 . . . . 6.1.7.3.1 6.1.7.3.2 6.2.1.1.1 6.2.1.1.2 6.2.1.1.3 6.2.1.1.4 6.2.1.1.5 6.1.6.1 6.1.6.2 Writing attributes . . . . The DServer class . The Tango::Util class 6.1.7.1 Vocabulary . 6.1.7.2 6.1.7.3 6.1.2.14.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.14.2 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.15 The PositionAttr class . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.15.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.2.15.2 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.3 Startup of a device pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.4 Command execution sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.5 The automatically added commands . . . . . . . . . . . . . . . . . . . . . . . . . 6.1.6 Reading/Writing attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Reading attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 96 96 96 97 97 97 99 99 99 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 6.1.7 The device server framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Contents . . . 6.1.7.4 A complete device server . . . . . . . . . . . . . . . . . . . . . . . . . 103 6.1.7.5 Device server startup sequence . . . . . . . . . . . . . . . . . . . . . . 103 6.2 Exchanging data between client and server . . . . . . . . . . . . . . . . . . . . . . . . . . 104 6.2.1 Command / Attribute data types . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 6.2.1.1 Using data types with C++ . . . . . . . . . . . . . . . . . . . . . . . . 105 . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Basic types . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Sequences . Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 The DevState data type . . . . . . . . . . . . . . . . . . . . . 108 Passing data between client and server . . . . . . . . . . . . . . . . . . . . . . . . 109 C++ mapping for IDL any type . . . . . . . . . . . . . . . . . . . . . . 109 6.2.2.1 Inserting/Extracting TANGO basic types . . . . . . . . . . . . 109 Inserting/Extracting TANGO strings . . . . . . . . . . . . . . 109 Inserting/Extracting TANGO sequences . . . . . . . . . . . . 109 Inserting/Extracting TANGO structures . . . . . . . . . . . . 109 Inserting/Extracting TANGO enumeration . . . . . . . . . . . 110 The insert and extract methods of the Command class . . . . . . . . . . 110 6.2.3 C++ memory management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 For string . . . . . For array/sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 For string array/sequence . . . . . . . . . . . . . . . . . . . . . . . . . 114 For Tango composed types . . . . . . . . . . . . . . . . . . . . . . . . 115 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 Example of throwing exception . . . . . . . . . . . . . . . . . . . . . . 115 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Sending TANGO Logging Messages . . . . . . . . . . . . . . . . . . . . . . . . . 117 Logging macros in C++ . . . . . . . . . . . . . . . . . . . . . . . . . . 117 6.3.3.1 6.3.3.2 C++ logging in the name of a device . . . . . . . . . . . . . . . . . . . 117 6.4 Writing a device server process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 6.4.1 Understanding the device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 6.4.2 Defining device commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 Standard commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 6.4.3 Choosing device state 6.4.4 Device server utilities to ease coding/debugging . . . . . . . . . . . . . . . . . . . 121 6.3 The Tango Logging Service . . 6.3.1 Logging Targets 6.3.2 Logging Levels . 6.3.3 6.2.2.1.1 6.2.2.1.2 6.2.2.1.3 6.2.2.1.4 6.2.2.1.5 6.2.2.2 6.2.3.1 6.2.3.2 6.2.3.3 6.2.3.4 6.2.4.1 6.2.2 6.2.4 Reporting errors . . . . 6.4.2.1
CONTENTS 5 6.4.4.1 6.4.4.2 6.4.9.1 6.4.9.2 6.4.9.3 6.4.9.4 6.4.10 The PositionAttr class 6.5.2 MFC device server . 6.4.11 The StepperMotor class 6.4.8.1 6.4.8.2 6.4.8.3 6.4.8.4 6.4.8.5 The device server verbose option . . . . . . . . . . . . . . . . . . . . . 121 C++ utilities to ease device server coding . . . . . . . . . . . . . . . . . 121 6.4.5 Avoiding name conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 6.4.6 The device server main function . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 6.4.7 The DServer::class_factory method . . . . . . . . . . . . . . . . . . . . . . . . . 123 6.4.8 Writing the StepperMotorClass class . . . . . . . . . . . . . . . . . . . . . . . . . 124 . . . . . . . . . . . . . . . . . . . . . . . . . 124 The class declaration file The singleton related methods . . . . . . . . . . . . . . . . . . . . . . . 125 The command_factory method . . . . . . . . . . . . . . . . . . . . . . 126 The device_factory method . . . . . . . . . . . . . . . . . . . . . . . . 127 The attribute_factory method . . . . . . . . . . . . . . . . . . . . . . . 127 6.4.9 The DevReadPositionCmd class . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 . . . . . . . . . . . . . . . . . . . . . . . . . 128 The class declaration file The class constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 The is_allowed method . . . . . . . . . . . . . . . . . . . . . . . . . . 129 The execute method . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 . . . . . . . . . . . . . . . . . . . . . . . . . 130 6.4.10.1 The class declaration file 6.4.10.2 The class constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 6.4.10.3 The is_allowed method . . . . . . . . . . . . . . . . . . . . . . . . . . 131 6.4.10.4 The read method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 6.4.11.1 The class declaration file . . . . . . . . . . . . . . . . . . . . . . . . . 132 6.4.11.2 The constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 6.4.11.3 The methods used for the DevReadDirection command . . . . . . . . . 135 6.4.11.4 The methods used for the Position attribute . . . . . . . . . . . . . . . . 135 6.4.11.5 The methods used for the SetPosition attribute . . . . . . . . . . . . . . 137 6.4.11.6 Retrieving device properties . . . . . . . . . . . . . . . . . . . . . . . . 138 6.4.11.7 The remaining methods . . . . . . . . . . . . . . . . . . . . . . . . . . 138 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 6.5.1 The Tango device server graphical interface . . . . . . . . . . . . . . . . . . . . . 140 The device server main window . . . . . . . . . . . . . . . . . . . . . . 140 The console window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 The help window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 The InitInstance method . . . . . . . . . . . . . . . . . . . . . . . . . . 142 The ExitInstance method . . . . . . . . . . . . . . . . . . . . . . . . . 143 Example of how to build a Windows device server MFC based . . . . . 144 6.5.3 Win32 application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 6.5.4 Device server as service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 The service class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 The main function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Service options and messages . . . . . . . . . . . . . . . . . . . . . . . 148 Tango device server using MFC as Windows service . . . . . . . . . . . 149 6.6 Compiling, linking and executing a TANGO device server process . . . . . . . . . . . . . 149 . . . . . . . . . . . . . . . . . . . . . 149 6.6.1.1 On UNIX like operating system . . . . . . . . . . . . . . . . . . . . . 149 Supported development tools . . . . . . . . . . . . . . . . . . 149 Compiling . . . . . . . . . . . . . . . . . . . . . . . . . 149 . . . . . . . . . . . . . . . . . . . . . . . 150 Linking . . . 6.6.1.2 On Windows using Visual Studio . . . . . . . . . . . . . . . . . . . . . 151 6.6.2 Running a C++ device server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 6.6.1 Compiling and linking a C++ device server 6.7 Advanced programming techniques 6.5 Device server under Windows 6.5.1.1 6.5.1.2 6.5.1.3 6.5.2.1 6.5.2.2 6.5.2.3 6.5.4.1 6.5.4.2 6.5.4.3 6.5.4.4 6.6.1.1.1 6.6.1.1.2 6.6.1.1.3 . . . . . . 6.7.1 Receiving signal . .
CONTENTS 6 . . . . . . 6.7.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 6.7.1.1 Using signal Exiting a device server gracefully . . . . . . . . . . . . . . . . . . . . . 155 6.7.1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 Inheriting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 6.7.2.1 Writing the BClass 6.7.2.2 Writing the B class . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 6.7.2.3 Writing B class specific command . . . . . . . . . . . . . . . . . . . . 156 6.7.2.4 Redefining A class command . . . . . . . . . . . . . . . . . . . . . . . 156 6.7.3 Using another device pattern implementation within the same server . . . . . . . . 157 6.7.4 Device pipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Client reading a pipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Client writing a pipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 6.7.4.1 6.7.4.2 . . . . . 7 Advanced features . . . . . . . . . . . . . . . . . . . . 7.3.2.1 7.3.2.2 7.3.2.3 7.2.1.1 7.2.1.2 7.2.1.3 7.3 Device polling . 7.1 Attribute alarms . . Introduction . 7.2 Enumerated attribute . 161 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 . 7.1.1 The level alarms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 7.1.2 The Read Different than Set (RDS) alarm . . . . . . . . . . . . . . . . . . . . . . 162 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 7.2.1 Usage in a Tango class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Setting the labels with enumeration compile time knowledge . . . . . . 162 Setting the labels without enumeration compile time knowledge . . . . . 163 Setting the attribute value . . . . . . . . . . . . . . . . . . . . . . . . . 164 7.2.2 Usage in a Tango client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 7.3.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 7.3.2 Configuring the polling system . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Configuring what has to be polled and how . . . . . . . . . . . . . . . . 165 Configuring the polling threads pool . . . . . . . . . . . . . . . . . . . 167 Choosing polling algorithm . . . . . . . . . . . . . . . . . . . . . . . . 168 7.3.3 Reading data from the polling buffer . . . . . . . . . . . . . . . . . . . . . . . . . 169 7.3.4 Retrieving command/attribute result history . . . . . . . . . . . . . . . . . . . . . 169 7.3.5 Externally triggered polling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 7.3.6 Filling polling buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 . . . . . . . . . . . . . . . . . . . 172 Setting and tuning the polling in a Tango class 7.3.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 7.4.1 Device server process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 . . . . . . . . . . . . . . . . 174 . . . . . . . . . . . . . . . . . . . . . . . 175 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 7.5 Generating events in a device server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 7.6 Using multicast protocol to transfer events . . . . . . . . . . . . . . . . . . . . . . . . . . 178 . . . . . . . . . . . . . . . . . . . . 178 . . . . . . . . . . . . . . . . . . . . . . . . . 180 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 7.7 Memorized attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 7.8 Forwarded attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 . 7.9 Transferring images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 7.10 Device server with user defined event loop . . . . . . . . . . . . . . . . . . . . . . . . . . 183 7.11 Device server using file as database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 7.12 Device server without database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 7.12.1 Example of device server started without database usage . . . . . . . . . . . . . . 186 7.12.2 Connecting client to device within a device server started without database . . . . 186 7.13 Multiple database servers within a Tango control system . . . . . . . . . . . . . . . . . . 186 7.14 The Tango controlled access system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 7.6.1 Configuring events to use multicast transport 7.6.2 Default multicast related properties 7.8.1 Definition . . 7.8.2 Coding . 7.4.1.1 7.4.1.2 Attribute Serialization model Serialization model within a device server 7.4.2 Client process . 7.4 Threading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS 7 7.14.1 User rights definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 7.14.2 Running a Tango control system with the controlled access . . . . . . . . . . . . . 190 A Reference part A.1 Device parameter . A.2 Device attribute . . . . . . . . . . . 191 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 A.1.1 The device black box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 A.1.2 The device description field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 A.1.3 The device state and status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 A.1.4 The device polling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 A.1.5 The device logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 A.2.1 Hard-coded device attribute parameters . . . . . . . . . . . . . . . . . . . . . . . 193 A.2.1.1 The Attribute data type . . . . . . . . . . . . . . . . . . . . . . . . . . 194 A.2.1.2 The attribute data format . . . . . . . . . . . . . . . . . . . . . . . . . 194 A.2.1.3 The max_dim_x and max_dim_y parameters . . . . . . . . . . . . . . . 195 A.2.1.4 The attribute read/write type . . . . . . . . . . . . . . . . . . . . . . . . 195 . . . . . . . . . . . . . . . . . 196 A.2.1.5 The associated write attribute parameter A.2.1.6 The attribute display level parameter . . . . . . . . . . . . . . . . . . . 196 A.2.1.7 The root attribute name parameter . . . . . . . . . . . . . . . . . . . . . 197 . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 A.2.2.1 General purpose parameters . . . . . . . . . . . . . . . . . . . . . . . . 197 The format attribute parameter . . . . . . . . . . . . . . . . . 197 The min_value and max_value parameters . . . . . . . . . . . 198 The memorized attribute parameter . . . . . . . . . . . . . . . 198 A.2.2.2 The alarm related configuration parameters . . . . . . . . . . . . . . . . 198 The min_alarm and max_alarm parameters . . . . . . . . . . . 198 The min_warning and max_warning parameters . . . . . . . . 199 The delta_t and delta_val parameters . . . . . . . . . . . . . . 199 A.2.2.3 The event related configuration parameters . . . . . . . . . . . . . . . . 199 . . . . . . . . . . 199 . . . . . . . . . . . . . . . . . 200 A.2.2 Modifiable attribute parameters A.2.2.1.1 A.2.2.1.2 A.2.2.1.3 A.2.2.2.1 A.2.2.2.2 A.2.2.2.3 . . . . . . . . . A.3 Device pipe . A.2.2.3.1 A.2.2.3.2 A.2.2.3.3 A.3.1 Hard-coded device pipe parameters A.3.1.1 The pipe read/write type. A.3.1.2 The pipe display level parameter The rel_change and abs_change parameters The periodic period parameter The archive_rel_change, archive_abs_change and archive_period . . . . . . . . . . . . . . . . . . . . . 200 parameters . . . . A.2.3 Setting modifiable attribute parameters . . . . . . . . . . . . . . . . . . . . . . . 200 A.2.4 Resetting modifiable attribute parameters . . . . . . . . . . . . . . . . . . . . . . 201 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 . . . . . . . . . . . . . . . . . . . . . . . . . 202 . . . . . . . . . . . . . . . . . . . . . . . . . 202 . . . . . . . . . . . . . . . . . . . . . 202 A.3.2 Modifiable pipe parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 A.3.3 Setting modifiable pipe parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 203 . . . . . . . . . . . . . . . . . . . . . . . . 203 A.3.4 Resetting modifiable pipe parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 A.4 Device class parameter A.5 The device black box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 A.6 Automatically added commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 A.7 DServer class device commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 A.7.1 The State command . . A.7.2 The Status command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 A.7.3 The DevRestart command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 A.7.4 The RestartServer command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 A.7.5 The QueryClass command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 A.6.1 The State command . . A.6.2 The Status command . A.6.3 The Init command . . . . . . . . .
分享到:
收藏