|
Topic: DMD0064 OPENDEV - Open Device |
|
|
|
|
|
The Open Device (OPENDEV) instruction is used to create a logical reference to a physical Device, then prepare the target device for access by other instructions that will use this device reference. This allows a Do-more project to be written using around a logical Device which can be changed at runtime.
An example of how this instruction can be used is found in the Do-more Simulator examples named BatchData1.Dmd. The project generates a report that can be sent to the User Log or to the Do-more Logger. Instead of generating two code-blocks that are identical except for where the report is sent. a Device Reference for the destination is created that can be changed at runtime to point to either the User Log or the Do-more Logger.
|
|
Parameters:Note: Use the F9 key (Element Browser) or Down-Arrow key (Auto-Complete) at any time to see a complete list of the memory locations that are valid in the current field of the instruction.
Device - designates which of the pre-configured devices to create the Device Struct for.
No devices
available - indicates there is no device that is appropriate for
this instruction. Select one of the following to create the required device:
Device Struct - the device reference
structure that will contain the reference to the opened hard device. 1
to 16 alphanumeric character name. Device Struct names must follow Nickname rules
On Success: - designates one of the following two options if the Open Device operation is successful:
On Error: - designates one of
the following two options if the Open Device operation is unsuccessful:
|
|
|
|
|
|
Creating a new Device Reference requires a change to the Memory Configuration (notice the yellow indicator next to the Device Struct that will be created). This confirmation dialog makes sure that the pending change is what the programmer intends.
Click the Yes button to continue, this will create the new Device Reference Struct in Heap memory.
Click the No button to go back to the Open Device instruction editor. |
|
Structure Memory:After the Open Device (OPENDEV) instruction completes the Memory Configuration will contain a new Device Structure. It can be viewed in the Project Browser at: Configuration-> Memory-> User-> Structures-> DEVICEREF tree. There will be an entry for each Device Structure, each structure will contain the following read-only fields:
.DeviceID - a system-generated, unique, reference number that is associated with the hard device that was opened
.Open - will be ON if the target device is ready to be used in other relevant device instructions, that is, it is OPEN
.Success - reflects the sate of the Success bit in the most recently executed device instruction
.Error - reflects the sate of the Error bit in the most recently executed device instruction
|
|
|
|
|
Status Display:The red triangle in the upper left corner indicates this is a Fully Asynchronous instruction.
The gray triangle at the right end of the input leg indicates the input
is edge
triggered
A successfully opened device will display the hard device name (@xxx) next to the Device Struct.
|
|
|
An unopened device will display 'Null Device' next to the Device Struct.
|
|
|
|
|
See Also:
|
|
|
|
|
Related Topics:
|
|
|
|
|
Example Using Stages:
|
|
|
|
|
Rung Example:
|
|
|
|
|