AdvancedHMI Software

General Category => Open Discussion => Topic started by: DJShardy on August 06, 2018, 08:57:55 PM

Title: Help a rookie - Displaying Circles
Post by: DJShardy on August 06, 2018, 08:57:55 PM
Hey,

This is my first time using AHMI. So far I enjoy it and once I get better at .NET ill be bale to use it a lot more.

So the project i am working on right now I need to display three different colored circles. ( Think traffic lights )

The circle that comes up is depending on logic in the PLC. The results end up in a BOOL. ( RED, AMBER, GREEN)

I have created three Data Subscribers (DS) and called them, RED, AMBER, GREEN. I have told each one that tag that it has to look at.

This is the code that each DS runs.

Code: [Select]
     
  Dim redCircle As Pen
        Dim redCircleFill As Brush

        redCircle = New Pen(Drawing.Color.Red, 5)
        redCircleFill = New SolidBrush(Color.Red)

        Dim myGraphics As Graphics = Me.CreateGraphics
        myGraphics.DrawEllipse(redCircle, 840, 175, 195, 195)
        myGraphics.FillEllipse(redCircleFill, 840, 175, 195, 195)

The problem is that, I will tell Green to come on and it does, then Amber and it does, I try red and it will Just not show up. It'll stay as the last colour. Then I go back to green and it will change as expected. Red will never work.

Any Ideas on what I have done incorrectly?
Have checked the tag names and everything like that.
Title: Re: Help a rookie - Displaying Circles
Post by: Archie on August 06, 2018, 09:14:50 PM
Sounds like either your Red DataSubscriber is not firing the event or 2 of the DataSubscribers are both firing and overwriting one.


On another note, you can do this with a BasicIndicator without having to write code.
Title: Re: Help a rookie - Displaying Circles
Post by: DJShardy on August 06, 2018, 09:51:02 PM
Ah, No idea how I missed Basic indicator, Well I learnt a bit on that adventure.

Not sure about the DS and why they were doing that.
Title: Re: Help a rookie - Displaying Circles
Post by: Archie on August 06, 2018, 10:34:03 PM
You can add a breakpoint at the first line of code of your red DataSubscriber and see if it fires, then step through it.
Title: Re: Help a rookie - Displaying Circles
Post by: Phrog30 on August 07, 2018, 05:57:11 AM
Looking at your code you posted on the other forum, you were just using the data returned event, which will fire on a bool for true and false. You need to add code for true only, use e.values(0) = true.