Using 2 CAN channels tags to drive the same Gauge

Post Reply
MitchP
Posts: 2
Joined: Tue Aug 15, 2017 11:08 pm

Using 2 CAN channels tags to drive the same Gauge

Post by MitchP »

Hi,

I'm trying to create a script so that I can have redundancy if one CAN link fails for whatever reason. The gauges and all other sending and receiving should use CAN 1 but change to CAN 2 if CAN 1 fails.

I've been pulling my hair out all week and can't work out how to do it. This is my latest attempt using heartbeat messages to force updates but it still won't work. I've set a test gauge to the vStbdStrIndication tag and I am trying to update that value from either CAN tag. Is this the correct way to do this?

I've proven that I can get communication on both CAN 1 and CAN 2 but can't get the screen to swap between them. I've also set up on screen pictures which show that the Valid (timeout) tags are updating correctly so I'm pretty sure I'm missing something with the scripting.

Any help would be greatly appreciated. Thanks, Mitch

Code: Select all

    public partial class Tags
    {			
		void iStnHB_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
		{
			if (Globals.Tags.iError_No_Valid.Value == 1)
				Globals.Tags.vStbdStrIndication.Value = Globals.Tags.iStbdStrIndication.Value;
			else
				Globals.Tags.vStbdStrIndication.Value = Globals.Tags._2iStbdStrIndication.Value;
		}
			
		void _2iStnHB_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
		{
			if (Globals.Tags.iError_No_Valid.Value == 0)
			{
				if (Globals.Tags._2iError_No_Valid.Value == 1)
					Globals.Tags.vStbdStrIndication.Value = Globals.Tags._2iStbdStrIndication.Value;
				else
					Globals.Tags.vStbdStrIndication.Value = 1000;
			}
		}			
    }

MitchP
Posts: 2
Joined: Tue Aug 15, 2017 11:08 pm

Re: Using 2 CAN channels tags to drive the same Gauge

Post by MitchP »

For anyone interested, I never got this working and gave up after finding a work around.

As my display doesn't have a lot of elements I ended up duplicating each one and used a valid can tag to set the visibility.

AMitchneck
Posts: 137
Joined: Mon Jun 11, 2012 2:10 pm

Re: Using 2 CAN channels tags to drive the same Gauge

Post by AMitchneck »

I'm not 100% certain what you are trying to do in your script, but, from the context, it seems you want a tag that gets the value from tag1 if CAN1 good, otherwise tag2.

One way to do this would be to create a tag - for this example I will call this 'tag' that is script-controlled. Then you would create tag1 connected to CAN1 and tag2 connected to CAN2. For this example I will use a bool tag named CAN1_error to indicate something wrong with CAN1.

Code: Select all

public partial class Tags
{
    void CAN1_error_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
    {
        if (!CAN1_error.Value)
        {
            tag.Value = tag1.Value
        }
        else
        {
            tag.Value = tag2.Value
        }
    }
    void tag1_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
    {
        if (!CAN1_error.Value)
        {
            tag.Value = tag1.Value
        }
    }
    void tag2_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
    {
        if (CAN1_error.Value)
        {
            tag.Value = tag2.Value
        }
    }
}
What this code does is updates tag with the value of tag1 if CAN1 error state goes away or tag1 changes with no CAN1 error. It updates tag with the value of tag2 if CAN1 error state occurs or tag2 changes with CAN1 error. Of course, changing screens/elements as you did works just as well.
Adam M.
Controls Engineer
FlexEnergy

Post Reply