AdvancedHMI Software

General Category => Support Questions => Topic started by: aduhaime2003 on January 12, 2015, 04:15:34 PM

Title: Unstable environment
Post by: aduhaime2003 on January 12, 2015, 04:15:34 PM
I am not 100% if I am the cause of the problems I have been experiencing creating my first project.  I am hoping I am just missing something.  I am attempting a simple project and the vb code Is just breaking.  I am unfamiliar with the feel of visual studio so I am not sure where to start.  I am rusty since I have been using rockwell software for the last few years.  Before that I was only experienced with c++ in a text environment.  I am just trying to get the feel for the environment and I am failing badly.

I had an emulator running a project that I have developed and I have had issues with the driver accessing df1 emulated data.  I sorted that out but everything just fell apart when I created page 2.  It is supposed to be my alarm screen and now I am stuck.  I just don't know the best place to start.  I have had this same issue 3 times and started from scratch.  It is apparent that if I try to ignore basically all my objects disappear.
Title: Re: Unstable environment
Post by: aduhaime2003 on January 12, 2015, 04:18:25 PM
I closed the most recent project and had not saved since it failed and I was able to reopen.  If I attempt to rebuild I lose all objects.  Hmmm
Title: Re: Unstable environment
Post by: aduhaime2003 on January 12, 2015, 04:26:31 PM
I thought perhaps the errors were related to the page 2 having a DF1Comm1 driver and the first page had the same.  Removing the form change button and the driver from the second page then rebuilding caused studio to crash.  After restarting studio the Main Form works and rebuilding worked.  I am unsure what the real problem is.
Title: Re: Unstable environment
Post by: Archie on January 12, 2015, 05:08:00 PM
Visual Studio has a quirk that if you add drivers or controls to the form, then perform a Rebuild, it will crash. You must either perform only a Build, or close all of the forms before doing a Rebuild
Title: Re: Unstable environment
Post by: doggo on January 12, 2015, 06:37:26 PM
I noticed this one as well...thought it was me at first...Thanks for posting!
Title: Re: Unstable environment
Post by: aduhaime2003 on January 13, 2015, 08:59:33 AM
Thank you!

Now, since I am a noob could you help me understand the "building".  When is this necessary and what is the task that is accomplished.  I thought it was as if the system was compling the project but I don't think I am correct because I can run the project without building.  Secondly, when I would deploy a runtime version, would I have a complied project or would the system be running in a client.  I am so unfamiliar with VB, VBA and studio. 

I am just trying to wrap my head around the capabilities before I invest my time into taking a course or dedicating a bunch of time to learning .net and all that goes along with the development.

Again, thanks.

Art
Title: Re: Unstable environment
Post by: Archie on January 13, 2015, 09:17:17 AM
.NET is always compiled before executing. When you click the Run button, the first things Visual Studio will do is compile the necessary code, then run the application. While running in Visual Studio, the application is "hosted" meaning that Visual Studio maintains control of it for debugging purposes.

If you use Windows Explorer to browse the directories, you will find a directory of AdvancedHMI/bin/debug. In this directory is the exe file. This file can be executed outside of Visual Studio.

Generally the "Build->Build Solution" is used to check the program for errors. When you click the Run, the Build action is performed automatically.

The recommended practice for AdvancedHMI is to develop your application in Visual Studio and Run it to test. After completed, copy the entire Solution to the target PC and create a shortcut to the AdvancedHMI\bin\debug\AdvancedHMI.exe file

Since AdvancedHMI or any Visual Studio application is a .NET app, it will require .NET framework installed on the target machine. This is not necessary on your development PC because when you install VS, the framework is also installed.

As a practice, I perform all of the Windows Updates, which includes all of the .NET frameworks.
Title: Re: Unstable environment
Post by: Noe on January 13, 2015, 09:27:06 AM
Archie, can I suggest you to use sticky posts? This information is really usefull for new users who have not worked / worked a little with computer programming languages like a lot of PLC programmers around the world are. Leave basic knowledge for easy access is a way to save time, for everyone. Or the idea of a repository you mentioned, is also good, not only for widgets/code, also for basic knowledge and sharing concepts.
Title: Re: Unstable environment
Post by: aduhaime2003 on January 13, 2015, 09:41:19 AM
Ok, another goofy question.  I am not sure but at some point I made the assumption that the software is based on VB.  I am unsure is this is true.  That being said, due to the familiarity that I have with C++; would I be able to make modifications and such to the software if instead of using visual basic at the point of installation I selected C++.  If that sounds at all infantile or useless as a question, I apologize.  I understand I would still be stuck attempting to understand the forms and resources and the rest of the package so it may be minimal at best. 

As an unrelated point of interest, is there a good resource to use to get familiar with the environment.  I literally have experience with unix based command line coding and compiling and high level software like the Rockwell stuff.  All that in-between stuff (like the .net studio) I have never even played with.  I just started fiddling with VBA in excel this month to see if I could view opc tags.  I have looked at tutorials online on VBA, but realistically my questions are more related to navigation an understanding of the system and how it works more that "what can I do".  Most tutorials I have just show the user how to make a button do some task.
Title: Re: Unstable environment
Post by: Archie on January 13, 2015, 09:50:37 AM
AdvancedHMI is all based on VB, but the solution structure allows you to add a new project to the solution based on C#. So if you choose to add code to your project, then you can write it in C#. Keep in mind that AdvancedHMI is designed to allow the creation of basic HMIs without the need to write any code. Code writing is only necessary for functionality that doesn't exist within the pre-built components.

On the main AdvancedHMI web site under the news section is a link to a series of VB tutorials. These will help get familiar with Visual Studio.
Title: Re: Unstable environment
Post by: aduhaime2003 on January 13, 2015, 01:06:58 PM
A first chance exception of type 'MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException' occurred in AdvancedHMIDrivers.dll

This is what started me chasing my tail yesterday.  Then the crashes started.  Now I am not rebuilding just building if the environment tells me to.
I am back to this error.  The exact same driver on page 1 works 100%
Title: Re: Unstable environment
Post by: Archie on January 13, 2015, 01:36:20 PM
What version are you using and what driver are you using? Are you reading with code or just putting a PLCAddress in an existing control?
Title: Re: Unstable environment
Post by: aduhaime2003 on January 13, 2015, 01:56:28 PM
Currently I am using v396 with the df1comm driver because I am emulating for the current development.  I am just placing the plc in a basic label for now.

I saw that there was a new release.  I would grab that and use it but once again my unfamiliarity with studio leaves me unsure.

I do not know what I would need to copy to allow me to continue with the work I have started.  I downloaded the basic label manual but it didn't help me with the problem because it seems to be a comm driver issue?  I am simply using built in commands for the first project.  It is a simple mode selection screen with pid input values.  There is a button to open form 2 which is the alarm screen. 

I need to show a string value for each alarm, and the associated value and status bits.  I will make a grouped object with all the info and then copy the object.  I would like to be able to pass a parameter to each one instead of updating 10 tags for each object since the structure in the plc is the same for all with a different start register.  I have not gotten past the string!  The string will display on page 1 but page two ...no dice.

example alarm 0 (alarm xx would be st31:xx, and data starts at n1xx:0)
st30:0 = alarm 1 information
n100:0/0 = input condition
n100:0/1 = alarm timeout
n100:0/3 = alarm acknowledged
n100:2 = alarm time month
n100:3 = alarm time day
n100:4 = alarm time hour
n100:5 = alarm time min
n100:6 = alarm time sec
Title: Re: Unstable environment
Post by: Archie on January 13, 2015, 02:09:46 PM
There was another report with a problem with DF1Com driver.  I will set up later today to see if I can replicate.

The DF1 driver tends to get very little attention and testing because the demand has dropped quite significantly. The Ethernet drivers tend to get the most attention and sometimes the DF1 is left broken.
Title: Re: Unstable environment
Post by: aduhaime2003 on January 13, 2015, 02:13:36 PM
I do not really need it for anything more than test.  I will try the plc. I have a few downstairs on some equipment being assembled.  I will see if I have better results for the time being.  I do make a lot of projects via the emulator.  I suppose that I could use rslinx.  I just had no clue how to get into that since I didn't know what the server name was and where to find the name of it on the pc.  I fiddled with it but gave up because I saw that using the df1 with emulator looked easy.
Title: Re: Unstable environment
Post by: Archie 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
Title: Re: Unstable environment
Post by: aduhaime2003 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

Title: Re: Unstable environment
Post by: Archie 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)
Title: Re: Unstable environment
Post by: aduhaime2003 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.

Title: Re: Unstable environment
Post by: Archie 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
Title: Re: Unstable environment
Post by: aduhaime2003 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...
Title: Re: Unstable environment
Post by: aduhaime2003 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.
Title: Re: Unstable environment
Post by: Archie 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
Title: Re: Unstable environment
Post by: Archie on January 15, 2015, 04:03:05 PM
For this, I think you may be inteneding:

Me.Label1.Text = "Month: " & EthernetIPforPLCSLCMicroCom1.Read(plcAddress) 
Title: Re: Unstable environment
Post by: aduhaime2003 on January 22, 2015, 02:30:20 PM
Moved this discussion to "Large Data Read and write blocks for data heavy pages"