Author Topic: Unstable environment  (Read 4253 times)

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Unstable environment
« Reply #15 on: January 13, 2015, 02:14:47 PM »
As for updating:

- Download and extract the latest version
- replace the AdvancedHMI directory of the new Solution with the AdvancedHMI directory of your old version
- Open in Visual Studio
- Build->Clean Solutiion
- Build-> Rebuild Solution

aduhaime2003

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Unstable environment
« Reply #16 on: January 13, 2015, 03:55:08 PM »
I am getting somewhere finally.  I just used the plc and the Ethernet driver.  I was wondering if you could enlighten me about the parameter passing capability or the best way to approach this.  Essentially I need to have the group to pass a variable to concatenate to the tag.

within the group xx

tag 1 = n1xx:0
tag 2 = n1xx:1


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Unstable environment
« Reply #17 on: January 13, 2015, 05:21:40 PM »
Maybe something like this:

Dim MyGroup as integer
MyGroup=5

Dim values() as string
Dim PLCAddress as string
PLCAddress = "N1" & MyGroup.ToString("D2") & ":0"
values=EthernetIPforPLCSLCMicroCom1.Read(PLCAddress,2)

aduhaime2003

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Unstable environment
« Reply #18 on: January 15, 2015, 01:11:52 PM »
I created a structure that is basically an array of string types and have the code written to fill them with the variables.  I now need to know how to actually view them in the form.  I tried a few different objects but I am unsure how to incorporate a variable into the display other than one of the PLC address tags.  Does this make any sense?  Maybe I am just overlooking something.


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Unstable environment
« Reply #19 on: January 15, 2015, 01:22:52 PM »
The easiest way is to add a BasicLabel to the form and put your address in the PLCAddressValue property, then everything is handled for you.

If you want to do with your own code:

- Add a Label to the form
- Add a Button to the form
- Double click the button
- add the code:

Label1.Text=.Read("TS30:0")

- Run the application and click the button

aduhaime2003

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Unstable environment
« Reply #20 on: January 15, 2015, 01:51:14 PM »
I am confused.  I tried what you said above and I cannot get that working.
//where plcAddress is the address of the register in string form

Me.Label1.Text = "Month: " & Alarms(0).month //i get the error Error   11   Operator '&' is not defined for types 'String' and '1-dimensional array of String'.   

//page 2.vb
Public Class Page2
    Structure Alarm
        Public desc() As String
        Public inCond() As String
        Public active() As String
        Public ack() As String
        Public month() As String
        Public day() As String
        Public hour() As String
        Public min() As String
        Public sec() As String
    End Structure

    Dim Alarms(32) As Alarm
    Dim plcAddress As String
    '*******************************************************************************
    '* Stop polling when the form is not visible in order to reduce communications
    '*******************************************************************************
    Private Sub Form_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
        If components IsNot Nothing Then
            Dim drv As AdvancedHMIDrivers.IComComponent
            '*****************************
            '* Search for comm components
            '*****************************
            For i As Integer = 0 To components.Components.Count - 1
                If components.Components(i).GetType.GetInterface("AdvancedHMIDrivers.IComComponent") IsNot Nothing Then
                    drv = components.Components.Item(i)
                    '* Stop/Start polling based on form visibility
                    drv.DisableSubscriptions = Not Me.Visible
                End If
            Next
            For x As Integer = 0 To Alarms.Length
                plcAddress = "ST31:" & x.ToString
                Alarms(x).desc = EthernetIPforPLCSLCMicroCom1.Read(plcAddress, 1)
                plcAddress = "N1" & x.ToString("D2") & ":0/0"
                Alarms(x).inCond = EthernetIPforPLCSLCMicroCom1.Read(plcAddress, 1)
                plcAddress = "N1" & x.ToString("D2") & ":0/1"
                Alarms(x).active = EthernetIPforPLCSLCMicroCom1.Read(plcAddress, 1)
                plcAddress = "N1" & x.ToString("D2") & ":0/3"
                Alarms(x).ack = EthernetIPforPLCSLCMicroCom1.Read(plcAddress, 1)
                plcAddress = "N1" & x.ToString("D2") & ":2"
                Alarms(x).month = EthernetIPforPLCSLCMicroCom1.Read(plcAddress, 1)
                plcAddress = "N1" & x.ToString("D2") & ":3"
                Alarms(x).day = EthernetIPforPLCSLCMicroCom1.Read(plcAddress, 1)
                plcAddress = "N1" & x.ToString("D2") & ":4"
                Alarms(x).hour = EthernetIPforPLCSLCMicroCom1.Read(plcAddress, 1)
                plcAddress = "N1" & x.ToString("D2") & ":5"
                Alarms(x).min = EthernetIPforPLCSLCMicroCom1.Read(plcAddress, 1)
                plcAddress = "N1" & x.ToString("D2") & ":6"
                Alarms(x).sec = EthernetIPforPLCSLCMicroCom1.Read(plcAddress, 1)
            Next
        End If
    End Sub


    Private Sub ReturnToMainButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MainForm.Show()
        Me.Hide()
    End Sub

    Private Sub Page2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

End Class

After is tried that I thought about skipping the structure step and creating the array of addresses and just using the label to read them and display but this was what I got from that

Me.Label1.Text = "Month: " & Me.Read(plcAddress)  //i get the error Error   11   'Read' is not a member of 'MfgControl.AdvancedHMI.Page2'.

//where Alarms(32) is a structure of strings and month is one of those

I guess I should be starting a new thread but...

aduhaime2003

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Unstable environment
« Reply #21 on: January 15, 2015, 02:41:49 PM »
So I took a step back and gave up on that part.

I am trying the baby step approach now but I am having nothing but errors.  Am I incorrect in assuming that I can place a string variable in the PLCaddressValue field of a basic label and use a variable that was defined somewhere in the code?  I have tried to do so but I keep getting errors relating to me not declaring the variable.  I guess I need to know where is the correct place and where can I assign it.  I have tried in the designer and in the design window.  Both got me nothing but errors.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Unstable environment
« Reply #22 on: January 15, 2015, 04:00:54 PM »
I think you are meaning to do this:

Me.Label1.Text = "Month: " & Alarms(0).month 

//page 2.vb
Public Class Page2
    Structure Alarm
        Public desc As String
        Public inCond As String
        Public active As String
        Public ack As String
        Public month As String
        Public day As String
        Public hour As String
        Public min As String
        Public sec As String
    End Structure

    Dim Alarms(32) As Alarm

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Unstable environment
« Reply #23 on: January 15, 2015, 04:03:05 PM »
For this, I think you may be inteneding:

Me.Label1.Text = "Month: " & EthernetIPforPLCSLCMicroCom1.Read(plcAddress) 

aduhaime2003

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Unstable environment
« Reply #24 on: January 22, 2015, 02:30:20 PM »
Moved this discussion to "Large Data Read and write blocks for data heavy pages"