AdvancedHMI Software

General Category => Application Showcase => Topic started by: Phrog30 on April 20, 2018, 11:51:45 AM

Title: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on April 20, 2018, 11:51:45 AM
This is a work in progress.  I have polished my multistate control a little more.  If you add this control to the form and double-click it will open a designer form, similar to other HMI software packages.  It makes editing properties a lot easier.  I added an import and export feature.  In a test I added over 10,000 states with no problem.  However, this will severely slow down VS during design mode open, closing, and saving.  So, if you have a large amount of states, I recommend exporting, then referencing this file as an INI.  I tested two multistates with over 10,000 states in an INI and the form load and changing was quick.

I tested this app in VS2013 and didn't get any errors, so all you should have to do is export and build the project.  For testing I just used a numeric up/down, but you can assign PLC addresses and that should work as well.

Let me know what you think.

https://drive.google.com/file/d/1qjlMtYEu99RfjormprxVEhwFPzoghRce/view?usp=sharing (https://drive.google.com/file/d/1qjlMtYEu99RfjormprxVEhwFPzoghRce/view?usp=sharing)

James
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on April 29, 2018, 04:54:34 PM
I tried it and it seems to be a neat control.

It is possible to add it to the AHMI project, as the attached pictures show, but in a quite a complex way.

Maybe consider making it compact so it could be easily added to AHMI or just persuade Archie to include it.

Importing those 10000+ messages did work, slowed down the VS but was responding quick at Runtime.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on April 29, 2018, 09:40:10 PM
... or just persuade Archie to include it.
I tried already. I'm guessing he's not onboard with it. Personally, I think it's one of the best controls to have, I used it all of the time. But maybe I'm the only one thinking that.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Alipaymax on April 30, 2018, 03:54:24 AM
I may be contacting you for more information on this issue. It is very interesting.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 26, 2018, 02:10:45 AM
hello i really liked the way ur project is

can u put instructions of using it for us beginners

with thanks
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 27, 2018, 06:06:30 AM
what i mean by instructions is

i am using 4 delta plcs in my project all using modbustcb
so how should i configure ur project
to work with myne
i mean i am gonna move my project inside yours so i can use your controls
( audit , alarm , history , users ,the new modified controls u add to it...)

and one more thing
the ( Who Am I Selection ')
what is it ?

NOTE " MY PROJECT IS WORKING FINE BUT I WANT TO USE YOUR CONTROLS BECAUSE THEY LOOK AND WORK MORE PROFESSIONAL AND I DON`T HAVE DATABASE IN MY PROJECT OR KNOW HOW TO DO IT YET )
with thanks
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 27, 2018, 08:16:19 AM
so how should i configure ur project to work with myne
i mean i am gonna move my project inside yours so i can use your controls
( audit , alarm , history , users ,the new modified controls u add to it...)

I can't answer that, not enough information... not sure about your project and your goals.  Personally, I would merge into Archie's latest beta.  I tried to make it easy by putting all of my stuff inside of a folder, just copy and paste.  Last time I updated it only took 2-3 minutes.

and one more thing
the ( Who Am I Selection ')
what is it ?

This is a remnant of a feature from another project that I left in.  You should probably delete it,
Code: [Select]
Public Shared Who_Am_I As Integerin Class/Globals, then go and delete all of the errors reference.

This was a means to control zones or nodes.  For example, we had 2 HMIs running the same program, but I didn't want the operator to be able to do the same things on each.  Our alarms had a property for zones, which allowed me to show certain alarms for certain zones and allow certain zones to silence or reset alarms.  I could also add a property to a basicbutton, for example, and prevent operation unless in that zone.  Just remember, this sample app I posted was part of a larger application, I tried to delete all non-relevant items, but I'm sure I missed a few.

The goal of the original post was for multistate, it was just to show the control, not really meant to show the whole app.  I included the entire app just to make it easier for people to run it.

I'm working on several projects so I really don't have time to write out detailed instructions on this stuff.  Just do your best and come back with a question or two and I will try and help.  Godra has been very good lately about giving help, so I'm not the only one that can help.  My point, someone should be able to help you.

James

Edit: I can't promise anything, but if you can send me your project I could try and merge files for you.  It depends on several factors.  One thing to answer, how do you have alarm triggers?  My app is really designed for arrays.  So, you will need to decide on triggers.  My app can do alarm descriptions from both a local file, or strings from a PLC, but I never tested with Modbus, so I would just stick to local.  That is easy to do, I can show you if necessary.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on June 27, 2018, 10:24:44 AM
oqapsking,

James offered to possibly do it for you so don't hesitate to send your project to him (if anybody can do it accurate and fast enough it would be James).

Make sure to refine your project and provide all the details so James doesn't waste to much time deciphering it.

Otherwise, doing it bit by bit will be a huge waste of your and everybody else's time.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 27, 2018, 02:21:59 PM
thanks guys what i need in my project i already used ctrlbasicbutton the one that u made
so what i need is only to make the connection status for my 4 plc
but i can`t find where to chose its com component and the alarms too
and how to make it read the alarms and audit it for multiple com components
my project is simple but full with images and i would rather to finish it my self so i will be learning in the process
i liked the idea of the audit
so i can see the alarms the system and the users

for the alarms the way i use it is for example i read the value of register (d100)
each value has a meaning for example from 0 to 20
0 = door1 open
1 = door 2 open
and so on
like u use in ur project
but i cant find the area to choose the com component and the plc address and so on

thanks in advance



Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 27, 2018, 03:40:38 PM
There are four main parents.  I had my reasons for doing this, but will not go into now.  This app gives you the ability to run on 4 monitors, hence 4 parents.  However, only the 1st parent has a ComComponent.  So, open up _0000_1st_Parent, and you will see it.  What you can do is delete that, then look at all of the errors and you can see where I was using it.  But, for alarms open the code for 1st parent (F7), then do find (Ctrl + F), search the current document for TODO.  i used TODO as a reference for where user defined stuff is at.  TODO_1 is alarm quantity, you don't need to use this though, you can simply hard code it.  TODO_2 I think is at 16, change to suit your needs.  If your words are 16 bit, then you are fine.  TODO_5 is the trigger array (there multiple places to edit).  I think the app I shared had 40020i, so what I'm doing is starting i=0 - 400200 and going to alarm quantity, let's say for example 3, so 400200, 400201, 400202 (Qty is base 0).  I shove those addresses in a datasubscriber.  TODO_6 is alarm descriptions, you can just comment that out.  You can comment out TODO_8 stuff.

I'm rushed for time, so hopefully that little bit helps...
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on June 27, 2018, 04:49:15 PM
oqapsking,

You seem to be after this Multistate control from this topic because it would allow you to specify what PLC to look at and display its active alarms in the form of a message.

Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 27, 2018, 05:42:09 PM
I'm sorry, I didn't realize that's what he was after. Not the first, or last, time I've not understood. :)
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 27, 2018, 06:41:02 PM
Yes and i used it but sadly for i am new in vb i didn't know how to use it with a database or to add it to the audit page and the history page the idea in my head is to use a multistate control for each plc then connect them with the audit page and the history page
And i couldn't do  the connection status for each plc i hope u guys can put me in the right direction
With thanks
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on June 27, 2018, 07:33:30 PM
If James is still willing to look at your project then you should definitely zip it up and send it to him.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 28, 2018, 12:32:40 AM
The multistate I did will only show one state at a time. Is that desirable for you? Probably could have 4 separate data subscriptions and look up tables?

I guess I'm still a little lost on what you are trying to accomplish. Sorry, just have a lot on my mind right now.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 28, 2018, 03:16:32 AM
ok i will work on it step by step

first i add a ModbusTCPCom1
then i add Mutlistate1
then i add a tag ( plc address D13 ) which should be written like ( 44110 ) in the plc address of the Mutlistate1 properties
now when i start the app it shows the message correctly according to the value.

what i don`t know how to do
is how to show this message in these forms ( _0080_Alarm_Active , _0085_Alarm_History , _1001_Audit )
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 28, 2018, 04:31:17 AM
look i tried to do the audit thing
so i edieted the multistat control

i add this code u have in one of the forms

Code: [Select]
Dim CurrentUser = Globals.LoginName
                    If CurrentUser = "" Then
                        CurrentUser = "None"
                    End If
                    Dim Audit_History As New AHMI_v1.Audit
                    Audit_History.Send(Globals.AuditDBPath, CurrentUser, "Alarm", Me.Messages(i).Value, "")


then i pasted it inside the multistate code under the Region "Private Methods" as like this

Code: [Select]
If m_TriggerType = 0 Then
            For i = 0 To Me.Messages.Count - 1
                If m_value = Me.Messages(i).Value Then
                    State_Ptr = i
                    StateChanged = True
                    Dim CurrentUser = Globals.LoginName
                    If CurrentUser = "" Then
                        CurrentUser = "None"
                    End If
                    Dim Audit_History As New AHMI_v1.Audit
                    Audit_History.Send(Globals.AuditDBPath, CurrentUser, "Alarm", Me.text, "")
                End If
            Next
        End If


then i rebuilt the project
and it showed as the photo in the Attachments

so this solved the audit issue for me
but if u have a better way or any advice please tell me

now i will work on the alarm page
and the connection status


Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 28, 2018, 07:05:33 AM
You are obviously free to do whatever you choose, but the general purpose of audit is for tracking operator input, button presses, setpoint changes, logging in and out, etc. Alarms don't really fit that bill. There is an alarm history for that. The current active alarm and alarm history aren't designed to do what you want. Edits could be made to make it work. It sounds like you got audit to work, so you should be able to get alarms to work because they use the same database functionality.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 28, 2018, 10:40:59 AM
I thought about this more, the way I did the alarms is I used an INI file as kind of a working table.  I needed something that could retain data (think App stopping and restarting - need retention), at the time I didn't use a DB and I just never went back and changed it.  So, since there is only one file I used indexes.  I don't know of an easy way to do that with multiple controls scattered through the application.  Writing to a DB, like you did with audit is easy.  But, the active alarms is basically a datatable looking at the INI file, which is changing all of the time.  Personally, if you really want to use the current active alarm summary, then it's probably best to add multiple tags in the current datasubscriber.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 28, 2018, 12:35:45 PM
Here is an updated app that makes it easier to add alarms.  I tested, but not thoroughly.  To add open the 1st parent, select AlarmTriggers at the bottom, then edit the Items property.  There is at least one limiting factor, all tags must be the same bit length and I didn't setup arrays... maybe later.  Also, the bit length is hard coded at 16.  Honestly, this should work for most applications.  The addresses don't have to be contiguous, which is what I think you were after.  I didn't test BOOLs, my guess is they won't work.

https://drive.google.com/file/d/1dPHap6RFzRYmBOy7V87IxxzObyomJUim/view?usp=sharing (https://drive.google.com/file/d/1dPHap6RFzRYmBOy7V87IxxzObyomJUim/view?usp=sharing)

Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 28, 2018, 05:08:59 PM
first thanks a lot for your help

i am trying to use it  but i did not make it work yet
i will keep trying and then i will tell u what happens
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 28, 2018, 06:04:56 PM
I forgot to mention that it's using the stock datasubscriber, which only allows one comcomponent. You need to sweet talk Archie into making a datasubscriber that allows a comcomponent per item. While he's at it he can fix the data change event for arrays, currently the data change/return only works on the first element in the array, which is fairly useless.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 28, 2018, 06:07:50 PM
To test, use the numeric controls on the form, that's why I left them there.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on June 30, 2018, 03:13:25 AM
For those who might be interested, in one of the later posts there is the link to modified version of this latest project, which performs Integer instead of bit alarming and also can monitor multiple PLCs:

It should theoretically allow 32000+ alarms per single address.

It can be tested as it is with MODRSsim2 program (which needs to have enabled the option to "Use a separate set of registers for each station" found by clicking the "Adv. PLC Emul. settings" icon in the top right corner).

There might be bugs in the project.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 30, 2018, 06:16:43 AM
lovely

thanks for your help Godra and Phrog

i will keep u posted
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 30, 2018, 06:56:07 AM
i tried your project Godra it reads the alarm but does not show a pop up massage and does not show it in the alarm history and active alarms
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 30, 2018, 07:08:54 AM
away from the alarming thing

how did you make the project this way
when the program starts it opens (_0000_1st_Parent.vb)
but it has (_0001_Main.vb )inside it as it is a part of it ?

i read something about mdi parent and child forms

but i didn`t try it before

so in this project how did u do it ?
can you show me the way?

usually my projects depends on images and panels
each page i need i create a form for it and change form button
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on June 30, 2018, 08:50:03 AM
Your pictures show "No Communication to PLC" ... did you use MODRSsim2 program for your test?

If not, then try it first and set it as suggested ... once this works then try making changes to have it work with your PLCs.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 30, 2018, 01:00:23 PM
How about we back up a bit...

What is being requested?  Is it how to do alarms, is how to use the multistate, is it to change forms?

1.  I'm being Capt. Obvious, the multistate is a multistate.  It displays a state.  It has nothing to do with alarms.  Since it's read only, it doesn't need auditing.  So, I'm more than happy to tweak the control, but I'm not going to spend time making it work with alarms.

2.  Alarming... In it's simplest part, it's binary.  An alarm is either on or off.  There are many ways to do alarming.  Over the years, I found the best to be mapping in the PLC to bits and the HMI reads the words (arrays) then breaks them back apart to display an alarm text.  Using bits or integer triggers in the HMI is SOOO stupid.  If you want to use integer triggers, be my guest but I will not spend time on it.  What I currently have in place WILL work for you.  You simply map the state to a bit in the PLC.  That's is it.  Done.  The hard part here is that you have multiple PLC's.  No problem, I can get that working for you if you are interested.  But, it will be bit array triggering, not bit or integers.  So, let me know if you are interested and I can throw something together.  Also let me know if I confused you on mapping to bits in the PLC, I can try and form an example.

3.  Yes I use MDI parents.  There are many ways to do what I did, I found this the easiest.  For multi display applications, I only have to have one form that may, or may not, be displayed on multiple screens at once.  I have a property that is set to allow multiple instances.  There is nothing to set up, it just works.  I have buttons that are designed to change forms and it works with the multi display functionality.  Look at the main form (with a house) button, that is an example.  This has been the more desired layout of HMI for my customers. So, each form has it's own navigation set.  Another option is to use a global footer/header/side bar.  What I didn't like about this is if you have a button that takes you to a screen, that button is still there once you change.  Why?  You can't go there anymore than you already are.  You could write code to hide it, but why?  This way you can have forms with many buttons, or forms with just one.  You simply drag and drop any way you like... done!

So, I think we need to ask questions a little better.  Don't ask how you do something.  Ask, I would like to do "x", what's the best way to do it.  Because the way you may have in mind, might not be the best, or even good... like using a multistate for alarming. :)

James
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 30, 2018, 03:04:00 PM
I connected it to the plc not to the simulator
I have set up two testing plcs so in the image
each two multistate is connected to a plc
And each one is set to a diffrent register


Mr Progh for my projrct us didn't have any problem with working with multi plcs at the same time
What i am doing here is learning more and more from the experts like you, Archie and Godra and am not saying that to complement  any one
Am always looking to learn more and when i see a project that i like i start asking questions  to understand how it is done

This is the second project on vb net i make
In the one am working on i am connected to 6 plcs and the hmi is on more than one computer at the same time and they are working fine
But your project and the way you made it
It looks and works more professional ,  and thats what i need

For the alarming i never had a problem  of using multistate to show it to the user
And to tell you the truth there is another step am going to work on which  is the Audit page will recieve data from another pc's so it will be working as one pc i a server and the others are clients

And to tell the truth am at this time more of a designer  than a programer
I will attach image of my first project when i get to my laptop so you can understand what am to
And i apologies if my English and the way i ask questions  is bad

And am really  thankful  for your help guys ☺️
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on June 30, 2018, 03:31:05 PM
The project is kind of hard-coded for 4 PLCs (there are 4 ModbusTcpCom drivers).

You should still fire up MODRSsim2 just to compensate for the missing 2 PLCs.

You should try to understand the significance of using this simulator at any point in time you might be dealing with Modbus.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 30, 2018, 03:32:43 PM
in the link is an image of my first project

which in it i had 6 plc`s in 3 different cities

it worked fine the only thing i didn`t do in it is a history page and database

https://drive.google.com/file/d/13SwXp37vUaoh9ygR_X2flgGMCNHJo-Ey/view?usp=sharing


Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 30, 2018, 03:33:48 PM
MODRSsim2 i don`t have it
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on June 30, 2018, 03:48:25 PM
One other thing you need to improve on is the research.

If you just type it in the Google it will show you all possible links, the very first which should be the SourceForge page.

If you do a search in this forum then you might notice that a member DougLyons is the one who is actually maintaining it.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 30, 2018, 03:59:03 PM
but if may i ask
i gave all the  4 ModbusTcpCom drivers an ip for each one and each two have the same ip , is that the reason the connection status does not work? ?
and when i use it i will make it to show the connection status for each ModbusTcpCom separately
from now on i will work like phrog by copying and modifying  each control i need and add it to the project

and what i mean about not having that software is that i don`t need it at this step

for the alarming issue and the audit am done with it for now i got the main idea how to do it from you and Prohg


if you opened the image i add for my first project u will understand that it  takes me  along time between each step and the next

https://drive.google.com/file/d/13SwXp37vUaoh9ygR_X2flgGMCNHJo-Ey/view?usp=sharing

becouse i design the images i test them (how they look in the project ) then i move to the next step

at now i will continue working at my current project i will come back when i have another questions and to share how i did it to get your advice's

with thanks :)
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on June 30, 2018, 04:16:05 PM
If you test the project with MODRSsim2 and actually see it working then you need to try to understand that there might be something you are doing wrong when modifying it.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on June 30, 2018, 04:21:54 PM
ok i will work on that

thanks
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 30, 2018, 04:52:41 PM

And i apologies if my English and the way i ask questions  is bad


Seriously?  I'm the idiot 'Merican who can barely understand one language.  Yeah, you're doing just fine!!

My point was just approach the question differently, no matter the language.  A lot of time people go down a path they think is correct and they will focus on that path, when in fact it's not the correct path at all.  So, if you state what you are trying to do, then people will tend to do a lot better job of giving advise.  Just my two pennies!!

James
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 30, 2018, 04:56:07 PM

What i am doing here is learning more and more from the experts like you, Archie and Godra ...


Yep, props to Archie and Godra.  They are the heavy hitters on this stuff.  I'm just trying to remember what day of week it is. :)
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on June 30, 2018, 05:49:13 PM
James, this project is your work and people seem to start paying attention to it.

The rest of us are just "fooling around" and experiment with it.
 
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on June 30, 2018, 08:16:39 PM

James, this project is your work and people seem to start paying attention to it.

The rest of us are just "fooling around" and experiment with it.

I don't mind one bit.  All I did was take what we did in FTViewME and make it work in AHMI, whether good or bad.  I posted it so people could use it.  I truly hope it benefits someone.  I'm sorry if my recent posts sounded crabby, I didn't mean them that way.  I just want to be efficient in the time I spend making changes. 

I really had fun making that app.  I learned a lot, I hope I somewhat got it right...

James
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on July 01, 2018, 04:32:42 PM
This project was changed and updated so it easier supports multiple PLCs and their addresses, and here is the link:

https://www.dropbox.com/s/ek96x3h7jvt5dfd/AHMI%20Updated%20Alarming%20vBeta11%20New.7z?dl=0

Requirement for this app is to keep the alarm triggers names format as it is, "PLCxAlarmTriggers" where x is 1, 2, 3, ...
You could add numbers at the end if you wish.
You should CLOSE and RE-OPEN the form whenever you add/remove alarm triggers.

Another thing to mention would be the Alarm_Desc.ini file, inside MyHMI\Data folder, which defines alarm descriptions for all PLCs:
          * The attached picture shows the format to be used for ini sections, which is "PLCx-Address", while alarm descriptions could be anything
          * Any quantity of alarms for any address is supported (see the current project file)

As usual, it will work with MODRSsim2 simulator as it is.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on July 02, 2018, 08:48:56 AM
Here is another option for using multiple datasources for alarming.  This was thrown together and more hard coded than I would like, but it's proof of concept.  My opinion is that the alarm list should be sequential and have unique IDs, so this accomplishes that.

This first data source, I was playing around with the data types...
Code: [Select]

Private Sub AlarmTriggers1_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles AlarmTriggers1.DataChanged

        Dim x1 As String = AlarmTriggers1.PLCAddressValueItems(0).LastValue
        If x1 <> "" Then
            AlarmArray(0) = Convert.ToInt32(x1)
            Console.WriteLine(AlarmArray(0))
            Active_Alarms(e.PlcAddress, AlarmArray(0), 0)
        End If

        Dim x2 As String = AlarmTriggers1.PLCAddressValueItems(1).LastValue
        If x2 <> "" Then
            AlarmArray(1) = Convert.ToInt32(x2)
            Console.WriteLine(AlarmArray(1))
            Active_Alarms(e.PlcAddress, AlarmArray(1), 1)
        End If

    End Sub


2nd data source...
Code: [Select]

    Private Sub AlarmTriggers2_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles AlarmTriggers2.DataChanged

        Dim x1 As String = AlarmTriggers2.PLCAddressValueItems(0).LastValue
        If x1 <> "" Then
            AlarmArray(2) = Convert.ToInt32(x1)
            Console.WriteLine(AlarmArray(2))
            Active_Alarms(e.PlcAddress, AlarmArray(2), 2)
        End If

        Dim x2 As String = AlarmTriggers2.PLCAddressValueItems(1).LastValue
        If x2 <> "" Then
            AlarmArray(3) = Convert.ToInt32(x2)
            Console.WriteLine(AlarmArray(3))
            Active_Alarms(e.PlcAddress, AlarmArray(3), 3)
        End If

    End Sub


So, I basically created tags (array) to hold the values of both data sources so everything is back in a logical order.  Then service the alarm code...

Code: [Select]

    Private Sub Active_Alarms(ByRef PLCAddress As String, ByRef PLCValue As String, ByRef i As Integer)

        If AlarmActiveini Is Nothing Then
            AlarmActiveini = New IniFile(AlarmActivePath)
        End If

        Dim Binary_Offset As Integer
        Binary_Offset = i * Binary_Length
        Dim dt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")

        For b = 0 To Binary_Length - 1
            Dim Shelved = AlarmActiveini.ReadValue("Alarm " & b + Binary_Offset & "", 7) 'Read Alarm Shelved State
            If Shelved = "" Then
                AlarmActiveini.WriteValue("Alarm " & b + Binary_Offset & "", 7, 0) 'If NULL/Nothing Then Set to a number (0)
            End If
            If (PLCValue And (1 << b)) <> 0 Then
                Dim result = AlarmActiveini.ReadValue("Alarm " & b + Binary_Offset & "", 3) 'Read Alarm Active State
                If result <> "1" Then
                    AlarmActiveini.WriteValue("Alarm " & b + Binary_Offset & "", 4, dt) 'If Alarm Active State Is Not 1 Then Set Active Time To Now
                    AlarmActiveini.WriteValue("Alarm " & b + Binary_Offset & "", 1, b + Binary_Offset) 'Set alarm #
                    Dim Count = AlarmActiveini.ReadValue("Alarm " & b + Binary_Offset & "", 8) 'Get Alarm Historical Count
                    If Count = "" Then
                        AlarmActiveini.WriteValue("Alarm " & b + Binary_Offset & "", 8, 1) 'If NULL/Nothing Then Set to a number (1)
                    Else
                        AlarmActiveini.WriteValue("Alarm " & b + Binary_Offset & "", 8, Count + 1) 'Increment count by 1
                    End If

                    Dim a = b + Binary_Offset
                    If Alarm_Quantity >= a AndAlso Alarm_Quantity > 0 Then 'Ignore alarm banner if alarm is greater than the alarm quantity
                        alarmName = AlarmActiveini.ReadValue("Alarm " & b + Binary_Offset & "", 2)
                        If Globals.Show_New_Alarm_Popup AndAlso Not Splash_Screen.Visible Then
                            Alarm_Banner.Alarm_Queue(dt, alarmName, b + Binary_Offset) 'Send alarm to list for alarm banner display
                        End If
                    End If
                    If Globals.Alarms_Text_To_Speech Then
                        If Not AlarmSpeechbw.IsBusy Then
                            AlarmSpeechbw.RunWorkerAsync()
                        End If
                    End If
                End If

                AlarmActiveini.WriteValue("Alarm " & b + Binary_Offset & "", 3, 1) 'Set Alarm Active State To 1
            Else
                Dim result = AlarmActiveini.ReadValue("Alarm " & b + Binary_Offset & "", 3) 'Read Alarm Active State
                Dim time = AlarmActiveini.ReadValue("Alarm " & b + Binary_Offset & "", 4) 'Read Alarm Fault Time
                If result <> "0" AndAlso time <> "" Then
                    AlarmActiveini.WriteValue("Alarm " & b + Binary_Offset & "", 5, dt) 'If Alarm Active State Is Not 0 Then Set Reset Time To Now
                    Dim alarmID = b + Binary_Offset
                    If Alarm_Quantity >= alarmID AndAlso Alarm_Quantity > 0 Then 'Ignore alarm history if alarm is greater than the alarm quantity
                        Alarm_History_Data(alarmID)
                    End If
                    If Globals.Show_New_Alarm_Popup AndAlso Not Splash_Screen.Visible Then
                        Alarm_Banner.Alarm_Search_Clear(b + Binary_Offset) 'Send alarm id to alarm banner list to clear if shown
                    End If
                End If
                AlarmActiveini.WriteValue("Alarm " & b + Binary_Offset & "", 3, 0) 'Set Alarm Active State To 0
            End If
        Next

        Populate_Active_Alarms_Table()

    End Sub


There are obviously things to clean up with this, but just wanted to share.

James
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on July 02, 2018, 06:24:27 PM
This last project was updated again and is now fully automated in adding/removing alarm triggers.
DataSubscribers had to be modified for this change.

See the previous post for description and the link to the project.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: nzflex on July 03, 2018, 04:18:56 PM
How would I add this control to my project ??
Title: Re: Sample App New Multistate with Designer and import/export
Post by: nzflex on July 03, 2018, 04:24:22 PM
One state at a time is fine for me :)
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on July 03, 2018, 05:21:06 PM
If I have time later I can create a guide. It's easy.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on July 03, 2018, 08:40:13 PM
Here's a quick guide, it assumes you know the basics.  If you don't, do some research or ask some questions.

I downloaded the latest beta:
https://www.advancedhmi.com/forum/index.php?topic=2058.msg12401#msg12401 (https://www.advancedhmi.com/forum/index.php?topic=2058.msg12401#msg12401)
and merged my application with it.  The steps should be the same or close to your application.

James

Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on July 05, 2018, 12:02:07 AM
There is alternative, a bit simpler way of adding these multi state controls without merging the whole project.

Some of the attached files have been modified and stripped.
You cannot benefit from Security, Audit and Database features - for these you need to follow the steps James listed.

It wouldn't surprise me if you find bugs or something that doesn't work (I think I checked all of it but...).

This is the list of files required for each control (you can add either or both controls):

BasicButtonMultistate                    Multistate
--------------------------                -------------------------

AHMIClassLibrary.dll                       AHMIClassLibrary.dll

BasicButtonMultistate.vb                Multistate.vb
ctrlBasicButton.vb                          ctrlMultiState.vb
BasicButtonDesigner.vb                  MultistateDesigner.vb
BasicButtonDesignerForm.vb          MultistateDesignerForm.vb
ColorPicker.vb                                ColorPicker.vb
AppModules.vb
Alignment.vb
Padding_Ctrl.vb
ImageSelector.vb
ResourceImages.vb

As you can see, the only common files for both controls are the dll file and ColorPicker.

These are the steps to add these controls to existing AHMI project:

1) Download the attached Resources.7z file and extract all the files
2) Right-click the AdvancedHMIControls project and click Properties, point to Resources and under Images add as Existing Item all the extracted files

3) Download the attached MultistateControls.7z file and extract all the files
4) Add a new folder to the AdvancedHMIControls\PurchasedControls folder and name it "MultistateControls"
5) Right-click this new folder, point to Add and click Existing Item
6) Browse to location of the extracted files and select AHMIClassLibrary.dll
    - once this file is added then add it as a reference to both AdvancedHMI and AdvancedHMIControls projects
7) Keep repeating step 5 for each of the files that you require from the above list (this means add them one by one)
    - don't add any files that are not in the list. All other files will be added automatically

8) Close all open forms and rebuild solution

Use the built-in Editor (designer) to manipulate the Messages.

The button control is slightly different since I chose to have the Highlight/HighlightAlternate properties be standalone and of a higher priority than either of the states back colors.
This makes the button control a sort of the quad state control.

You can use the attached Messages Import Test.txt file to test the import feature of the Multistate control.

There is even simpler way of adding the MultiState control in the reply #58, further below.

Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on October 04, 2018, 02:10:04 PM
Here is an updated version.  I made some major changes to alarming to speed things up.  What I noticed was after 300 or 400 alarms, the app would slow down and become choppy.  The sample app is already compiled with close to 1000 alarms, I think 980ish.  It's pretty fast now.  Start the Modbus sim, which is part of the zip file and test away.  I also made it easier to add alarms, now just add in collection.  However, it's limited to one PLC.  I didn't have time to work on multi PLC support.  Maybe one day.

I tested as best as possible, but there may be a bug or two that pops up.

https://drive.google.com/file/d/1yGLF1Vk7fS1XSQjXIKPNouUwz0J399zk/view?usp=sharing (https://drive.google.com/file/d/1yGLF1Vk7fS1XSQjXIKPNouUwz0J399zk/view?usp=sharing)
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Alpaslan on February 03, 2019, 01:02:35 AM
Hi,

I did this procedure within document. I deleted EthernetIPforCLXCom1 because it does't exist in my system. However everytime i build project it comes back.

Ho can i get rid of it?

Edit: Now there are two of them.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on February 03, 2019, 07:50:53 AM
Yeah, I'm not sure it's a bug in the data subscriber, but it's definitely annoying. What I do is comment out the code in the datasubcriber so it will no longer try and create a com component. If I have time later today I'll send a screenshot or two on how to do it.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Alpaslan on February 03, 2019, 11:06:17 AM
Now there is six of them although i delete them. İ already searched within documents and deleted all where i found within every resx and vb document. However there are six of them. I Will look again.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on February 03, 2019, 12:11:33 PM
Go to AdvancedHMIControls, Components, then look for DataSubscriber2.  Select it, then hit F7 to open code.  Under basic properties region, mine is line 77, comment out...
Code: [Select]
'm_ComComponent = AdvancedHMIDrivers.Utilities.GetComComponent(Me.Site.Container)

That will prevent this from happening, BUT, it will also prevent all instances from adding a com component if it needs one.  Personally, I would rather add on my own.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: Alpaslan on February 03, 2019, 02:01:10 PM
Thanks. Problem has been solved.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on May 20, 2019, 03:07:06 AM
hello
could this multistate be used with multiple registers?
as in my case now

i have 3 registers to read from
each register have multiple values

for example
the registers are d300 , d301 ,d302

the values and messages  for d300
0 = nothimng
1= openning door 1
2= alarm -
 
the states are for d301
0 = nothing
1= closing  door 1
2= alarm 2 - somthing in the way

and so on


so how can i make it happen ?

and i already add the multistate to my project using Godra way
https://www.advancedhmi.com/forum/index.php?topic=2079.msg12429#msg12429


but i don`t realy know how to use it :(





Title: Re: Sample App New Multistate with Designer and import/export
Post by: Phrog30 on May 20, 2019, 09:38:44 AM
could this multistate be used with multiple registers?
No.  That really defeats the main purpose of the multistate in my opinion.  If you use multiple connections you will need to do in code, or try one of the existing controls already in AHMI.

The multistate only shows one value at a time, so if you used multiple connections how would you pick which one is displayed. 

I think you should use alarming instead.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: oqapsking on May 20, 2019, 03:08:50 PM
in this case am using 3 buttons each button when i click on it it activates one register
so it only displays one state of the registers and you can`t click on both buttons at the same time
i can do it in the code but i thought to ask if it possible to do it this way

Title: Re: Sample App New Multistate with Designer and import/export
Post by: Godra on April 20, 2020, 12:53:26 AM
Related to the reply #48, here is a bit simplified way of adding the MultiState control (as suggested by the user MajorFault in the topic that was removed):

1) Download the attached MultistateControls.7z file and extract all the files
2) Add a new folder to the AdvancedHMIControls\PurchasedControls folder and name it "MultistateControls"
3) Right-click this new folder, point to Add and click Existing Item, browse to the location of the extracted files and select AHMIClassLibrary.dll
    - once this file is added then add it as a reference to both AdvancedHMI and AdvancedHMIControls projects
4) Right-click this new folder, point to Add and click Existing Item, browse to the location of the extracted files and select MultiState.vb file

5) Close all open forms and rebuild solution

This is a slightly modified version of the original ctrlMultiState.vb file.
Designers are not included so you only have 2 files to deal with.

It appears to work fine.

Title: Re: Sample App New Multistate with Designer and import/export
Post by: Alpaslan on April 07, 2021, 04:09:27 PM
Hi,

Over the years i am here. However i couldn't achive adding alarms to this project.

I used the editor page (ahmi_ask_1.png) but then? I stopped. There is two files Alarms.ini and Alarm_Desc.ini which i don't understand how to use them.

I connect to S7-1200 with Modbus TCP.

My alarms are bitwise. For example 40001.1 4001.2

Is there any smart man to help me?

Thanks a lot.
Title: Re: Sample App New Multistate with Designer and import/export
Post by: MajorFault on April 07, 2021, 07:52:02 PM
It's been far too long since I've worked on that project, but you really don't need to worry about the INI files.

To start, I would work with a modbus simulator. Get that working then move over to Siemens.