Author Topic: ANIMATING PICTURE BOX Y-VALUE ISSUE  (Read 1950 times)

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
ANIMATING PICTURE BOX Y-VALUE ISSUE
« on: November 10, 2019, 10:28:45 PM »
Hi Guys,

May I know how can I change to correct axis for positive and negative value of the y-axis?
as can be seen in the attachment, I key in -50 but the cursor pointed on the positive region.

x-axis is working fine.
« Last Edit: November 10, 2019, 10:33:19 PM by joko markono »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: ANIMATING PICTURE BOX Y-VALUE ISSUE
« Reply #1 on: November 11, 2019, 04:57:31 PM »
Keep ImageTranslateXValue as it is and negate the ImageTranslateYValue.

See the attached picture.

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: ANIMATING PICTURE BOX Y-VALUE ISSUE
« Reply #2 on: November 11, 2019, 05:23:08 PM »
Sorry i don't get it. do You mean negate in PLC program?

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: ANIMATING PICTURE BOX Y-VALUE ISSUE
« Reply #3 on: November 11, 2019, 07:08:22 PM »
That's probably the best choice.

Otherwise, you could try not to put any address in the PlcAddressImageTranslateYValue and then manually subscribe to the desired address similar to this:

Code: [Select]
    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.ModbusTCPCom1.Subscribe("40002", 1, 250, AddressOf ModbusTCPCom1_SubscribedDataReceived)
    End Sub

    Private Sub ModbusTCPCom1_SubscribedDataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs)
        If e.ErrorId = 0 Then
            If e.PlcAddress = "40002" Then
                If e.Values.Count > 0 Then
                    Me.AnimatingPictureBox1.ImageTranslateYValue = -e.Values(0)
                End If
            End If
        End If
    End Sub

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: ANIMATING PICTURE BOX Y-VALUE ISSUE
« Reply #4 on: November 14, 2019, 08:52:07 PM »
I prefer the second option so that I don't have to mess up with the PLC program.
unfortunately, it doesn't work. I can see the pointer jump to the +ve y region occasionally but it is mainly on the -ve region all the time (note that my analog value is +ve).
here is my modified code from your advice:
Code: [Select]
Private Sub IOPanel_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.OmronSerialHostLinkCom1.Subscribe("2001", 1, 250, AddressOf OmronSerialHostLinkCom1_SubscribedDataReceived)
    End Sub

    Private Sub OmronSerialHostLinkCom1_SubscribedDataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs)
        If e.ErrorId = 0 Then
            If e.PlcAddress = "2001" Then
                If e.Values.Count > 0 Then
                    Me.AnimatingPictureBox1.ImageTranslateYValue = -e.Values(0)
                End If
            End If
        End If
    End Sub

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: ANIMATING PICTURE BOX Y-VALUE ISSUE
« Reply #5 on: November 14, 2019, 08:55:57 PM »
Did you  put any address in the PlcAddressImageTranslateYValue?

joko markono

  • Full Member
  • ***
  • Posts: 132
    • View Profile
Re: ANIMATING PICTURE BOX Y-VALUE ISSUE
« Reply #6 on: November 14, 2019, 09:24:11 PM »
Yes. Owh, i should remove it. now it works fine. thanks a lot.
« Last Edit: November 14, 2019, 09:47:22 PM by joko markono »