Questo sito utilizza i cookie per migliorare servizi ed esperienza degli utenti. Se decidi di continuare la navigazione consideriamo che accetti il loro uso.

Panoramica Cerca Sopra
Dettagli del download
Extracting bits from an integer Extracting bits from an integer tag
(0 voti)

ExtractBits is a project designed to demonstrate how to use scripts to extract bits from an integer tag and store the bit values in tags of type Bool.

Within the System device, the following tags are defined via the Device Manager: Status01 and Status02 of type Byte, Bits_Status01 and Bits_Status02 of type StatusBits, which is a data structure (defined via the Data Structure Manager). The Bits_Status01 (or Bits_Status02) tag is a structured tag that contains several nested tags of type Bool to which a script will write the value of the respective bits of the Status01 (or Status02) tag.

The Define script, which contains the definition of the ExtractBits procedure, is defined via the Script Manager. On the Advanced page of the script's Properties pane, the Run on thread initialization option is active to execute the script prior to any other script supposed to run in the same thread of execution. The ExtractBits procedure is called from the StatusChanged procedure that is called from the same-named script. The StatusChanged script executes every time the value or quality (validity) of the Status01 tag (or Status02) changes. This is ensured by linking the Status01 and Status02 tags to this script on the Device Manager's Scripts page. The quality (validity) is always changed upon project startup.

The following parameters are passed to the ExtractBits procedure:

The name of the device in which the source tag is defined: System

The name of the source tag: Status01 (or Status02)

The name of the device in which the target tag is defined: System

The name of the target tag (including the character used to separate the structured tag and its nested tags): StatusBits01/ (or StatusBits02/)

The array containing the numbers of bits to extract: BitNumbers_StatusBits = Array(0, 1, 4, 5)

The array containing the names of the fields of the StatusBits data structure (in the same order as bit numbers in the BitNumbers_StatusBits array): BitTagNames_StatusBits = Array("ManualMode", "EmergencyMode", "CheckDevice", "Error")

To display the data of the structured tags of type StatusBits, the same-named window template is used (see the Window Manager). This template contains Display components linked to particular fields of the StatusBits data structure. The template is embedded into the window named MainWindow through a Container component. The window also contains a Display component that is used to display the value of the Status01 (or Status02) tag and enables you to change it.

The solution described above has proven to be very convenient. There may be many tags like Status01 each of which contains status information on a machine used in the industrial process being visualized. It is very easy to add a new status tag. Simply duplicate the Status02 and Bits_Status02 tags. There is no need to modify the existing scripts and add new scripts.

Informazioni

Versione:
Dimensione30.84 KB
Downloads1
Lingua
Licenza
Autore
Sito Web
Prezzo
Creato24-08-2015
Creato da
Modificato il24-08-2015
Modificato daroby

Solo gli utenti registrati e loggati possono scaricare questo file.

.

.