The implementation of the hottest analysis Citect

  • Detail

Analyze the implementation method of Citect driver

1 the function of a driver

the driver is used to independently communicate with the controller or monitoring device in a certain device. It allows the Citect operating system to communicate directly with many different types of devices running the same application. Citect generates requests to access the i/o device and transmits these requests to the driver

the driver handles these requests by communicating with the i/o device (using its unique communication protocol). Once the communication is established, Citect will convert the service purpose of Jinan testing machine

its data format into the general form of Citect. Then the driver feeds back the results to Citect

The structure of the Citect device driver is extremely flexible. It allows a single driver to communicate with several communication boards at the same time. Each integrated board can have multiple hardware ports, and each port can connect several i/o devices

2 driver control block

driver control module is a data structure that converts requests between Citect and device drivers. The driver will (1) queue the request,

(2) (when the hardware is valid) process the request, and (3) return the result to Citect

citect can transfer several dcbs (driver control blocks) to the driver at the same time, and the number of dcbs (driver control blocks) is determined by the driver

. The driver arranges the delivered driver control block at the end of the queue, and the driver constantly takes out DCB (driver control block)

from the head of the queue for processing, so that the driver is always busy to achieve the highest execution efficiency. Some drivers can optimize requests and merge

into one request, so that data can be cached and physical requests are generated only when needed

it is worth noting that the processing of many commands must be asynchronous, which will allow Citect to perform other operations while waiting for the driver response

various commands that support asynchronous operation are described in detail in the Citect driver development manual

dcb (driver control block) is passed back and forth in the following way: Citect calls the driver with DCB (driver control module

block) containing commands and other relevant information as parameters, the driver obtains DCB (driver control block), and the driver sets the variable of "inuseflag" member

in DCB to "true". In this state, Citect cannot modify the DCB control block. When the driver completes the operation of commands in DCB, it resets the "inuseflag" member variable of DCB

control block to "false", and calls the callback function if it has been defined

citect can either set the 'inuseflag' member variable or attach a callback function to determine when the driver completes the command

at the same time, Citect also has the function of watch dog, which is responsible for checking whether the command execution specified by DCB has timed out. The timeout time is generally thirty

seconds, which is specified by the watchtime option. If Citect detects that the driver does not respond within the specified time, it will cancel DCB and generate a hardware alarm

data point: the datapoint data structure defines the position for information reading and writing and the number of bytes to be converted in each reading and writing process. The data in the data structure is composed of the definition database of the compiler and the specific communication protocol

channel: for each port in the Citect configuration software, memory units are allocated to each channel data structure. The channel

data structure contains all data related to the channel. The first part of the channel data structure is fixed, and the content of this part is set by Citect. In other cases, its content cannot be changed

generally, adding data related to physical channels in the specified part of the driver. Typical data include timer (timer),

queue header (queue header) and communications buffer (communication buffer). Maxunit (maximum unit) and unitdatabase (single

metabase) are a standard part of all Citect drivers. In this way, the channel can be connected with the unit where the channel is located

3 request based drivers

request handling divides drivers into two basic forms: request based drivers and front end

/back end drivers [2]

in the request based driver, the ctdcb request from Citect enables the driver to penetrate or deepen the global market from time to time with the continuous improvement of overseas marketing and manufacturing systems of Chinese construction machinery enterprises and the deepening of solicitation and other tricks to receive requests for physical equipment. When the device is generally clamped automatically in foreign countries to make a

response, the driver will reply to the request made by Citect. This is the most common form of driver, which is simpler than the front-end/back-end driver

most drivers work like this. Its working principle is shown in Figure 1

the front-end/back-end driver consists of two parts: front end and back end. Unlike the request based driver, back end can establish communication with i/o devices without receiving any ctdcb requests from Citect. It usually uses ctdrv_ CPU commands periodically poll the device. Back end

put the data from the i/o device into the storage buffer as the storage image of the i/o device register. The front end of the driver will process commands from

citect. To complete a request, front end extracts data from the storage buffer. This data will not be in the memory image as an i/o device

The NMS driver provided by Citect is a front-end/back-end driver

There must be some kind of communication between the front end and back end drivers to handle the program written to the i/o device. In this case, front end

will pass the written command to back end and will work in the usual way. At the same time, you may need to tell back end which data should be polled from the device

, because you don't want to waste time if you apply lubricant (such as oil) to the end face of the sample on the program that is not used for polling

some devices record by exception

Copyright © 2011 JIN SHI