Welcome Guest ( Login | Register )



All times are UTC - 7 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Using 2 CAN channels tags to drive the same Gauge
PostPosted: Wed Aug 23, 2017 5:05 pm 

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

Offline
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:
    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;
         }
      }         
    }


 Profile  
 
 Post subject: Re: Using 2 CAN channels tags to drive the same Gauge
PostPosted: Wed Dec 13, 2017 9:58 am 

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

Offline
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.


 Profile  
 
 Post subject: Re: Using 2 CAN channels tags to drive the same Gauge
PostPosted: Wed Dec 13, 2017 2:58 pm 

Joined: Mon Jun 11, 2012 2:10 pm
Posts: 98

Offline
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:
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


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: