# имя: 'Proxy item 2' # описание: прокси - заместитель связанного устройства # тип триггера: 'EgsObjectUpdated' # создан: 2018.02.28 17.37.48, Сельченков Н.Ю. # изменен: '2018.04.17 15.28.22', Сельченков Н.Ю. # подробности: https://redmine.integra-s.com:11000/projects/eilyacuario/wiki/Proxy_item_2 use Newtonsoft.Json.JsonConvert from Newtonsoft.Json use typedef ` ` as Settings const settings = Settings(trigger.settings) use ("acuario2.types." + settings.item_type) as ItemType from acuario2.types use ("acuario2.types." + settings.proxy_type) as ProxyType from acuario2.types if @object is Item then let item = @object as ItemType if (item isnt nil) and ("state" in changes) then let source = item["state"] from item.(settings.item_pin).GetOppositeItems() where it is ProxyType do let target = it["state"] if source.Text in target.EnumNames then target.Set(source.Text, source.Status, source.DateTime) else switch item.State when "ok" then target.Set("ok_normal", source.Status, source.DateTime) when "error" then target.Set("error_defective", source.Status, source.DateTime) when "alarm" then target.Set("alarm_alarm", source.Status, source.DateTime) when "none" then target.Set("none_unknown", source.Status, source.DateTime) else target.Set("DEFAULT", Status.invalid, source.DateTime) now end let proxy = @object as ProxyType if (proxy isnt nil) and ("command" in changes) then let source = proxy["command"].Old ?? proxy["command"] from proxy.(settings.proxy_pin).GetOppositeItems() where it is ItemType do let target = it["command"] if source.Text in target.EnumNames then target.Set(source.Text, source.Status, source.DateTime) else target.Set("DEFAULT", Status.invalid, source.DateTime) now end end