Setting Alarms in Ignition

Hi all, I would like to ask, how do I configure alarms in Ignition and display it in the Alert Status Table from one of the Templates ?

I tried configuring the tag but nothing pop ups

  1. The first image is the settings for the an alert:
    If Ignition is unable to get new values from the database query, like no change in values for the past 3 seconds, an alert should be on to notify user to check the temperature sensor connection.

I tried using Bad Quality since it can work for no connection to database.

  1. The second image is the settings for another alert:
    Ignition read values from the database and calculate the mean and find the maximum value of the values it reads,if the values differs by 10, the alert should be on to notify the user that they should check the screen

Sample Code for Temperature varying too much from a reading by 10 from database

history = np.zeros([32, 32, 5], 'f')
idx = 0
movavgmax = np.zeros((5,1), 'f')
movavgmin = np.zeros((5,1), 'f')
hyst = 0.8;
## Simulate value inputs into the Tag using raw data
rawdata = [2977, 2988, 2966, 2995, 2966, 2973, 3002, 2975, 2983, 2987, 2973, 2984, 2980, 2961, 2966, 2984, 2945, 2952, 2955, 2951, 2943, 2968, 2950, 2945, 2945, 2976, 3006, 2946, 3006, 2918, 2982, 2962, 2926, 2987, 2962, 3009, 2972, 2973, 3002, 2977, 2976, 2997, 2991, 3002, 2972, 3000, 2968, 2982, 2986, 2964, 2944, 2947, 2962, 2955, 2929, 2944, 2944, 2931, 2978, 2962, 2930, 2943, 2927, 3001, 2952, 2983, 2974, 2965, 2989, 2966, 2951, 2975, 2992, 2986, 2955, 2945, 2955, 2978, 2969, 2995, 2972, 2997, 2948, 2950, 2932, 2951, 2946, 2935, 2969, 2941, 2944, 2953, 2934, 2951, 2959, 2946, 2963, 2970, 2981, 2976, 2989, 2993, 2954, 2978, 2983, 2983, 2982, 2975, 2992, 2973, 2977, 2969, 2979, 2966, 2959, 2955, 2923, 2933, 2938, 2953, 2949, 2940, 2948, 2945, 2906, 2973, 2954, 2988, 2958, 2971, 2991, 2959, 2956, 2950, 2983, 2958, 2957, 2980, 2960, 2975, 2979, 2973, 2976, 2986, 2992, 2981, 2984, 2965, 2942, 2935, 2907, 2929, 2939, 2931, 2955, 2963, 2937, 2957, 2986, 2969, 2996, 2960, 2963, 2998, 2958, 2969, 2984, 2955, 2966, 2974, 2967, 2959, 2958, 2993, 2990, 3004, 2994, 3009, 2998, 2998, 2945, 2932, 2933, 2935, 2901, 2925, 2914, 2946, 2926, 2994, 3023, 3009, 2972, 2957, 2961, 2944, 2979, 2975, 2969, 2939, 2996, 2973, 2961, 2935, 2987, 2966, 2993, 3025, 3008, 3028, 3010, 2990, 2960, 2944, 2952, 2903, 2926, 2921, 2935, 2921, 2932, 2936, 2967, 2932, 2963, 2991, 2980, 2966, 2973, 2986, 2978, 2966, 2969, 2973, 2955, 2955, 2962, 2981, 3015, 3018, 3017, 3017, 2992, 2962, 2966, 2930, 2933, 2932, 2909, 2911, 2922, 2944, 2904, 2914, 2934, 2984, 2977, 2967, 2996, 2978, 2985, 2996, 2987, 2966, 2965, 2972, 2966, 2975, 2979, 2975, 3003, 3005, 3002, 2985, 2979, 2965, 2952, 2955, 2925, 2912, 2922, 2913, 2934, 2917, 2933, 2927, 2909, 2931, 2978, 2946, 2973, 2988, 2968, 2976, 2989, 2968, 2958, 2949, 2961, 2966, 2965, 2959, 2975, 2986, 2980, 2954, 2942, 2964, 2941, 2916, 2903, 2897, 2911, 2893, 2916, 2880, 2910, 2926, 2923, 2961, 2969, 2976, 2974, 2991, 3010, 3022, 3004, 2963, 2966, 2964, 2949, 2944, 2956, 2956, 2942, 2954, 2946, 2955, 2948, 2930, 2941, 2925, 2923, 2895, 2909, 2894, 2870, 2905, 2888, 2917, 2903, 2917, 2960, 2975, 3014, 3027, 3031, 3011, 3008, 2971, 2959, 2958, 2945, 2946, 2948, 2944, 2945, 2936, 2935, 2924, 2918, 2937, 2938, 2917, 2900, 2893, 2892, 2895, 2873, 2910, 2884, 2910, 2918, 2932, 2974, 2975, 2997, 3021, 3043, 3015, 2998, 2966, 2953, 2952, 2941, 2946, 2966, 2936, 2947, 2935, 2942, 2937, 2926, 2936, 2916, 2934, 2909, 2893, 2874, 2881, 2896, 2893, 2918, 2903, 2927, 2920, 2985, 2941, 2982, 3003, 3001, 2990, 2991, 2957, 2964, 2954, 2948, 2956, 2953, 2939, 2925, 2933, 2923, 2936, 2928, 2935, 2926, 2929, 2903, 2885, 2891, 2877, 2916, 2888, 2894, 2916, 2957, 2956, 2985, 2970, 2984, 2971, 2971, 2981, 2968, 2953, 2950, 2952, 2934, 2930, 2933, 2940, 2947, 2938, 2927, 2933, 2918, 2927, 2924, 2924, 2925, 2909, 2897, 2913, 2899, 2910, 2925, 2918, 2911, 2896, 2985, 2966, 2968, 2975, 2973, 2958, 2962, 2962, 2960, 2949, 2949, 2952, 2940, 2932, 2946, 2941, 2932, 2931, 2931, 2926, 2932, 2940, 2928, 2919, 2917, 2923, 2910, 2927, 2915, 2927, 2937, 2935, 2973, 2966, 2952, 2980, 2961, 2958, 2963, 2971, 2938, 2965, 2956, 2950, 2949, 2940, 2947, 2951, 2940, 2939, 2938, 2930, 2941, 2926, 2923, 2913, 2921, 2914, 2927, 2918, 2955, 2946, 2944, 2922, 2976, 2971, 2964, 2956, 2945, 2945, 2942, 2956, 2959, 2953, 2950, 2948, 2943, 2936, 2952, 2944, 2943, 2941, 2945, 2943, 2936, 2930, 2935, 2931, 2924, 2918, 2907, 2927, 2943, 2948, 2959, 2934, 2965, 2963, 2950, 2971, 2960, 2953, 2944, 2948, 2938, 2936, 2958, 2944, 2958, 2954, 2935, 2940, 2939, 2943, 2942, 2941, 2944, 2932, 2943, 2932, 2931, 2940, 2927, 2938, 2946, 2951, 2935, 2956, 2968, 2961, 2949, 2962, 2974, 2977, 2959, 2965, 2943, 2955, 2952, 2956, 2955, 2947, 2953, 2935, 2936, 2954, 2948, 2953, 2941, 2942, 2940, 2939, 2933, 2929, 2912, 2919, 2923, 2940, 2948, 2968, 2974, 2950, 2962, 2951, 2965, 2966, 2947, 2962, 2938, 2956, 2951, 2961, 2956, 2944, 2955, 2949, 2943, 2951, 2949, 2952, 2942, 2931, 2942, 2938, 2960, 2947, 2935, 2932, 2926, 2934, 2921, 2935, 2947, 2949, 2954, 2964, 2951, 2949, 2946, 2963, 2948, 2958, 2957, 2962, 2955, 2941, 2967, 2949, 2937, 2952, 2953, 2961, 2956, 2930, 2966, 2928, 2946, 2929, 2929, 2939, 2946, 2959, 2954, 2930, 2949, 2950, 2965, 2991, 2948, 2961, 2965, 2962, 2933, 2962, 2976, 2935, 2946, 2948, 2954, 2965, 2950, 2949, 2953, 2965, 2946, 2937, 2947, 2943, 2942, 2936, 2946, 2942, 2944, 2922, 2942, 2912, 2969, 2963, 2928, 2950, 2963, 2969, 2953, 2971, 2946, 2948, 2955, 2957, 2951, 2937, 2945, 2945, 2954, 2937, 2969, 2962, 2961, 2943, 2942, 2944, 2945, 2937, 2945, 2939, 2953, 2946, 2926, 2988, 2929, 2957, 2976, 2938, 2960, 2983, 2969, 2959, 2953, 2971, 2932, 2966, 2934, 2950, 2959, 2948, 2970, 2942, 2941, 2954, 2942, 2944, 2952, 2952, 2946, 2929, 2937, 2944, 2960, 2943, 2951, 2961, 2941, 2947, 2949, 2936, 2956, 2919, 2974, 2956, 2953, 2949, 2969, 2954, 2952, 2939, 2964, 2962, 2962, 2960, 2957, 2956, 2961, 2940, 2949, 2940, 2958, 2946, 2949, 2921, 2974, 2957, 2958, 2955, 2954, 2934, 2970, 2939, 2952, 2948, 2964, 2947, 2921, 2935, 2965, 2952, 2954, 2949, 2939, 2955, 2938, 2966, 2960, 2936, 2942, 2949, 2953, 2943, 2960, 2950, 2962, 2944, 2936, 2931, 2960, 2976, 2919, 2945, 2918, 2935, 2947, 2952, 2963, 2947, 2954, 2962, 2936, 2950, 2960, 2944, 2956, 2941, 2959, 2965, 2953, 2965, 2953, 2936, 2952, 2940, 2947, 2959, 2946, 2935, 2978, 2950, 2966, 2991, 2917, 2891, 2949, 2938, 2961, 2969, 2942, 2970, 2963, 2964, 2956, 2952, 2949, 2963, 2947, 2951, 2950, 2948, 2969, 2968, 2939, 2941, 2949, 2939, 2974, 2981, 2949, 2920, 2972, 2949, 2973, 2944, 2921, 2954, 2895, 2912, 2979, 2937, 2973, 2956, 2964, 2961, 2957, 2946, 2940, 2938, 2975, 2959, 2952, 2955, 2987, 2970, 2960, 2939, 2957, 2937, 2972, 2925, 2947, 2983, 2961, 2987, 2940, 2909, 2953, 3001, 2955, 2987, 2966, 2953, 2956, 2946, 2894, 2938, 2935, 2966, 2940, 2958, 2964, 2958, 2949, 2951, 2957, 2966, 2950, 2972, 2948, 2970, 2983, 2948, 2972, 2976, 2925, 2962, 2970, 2871, 2970, 3023, 2935, 2976, 2971, 2948, 2937, 2966, 2931, 2943, 2950, 2941, 2934, 2977, 2939, 2937, 2978, 2940, 2980, 2979, 2953, 2958, 2939, 2949, 2955, 2925, 2948, 2951, 2913, 2912, 2935, 2987]
rawdata = np.array(rawdata)
rawdata = np.resize(rawdata,(32,32))
rawdata = (rawdata/10.0)-273.15

rawdata = {[.]Row0.value}
import math 
pyData = system.dataset.toPyDataSet(value)
import jnumeric.PyMultiarray as np
history = np.zeros([32, 32, 5], 'f')
alarm=0

avg = np.resize(rawdata,(1024,1))
avgs = [sum(vals)/len(avg) for vals in zip(*avg)]
Max = 0
Max=(max(avg))

if ( Max - avgs >= 10.0):
	alarm=1
else:
	alarm=0

return (alarm)

Maybe I should setup another script tag to read data from database and process the value difference then compare it with the setpoint for this… but I wonder if it’s possible with a query tag

Hi @e0310912,

For 1. you may need to use some form of heartbeat or timer script to trigger the alarm. Bad Quality does work, but will only alarm for a disconnect from the DB.

For 2. I would separate this out into a couple of tags. One tag is a query tag that holds the dataset. The other is an an expression tag that calculates the difference between the mean and max value from the dataset. The expression tag will have the alarm configured with Above Setpoint 10.

For number (2), you’re trying to run python within the expression language which isn’t possible without calling it within the runScript expression function.
What is this script actually doing? It’s always better to try to use the expression language rather than python as it’s far more efficient and performant. The expression language has a lookup function to lookup values in a dataset, but it’s hard to know what you’re trying to do without seeing your full script.
Also, you would see an error showing on the tag under its diagnostics with it configured as it is (see the diagnostics tab in the tag editor)

Ok, I will look into it the diagnostics part

The goal is to actually calculate the average temperature from a 32x32 pixel temperature values obtained from a sensor and then do a simple comparison by finding the highest temperature value within the same 32x32 temperature values and check for any deviation.

If the Difference between the maximum temperature and the average is a lot, let’s say a big difference of 10, it will set an alarm mostly. For this… it’s just a working concept design the but the main idea would be to implement an alert.

For 1. I see, I thought it was that the value never change for bad quality, but that’s good to know it can be used to check for DB connection, maybe I can implement it for another Alert if Ignition is unable to connect to the DB.

For 2. Oh, that an interesting approach, I have a lot of tags so it seems like a good idea to use them for these. I will try this out. Thank you

In the Ignition docs it states for the bad quality mode:

Active if the Tag value becomes a bad quality, for example, on communication loss.

For OPC comms this would be a return value of BAD. In terms of DB queries it seems to do this for an error, which is produced when the DB cannot be reached (I only came to this conclusion by having a play last night). A lack of value change doesn't necessarily mean that the data is of bad quality.

There are a few ways you can do 2. I thought separating out would be easier to debug, as you can see the result from the expression tag to check it is returning a valid value. You could split this out into even more tags if required to try and get to where the issue is.