Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Godra

Pages: 1 2 [3] 4
31
Additional Components / ButtonControlArray
« on: January 19, 2017, 10:37:37 PM »
This is an array of standard button controls (see the attached picture).

To be used AS IS or to serve as an example of how to go about creating an array of identical controls.

Most controls are somehow unique when it comes to their properties and it might get somewhat tricky to create an array as a single control.
AHMI controls should be considered even trickier, as this example shows:
https://www.advancedhmi.com/forum/index.php?topic=2132.msg12265#msg12265

Read the comments inside the file to find out what modifications might be necessary to make this control work the way you want it.

Most of the time it should be easier to just drop a bunch of the same controls onto the form.

Edit: This control was last updated on May 06, 2020.


32
Additional Components / Ping Button
« on: December 16, 2016, 09:12:21 PM »
This is a button control that allows you to ping a computer.
It supports multiple entries in the form of IPv4 address or a hostname (use the control's IPAddressCollection property to create a list).
Also, check the attached pictures to see what it could look like.

It is related to this topic:

http://advancedhmi.com/forum/index.php?topic=1555.0

and includes Archie's code.

Do report bugs so I can try to fix them.

33
Additional Components / RadioButton as AHMI Control
« on: December 13, 2016, 11:04:49 PM »
Most of it is actually Archie's code from the CheckBox control.

Be aware that if you set the PLCAddressChecked property then it will be controlling the checked state of the RadioButton (clicking the button in this case will only have momentary effect). This seems to apply to the CheckBox control as well.

34
The attached control is a button to start the Windows On-Screen Keyboard (mainly to be used with touchscreens).

No path is specified so hopefully all versions of Windows will be handling it properly (Windows 7 does).

35
Additional Components / BasicButton - Multi Address/Value Write
« on: October 29, 2016, 07:40:57 PM »
The attached control is a modified BasicButton control.

It was created to support writing multiple values to multiple addresses with a single click of the button. This could be useful for presets (zeroing or setting identical value to bunch of PLC addresses) or repetitive writes. Multiple buttons can be used to point to the same PLCAddresses but write different values.

The following would be a representation of how the control could be used:

     Single Address       -    Single Value to write to this address
     Single Address       -    Multiple Values to write to the range starting with this address
     Multiple Addresses  -    Single Value to write to each address
     Multiple Addresses  -    Multiple Values to write to each range starting with each address

The button's property PLCAddressClickItems holds PLCAddresses (it has replaced PLCAddressClick property but provides the same functionality if single address is used). Each item independently allows for ScaleFactor and ScaleOffset values.

The button's property ValueToWrite holds values (which is array of strings). It represents NumberOfElements that will be written with the driver's BeginWrite function.

There is a new property ValueToWriteType which defines whether ScaleFactor and ScaleOffset are applied to the value before it is written to the destination address. NumericType writes scaled numeric values and StringType just writes the string as it is. The string doesn't have to be numerical but then its destination has to be able to accept string <-- the example could be AB ST9:x addresses. Writing strings with Modbus is not implemented since it is quite complex to integrate into this control (at the end of this post, there is an example of how to go about writing/reading a string value with Modbus). <-- Modbus String writing for this button control might work properly in v3.99y+ since Archie implemented that functionality into drivers

For this all to work, the button's OtputType property has to be set to WriteValue.
Any other setting will still use defined PLCAddresses but will be using True/False values only, as intended.

If you need to use the code to receive values then you might try using this control's ClickItemsDataReturned event. Here is a code example for Modbus, knowing that F40001 and F40011 addresses were subscribed to, with 2 elements each:

Code: [Select]
    Private Sub BasicButtonMulti1_ClickItemsDataReturned(sender As Object, e As AdvancedHMIControls.SubscriptionHandlerEventArgs) Handles BasicButtonMulti1.ClickItemsDataReturned
        If e.PLCComEventArgs.PlcAddress.Equals("F40001") Then
            Label2.Text = e.PLCComEventArgs.Values(0)
            Label3.Text = e.PLCComEventArgs.Values(1)
        ElseIf e.PLCComEventArgs.PlcAddress.Equals("F40011") Then
            Label4.Text = e.PLCComEventArgs.Values(0)
            Label5.Text = e.PLCComEventArgs.Values(1)
        End If
    End Sub

You could as well try using the drivers DataReceived event.

Try to understand all of the above before attempting to use the control.

The control was tested to a degree with MODRSSim simulator and RSLogix Emulate 500. It might have bugs and is offered AS IS.

----------------- M O D B U S ------------------

Here is a possible way of writing a string (str) with Modbus by using the BeginWrite function of the driver inside some sub (maybe a Click event of a button named btnWrite):

Code: [Select]

    Private str As String = "123abc"

... Some Sub ...

    'Format to write is: startAddress As String, numberOfElements As Integer, dataToWrite() As String
    ModbusTCPCom1.BeginWrite("40061", str.Length, ConvertStringToStringOfIntegers(str))

... Some Sub ...

    Private Function ConvertStringToStringOfIntegers(ByVal str As String) As String()
        '* Convert string to an array of bytes
        Dim ByteArray(str.Length - 1) As Byte
        ByteArray = System.Text.Encoding.Default.GetBytes(str)

        '* Convert each byte to integer and then convert this integer to its string representation and store it in the string array
        Dim ints(ByteArray.Length - 1) As String
        For i = 0 To ByteArray.Length - 1
            ints(i) = CStr(CInt(ByteArray(i)))
        Next

        '* Return the string array
        Return ints
    End Function

Holding registers, 4xxxx addresses, should be used to store a string as an array of integers.

In order to read the string, this exact array of integers has to be read and converted back to string inside some sub (maybe a Click event of a button named btnRead), and the string could be shown on some standard label:

Code: [Select]
... Some Sub ...

    'For example, we could initiate the read and then use DataReceived event of the driver
    'Format to read is: startAddress As String, numberOfElements As Integer
    ModbusTCPCom1.BeginRead("40061", str.Length)

... Some Sub ...

    Private Sub ModbusTCPCom1_DataReceived(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles ModbusTCPCom1.DataReceived
        If e.PlcAddress.Equals("40061") Then
            Dim ints(e.Values.Count - 1) As String
            For i = 0 To e.Values.Count - 1
                ints(i) = e.Values(i)
            Next
            Label6.Text = ConvertStringOfIntegersToString(ints)
        End If
    End Sub

    Private Function ConvertStringOfIntegersToString(ByVal ints() As String) As String
        '* Convert integer values to strings and then to an array of bytes
        Dim ByteArray(ints.Length - 1) As Byte
        For i = 0 To ints.Length - 1
            ByteArray(i) = CByte(CStr(ints(i)))
        Next

        '* Convert the array of bytes to a string
        Dim result As String
        result = System.Text.Encoding.UTF8.GetString(ByteArray)

        'Return the string
        Return result
    End Function

Archie already explained some of this here: https://www.advancedhmi.com/forum/index.php?topic=1301.msg6918#msg6918

I slightly modified his code.

36
Additional Components / KeypadPopUp as a button control
« on: August 24, 2016, 06:30:00 PM »
For those who might need a control like this, attached is a KeypadPopUp Control in the form of a button.

You can drop it on the form and associate with multiple PLCAddressKeypad entries. Right-clicking the button will pop-up a menu with available addresses to choose from (at Runtime, the control will default to the first address entered).

Might be useful if you need a keypad with controls that don't have it built-in.

37
Additional Components / Rotating Image
« on: August 21, 2016, 09:27:18 PM »
This control, just like the RotatingWheel control from other topic, is intended to show possible VB Net code for Rotation, Horizontal and/or Vertical image flip, limiting the control's paint region (thanks to Archie) and some other code that can be used when creating your own controls.

The main difference from the RotatingWheel control is that this control manipulates existing images. It doesn't custom draw any image besides for the built-in image which is loaded when no other image is selected. The attached picture is actually the one that's built-in/hardcoded and has transparent background (its code should be the same as what you would see if opening this picture in any HEX editor).

This control is practically round shaped with its circle diameter being equal to the image's diagonal, to allow the image rotate without having its corners being cut off. You can see the circle if you change the controls BackColor.

If you do find a use for the control as it is, then good for you.

This control is AHMI control but additional PLC properties can be added if needed.

The "RI_RotationAngle" property of this control is defined as Single value with -360 to 360 range.
The "Value" property of this control is defined as Boolean value and, when set to True, will start Perpetual Rotation of the loaded image (so will the mouse DoubleClick event at Runtime).
The "PLCAddressDirectionOfPerpetualRotation" property of this control can be targeting either Boolean or Integer address to provide "0" or "1" value to change the direction of perpetual rotation.

If you set the PLCAddressRI_RotationAngle property, which will then have a PLC provide angle value, the Perpetual Rotation will not be active.
If you set the PLCAddressValue property, the mouse DoubleClick event will not be active.


38
Additional Components / Rotating Wheel
« on: July 31, 2016, 11:26:29 PM »
This control is intended to show possible VB Net code for Rotation, Horizontal and/or Vertical image flip, limiting the control's paint region (thanks to Archie), 3D effects and some other code that can be used when creating your own controls.

If you do find a use for the control as it is, then good for you.

This control is AHMI control.

The "RW_RotationAngle" property of this control is defined as Single value with -360 to 360 range.
The "Value" property of this control is defined as Boolean value and, when set to True, will start Perpetual Rotation of the loaded image (so will the mouse DoubleClick event at Runtime).
The "PLCAddressDirectionOfPerpetualRotation" property of this control can be targeting either Boolean or Integer address to provide "0" or "1" value to change the direction of perpetual rotation.

If you set the PLCAddressRW_RotationAngle property, which will then have a PLC provide angle value, the Perpetual Rotation will not be active.
If you set the PLCAddressValue property, the mouse DoubleClick event will not be active.

39
Just tried a fresh v3.99d solution with a basic button and basic label.

BasicButton throws the attached error when using EthernetIPforSLCMicro driver but works fine with ModbusTCP driver.
BasicButton reads value properly with PLCAddressText property.

BasicLabel works fine in either case.

Also tried GlassButton from other post and it worked as well.

40
Additional Components / NumericUpDown as AHMI control
« on: March 29, 2016, 07:33:08 PM »
This is my attempt at converting NumericUpDown control to AHMI control.

It is using PLCAddressValue property to both read from and write to (tried it with ModRSSim simulator and it worked fine).

Its ReadOnly property is initially set to True, so it will only allow changing value with arrows (change it if you want to manually enter the value in the box).

First file is for older versions of AHMI and the second one is for v3.99d.

Check later posts for updated controls.

41
Additional Components / Rotational Position Indicator
« on: January 26, 2016, 10:54:17 AM »
As the title states, this is a rotational position indicator.

It should be sufficient to add the files as an "Existing Item" to PurchasedControls folder.

Read the comments section inside the file itself for features.

Get files from Archie's post below or just use AHMI v3.99m+ (those are updated versions of the control from this post).

42
Related to this topic: http://advancedhmi.com/forum/index.php?topic=899.0

Would it be possible to convert either of these 2 drivers to be able to access COM based PLCs over ethernet?

The SerialToIP server provides transparent access to a PLC connected to COM port so it would have to be the driver to properly access the PLC and issue correct commands.

43
Tips & Tricks / Add control to a property grid
« on: July 31, 2015, 01:38:05 AM »
For those who might find it useful, here is a link that shows how to add NumericUpDown control to a property grid:

http://stackoverflow.com/questions/14291291/how-to-add-numericupdown-control-to-custom-property-grid-in-c

It is in C# but can be converted to VB Net and modified to produce the results as in the attached pictures. So far I've tried the NumericUpDown and TrackBar controls but the logic suggests that other controls could be added as well.

This way a user can select numbers directly, which "Enum" statement doesn't seem to be capable of, and the range could be adjusted for example to show only odd or only even numbers or increment the value any way you'd like. It is generally suitable for predefined range of values.

A new class might need to be created for different properties if the range and type of values are different.

Here is another link with identical subject that is presented in rather colorful way, that has code in VB Net:

http://www.codeproject.com/Articles/28984/Rich-Design-Time-Editing-with-UITypeEditors-VB-NET

Actually, this might be a better choice for those who decide to give it a try.

Here is an example of control that is using both NumericUpDown and Trackbar:
https://www.advancedhmi.com/forum/index.php?topic=673.msg4955#msg4955

44
Archie,

So far, I tried this only in version 3.98t.

If DisableSubscriptions is set to True initially then it is observed until changed.
But once it is set to False it just stays subscribed regardless of how I set it afterwards through the code of a button click event (this button is used to enable/disable subscriptions).

Any thoughts?

45
Additional Components / Rotating Text Button with Custom Text Colors
« on: July 11, 2015, 02:00:56 PM »
For those who might need to have a vertical or eventually upside-down text on the button, here is one possible solution.

It also allows selecting 2 custom colors for gradient fill.

Some fonts will produce symbols instead of letters (like Webdings font or Wingdings or ...) so exercise caution since error messages might appear in that same font.

Pages: 1 2 [3] 4