Skip to content

Lamp

The lamp lights in the “on” color when the tag condition is met and in the “off” color otherwise. The condition is TRUE or greater than zero, a bit of an integer tag (“Bit”), a comparison (“= 3”, “> 5”), a range (“2..5”), one of several values (“1;3;5”) or a JavaScript expression (“js: value == 3 || value == 5”). “Flash when on” draws attention to a fault, the label goes right, below, left or above, and a state text can be written inside the lamp.

Besides the properties of every element — name, position, size, tooltip, rotation, transparency and the operate right:

Property Values Default Description
Tag tag name Tag
Bit integer Bit. For an integer tag — the bit number; empty — a Bool tag
OnCondition text «On» condition. Empty — TRUE or greater than zero. «= 3», «<> 0», «> 5» — comparison; «2..5» — range; «1;3;5» — one of the values; «bit 3» — word bit; «js: value == 3 || value == 5» — JavaScript expression
OnColor #RRGGBB #3D4A55 “On” color
OffColor #RRGGBB #F2F3F4 “Off” color
Round true / false true Round
Flash true / false false Flash when “on”. Draws attention: fault, requires action
FlashRate Slow, Medium, Fast Medium Flash rate
Shaded true / false false Raised. Highlight and shadow, like a real lamp
BorderColor #RRGGBB Border color. Empty — normal
BorderWidth number 1 Border width
CornerRadius number 0 Corner radius. For a square lamp
Label text Label. Text next to the lamp (outside its frame)
LabelPlacement Right, Bottom, Left, Top Right Label position
LabelFontSize number 12 Label font size
LabelColor #RRGGBB Label color
OnText text “On” text. Text inside the lamp when on
OffText text “Off” text. Text inside the lamp when off

Item.Type = Lamp. Any property is read and changed by name: Item.OnColor = "#D32F2F". The common element members (Visible, Enabled, Value, Raise, Apply…) are described in Elements from scripts.

Mouse, hover, focus and keyboard — as for any element (see Events and functions).

A “Communication” lamp by tag quality — the tag may have no communication bit of its own.

var lamp = Screen.Items("Comm");
lamp.OnColor = "#3C9A5F";
lamp.OffColor = "#D32F2F";
lamp.Label = Tags("PLC1.Counter").Quality === "Good" ? "Online" : "No communication";

The lamp watches another bit of the status word of the selected unit.

var lamp = Screen.Items("Ready");
lamp.Tag = Tags("Unit.Selected").Value + ".Status";
lamp.Bit = 3;