Using references to display a packed word value

August 3, 2015 / 0 comments / in General  / by Ryan Ackerman

Have you ever run into a situation where a single value on a device could represent multiple values at the same time? How would you display a nice string representation for all the potential values? I recently saw this problem solved on an Emerson device where a TLP contained multiple values packed into a single byte. The solution used a combination of multiple reference DEIDs and a few associated enumerations.

First define the DEID that represents the data you want to unpack. In this example the data is arbitrary and could be any data from any EIE type; I have used an Emerson device. Notice that I have marked this DEID as hidden. The hidden attribute allows me to hide the raw value, which could be difficult to understand.

<WordValue desc="Packed Word Value" type="ui2" tlpType="98" tlpLog="2" tlpParm="30" hidden="true"/>

Next define the references to the packed value. These references will extract the specific content based on the bit values in the source word value and then display a nice string representation of the result value.

The bMsk attribute allows me to do a bitwise AND operation on the value and then a bit shift to move the result value all the way to the right. Alternatively I would have used the bPos attribute depending on how I am analyzing the source value. The result of this specific operation will be either a 1 or a 0 if the second bit is set or unset. Based on that result value I can apply an enumeration to the value to display a nice string. Notice that I have also included a default value in the event I get a value I am not expecting.

<RunState desc="Run State" type="string" ref="WordValue" bMsk="0x0012" mapVal="RSMap">

    <RSMap>

        <e0 value="0:Stopped"/>

        <e1 value="1:Running"/>

        <defVal value="Unknown Run State"/>

    </RSMap>

</RunState>

Now I can repeat the process for each part of the packed word value I want to analyze.

<dgElements>

    <WordValue desc="Packed Word Value" type="ui2" tlpType="98" tlpLog="2" tlpParm="30" hidden="true"/>

    <RunState desc="Run State" type="string" ref="WordValue" bMsk="0x0002" mapVal="RSMap">

        <RSMap>

            <e0 value="0:Stopped"/>

            <e1 value="1:Running"/>

            <defVal value="Unknown Run State"/>

        </RSMap>

    </RunState>

    <LoadState desc="Load State" type="string" ref="WordValue" bMsk="0x0004" mapVal="LUMap">

        <LUMap>

            <e0 value="0:Unloaded"/>

            <e1 value="1:Loaded"/>

        </LUMap>

    </LoadState>

    <ModState desc="Modulating" type="string" ref="WordValue" bMsk="0x0010" mapVal="MODMap">

        <MODMap>

            <e0 value="0:Not Modulating"/>

            <e1 value="1:Modulating"/>

        </MODMap>

    </ModState>

</dgElements>    

The result view in the editor will look something like this:

Using references to display a packed word value

Share this entry
Share by Mail



Comments

Blog post currently doesn't have any comments.
{{com.name}}           {{com.blogCommentDateFormatted}}

Leave Comment

Please correct the following error(s):

  • {{ error }}

Subscribe to this blog post

Enter your email address to subscribe to this post and receive notifications of new comments by email.


Search the CygNet Blog

Subscribe to the CygNet Blog

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Tags

.NET ‘Sparkline” “.NET “64-bit” “Allen “Azure “Canvas” “CygNet “Data “Database “DDS-based “Dispatch” “DNP3 “Facility “FWRD” “Geometric “HMI “IoT “Lufkin “MQTT “Note “OpenStreetMaps” “Relative “Replication” “SCADA” “Security” “SVG” “Telerik” “Thin “Totalflow “Weatherford 8.5.1 9.3 9.4 9.9” Ad hoc chart Alarms API API” ASR Authentication auto-failover automatic failover automatic service recovery beta program Bradley breakouts Bridge Bridge API broadcast browser-based Bytes Canvas CIP Client Client” Clients” Comm Config File Manager Configuration Context menu Controls controls” CRC custom database indexes Custom Events CygNet CygNet 9.0 CygNet 9.4 CygNet 9.6 CygNet 9.7 CygNet 9.8 CygNet messaging CygNet. Data Data Visualization DEIDs Depot Designer device mapping Diagnostics disaster recovery Dynagraph EAC EIE EIE” email Emerson emitter” Enhanced Enhanced Alarm Configuration Excel Facilities” failover feedback Files first look FMS Full FWRD Get Latest Get New GitHub gns Grid” group group grid Heat Map HMI HSS IoT iPhone Job Runner Link Link” Maps” Measurement Measurement” Messaging” Mobile Mode” Navigation OAuth ODBC On-demand chart OPC OPC UA Polling recovery redundancy reference facilities Reference Packages Release Remote replication Report Module SAM Samples SCADA screen performance Scripting Security Server” Shapes” slides Sniffer SQL Server survey Sync” Tabs Tech Bulletin Template Test” TFA Thin Web Client Token Tools transactions” Tree Map trend Troubleshooting Two-factor UA UIS video View Group Web web-based Well WESC 2016 WESC 2018 WESC 2020 WESC2019