Applies To:
  • CitectSCADA

Question: If two Cicode tasks open the same device, do they each get a unique record pointer?

If two Cicode tasks open a device, the same device handle is returned and they share the record pointer. If one device loops from record 1 to the end of the device, and at the same time the other task moves the record pointer to record 42, the first task will not work correctly. 

To work around this problem, use semaphores to control access to the device. For example, create a semaphore for the device and get the semaphore before each task tries to access the device. In this way only one task will access the device.

Alternatively, create two devices that access the same physical device, with each task using its own device. For example DEVICE1 and DEVICE2 that both access dBASE file DEVICE.dbf. With this solution, each device has its unique record pointer and Citect will do record locking to control access to the DEVICE.dbf file. This solution will only work with database type devices as these device do record locking. This solution will not work with ASCII files.