Author Topic: Multistate with embedded variables - Value, LSB, & Bit Array  (Read 11739 times)

Phrog30

  • Guest
Multistate with embedded variables - Value, LSB, & Bit Array
« on: February 03, 2019, 09:08:33 PM »
There have been a few requests for a multistate that works with bit arrays.  Here is a rough draft.  This control can use values, LSB, or bit arrays.  Values will only show one value at a time.  LSB will only show one value at a time... the LSB.  However, bit will cycle through all high bits in the array.  You can still take advantage of embedded variables and the state colors and options.  I didn't work out what to show for word 0 bit 0, maybe I can add a default message?

https://drive.google.com/file/d/1jmsMc-JoSFKvO-EJsQZ71nrA1HYimoFv/view?usp=sharing

It was done while watching the superbowl, so expect a bug or two.  I installed the control in Archies beta v18.  Download, rebuild, and you should be good to go.  I tested with ModbusSim.  I used ini file, which is also included.
« Last Edit: February 03, 2019, 09:10:07 PM by Phrog30 »

Tazmahal

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #1 on: February 04, 2019, 12:57:57 AM »
I've succesfully add it to my project  :D  Man I wish I were as good as you are !

Works perfectly !

Phrog30

  • Guest
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #2 on: February 04, 2019, 07:55:28 AM »
All credit goes to Archie.  All I did was add to his stuff, and it's pretty hacked up.  I don't think I really did it correctly.  It should behave like LSB, but cycle through all bits high.  It does cycle, but I think it's one bit off, on the low side.  Which makes sense because you should be able to set a message for state 0, this would be the state where no bits are high.  So, try making a change, in AdvancedHMI, purchased folder, select ctrlMultistate and hit F7 to open code.  Go to line 403 and 404, change "b + Binary_Offset" to b + 1 + Binary_Offset".  Should look like this...

Code: [Select]
If IsNumeric(b + 1 + Binary_Offset) Then
      dr("#") = b + 1 + Binary_Offset
End If

Let me  know what you think.  Also, I suggest using the ini where possible.  I think it's lighter weight and faster, especially if you have a lot of states.  The easiest method is add a few states in development, then export.  Use this file and edit in excel or something.  You can bang a file out quick. 

If you like the change, I will edit the code and repost.

Tazmahal

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #3 on: February 04, 2019, 08:50:26 AM »
I’ll try that tonight !

For the ini file , I don’t know what i’m doing wrong but it just don’t work.. For now I just load the txt and edit in the designer but if you reload it, you lost your blinking settings. Will give a another look !

Thanks Phrog! and hats down to you Archie  ;)

Phrog30

  • Guest
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #4 on: February 04, 2019, 09:49:11 AM »
If the path isn't correct, the INI will not work.

If you import the INI it will overwrite everything.  If you have under a couple hundred states, doing it in the designer will be fine.

Tazmahal

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #5 on: February 04, 2019, 09:38:46 PM »
I've inclued Alarm.txt in my project in folder \Purchased
So the path must be Purchased\Alarm.txt , but always getting Undefined message bit etc..

In the alarm.txt each line is like ; 1,QUAD: ALARME MOTEUR POMPE HYDRAULIQUE ENTRAINEMENT,,-65536,,-16777216,True

 I got over 1000 states

I've also tried to put in the main folder and try .\Alarme.txt , \Alarme.txt , Alarme.txt

Phrog30

  • Guest
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #6 on: February 05, 2019, 07:51:17 AM »
If you created a folder under AdvancedHMI project called "Purchased", and your file is called "Alarm.txt", the path should be "Purchased\Alarm.txt".  So, sounds like you had the correct path.  Make sure you set copy to output directory to copy if newer or copy always.  See attached photo.

Tazmahal

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #7 on: February 12, 2019, 05:38:05 PM »
Thanks Phrog ! Working now  ;)


Phrog30

  • Guest
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #8 on: February 12, 2019, 07:32:21 PM »
Thanks Phrog ! Working now  ;)
Glad to hear. See any issues so far? Was that what you were looking for?

Tazmahal

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #9 on: February 13, 2019, 12:51:30 PM »
Exactly what I'm looking for !! And no issues  ;D

Thanks again !

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #10 on: May 09, 2019, 02:15:23 PM »
HELLO
AND THANK U FOR SHARING

BUT I HAVE A PROBLEM

I EXTRACTED THE FILE
THEN STARTED IT
REBUILD THE PROJECT

BUT GIVES MULTIPLE ERRORS

AS IN THE PHOTOS


Phrog30

  • Guest
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #11 on: May 10, 2019, 08:05:34 AM »
HELLO
AND THANK U FOR SHARING

BUT I HAVE A PROBLEM

I EXTRACTED THE FILE
THEN STARTED IT
REBUILD THE PROJECT

BUT GIVES MULTIPLE ERRORS

AS IN THE PHOTOS



You added the reference? It looks like you did. The error is related to the reference in some way. I'm limited on time until Monday.

Godra

  • Hero Member
  • *****
  • Posts: 1448
    • View Profile
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #12 on: May 10, 2019, 01:23:21 PM »
That yellow triangle with exclamation mark indicates that something is missing and needs to be resolved first.

It probably relates to incorrect file path or inability to locate the file.

Maybe remove it and then manually browse to it to add it again.

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #13 on: May 11, 2019, 01:54:48 PM »
i didn`t add or remove anything
just extracted the files and rebuild the project


Godra

  • Hero Member
  • *****
  • Posts: 1448
    • View Profile
Re: Multistate with embedded variables - Value, LSB, & Bit Array
« Reply #14 on: May 11, 2019, 03:13:39 PM »
I just did the same and got the same errors since the AHMIClassLibrary.dll file is missing.

You can get it from the other project: https://www.advancedhmi.com/forum/index.php?topic=2079.0

It is inside AdvancedHMI/MyHMI/DLL folder.