Change Color of Control Based on Quality of Tag
I need to get a quick overview on multiple tags to see if they are logging data or not, so I want the controller to turn red when it is offline. I'm trying to change the color of my donut gauge when there is no data coming through but I'm not sure how I can change that. I've tried setting the value under limit to No Data to see if it would change the color but it doesn't do anything. I want to see if I can instead use a script to control the color of through the Axiom Scripting tool but there isn't an option to add a script anywhere. I'm not sure if I am just not looking in the right area or where it lives. Of course, if there is an easier way to do this or a better way I am open to ideas!
2 replies
-
abraham. faz It looks like you don't have permissions to edit Axiom scripts on your Canary server. Make sure that your username or a group that you are a member of is listed in the administrative privileges list. You can configure this in Canary Admin by going to the Admin tile and then selecting Allow on the left side ( Admin Tile v23 | Access ).
Once you have the right permissions, you can add a script to set the color of a control based on the quality. There should be a new property in the list of properties for the donut gauge called OnBeginValueChange. Click on the script icon to open the script editor.
Then enter the following script:
using AxiomCore2.Client; using AxiomCore2.ControlProperties; using AxiomCore2.Controls; using AxiomCore2.Data; using AxiomCore2.Events; using AxiomCore2.Legacy; using AxiomCore2.Log; using AxiomCore2.Managers; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Collections; using System.Drawing; //using CanaryWebServiceHelper; //using CanaryWebServiceHelper.HistorianWebService; namespace AxiomScript { public partial class ScreenScript : IDisposable { // NOTE: click help icon in dialog header for API documentation and examples. // NOTE: use EventTimer class when timer is necessary. See API documentation. // axiom references public ControlApplication Application { get; } = ControlApplication.Instance; public ControlFactoryManager ControlFactory { get; } = ControlFactoryManager.Instance; public IDataProvider DataProvider { get; } = DataProviderManager.CreateInstance(); public ILog Log { get; } = ClientLog.UserScript; public NavigationManager Navigation { get; } = NavigationManager.Instance; public ControlScreen Screen => _screen; public void OnScreenVisible() { } public void OnScreenInvisible() { } public void Dispose() { } public void DonutGauge1_OnBeginValueChange(object sender, TagSubscriptionArgs subscription, TVQ tvq) { var donut = (ControlDonutGauge)sender; //If the quality is not good, it's value will not be 192 if(tvq.Quality != 192){ donut.Color = ColorTranslator.FromHtml("#FF0000"); } else { donut.Color = ColorTranslator.FromHtml("#7CB342"); } } } }
-
Yes it seems like that was the issue! Thank you and I will definitely be using the script!