Author Topic: Dynamically loading ModbusRTUCom and BasicDataLogger  (Read 1333 times)

vitico bon

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Dynamically loading ModbusRTUCom and BasicDataLogger
« on: November 11, 2016, 11:36:35 PM »
Hi, I am attempting to load a group of Com and Logger controls in a form but since there is not documentation I am now stuck trying to find all the parameters that need to be code to make this work. I think that I have already most of them but need a litter push to get this done. Maybe there is a sample that I can follow. So far I can't find the way to pass the loaded ComComponent just loaded to the BasicDataLogger control. Here is a piece of my infant code. Other than that, after being working for only a week with this I found it extremely good and very useful. It is a great job what all of you are doing. Thanks.

Here goes my spaghetti code:

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

        Dim Port(8) As AdvancedHMIDrivers.ModbusRTUCom
        Dim ComCom(8) As MfgControl.AdvancedHMI.Drivers.IComComponent
        Dim Logger(16) As AdvancedHMIControls.BasicDataLogger
        Dim Address(16) As MfgControl.AdvancedHMI.Drivers.PLCAddressItem
        Dim S As String

        ' Port(0).
        Port(0).PortName = "COM1"
        Port(0).BaudRate = 19200
        Port(0).DataBits = 8
        Port(0).Parity = Ports.Parity.Odd
        Port(0).PollRateOverride = 100
        Port(0).StationAddress = 1
        Port(0).StopBits = Ports.StopBits.One
        Port(0).SwapBytes = True
        Port(0).SwapWords = False
        Port(0).TimeOut = 3000
        Port(0).ToString()



        Logger(0).ComComponent = ComCom(0)
        Logger(0).FileFolder = Path.GetDirectoryName(Application.ExecutablePath) & "\DATA"
        Logger(0).FileName = "PLCDataLog1.dlog"
        Logger(0).LogInterval = 1000
        Logger(0).LogTriggerType = AdvancedHMIControls.BasicDataLogger.TriggerType.TimeInterval

        Address(0).PLCAddress = "F428675"
        Logger(0).PLCAddressValue = Address(0)
        Logger(0).TimeStampFormat = "dd-MMM-yy HH:mm:ss"


    End Sub


 
« Last Edit: November 13, 2016, 05:00:54 PM by vitico bon »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Dynamically loading ModbusRTUCom and BasicDataLogger
« Reply #1 on: November 12, 2016, 08:47:50 AM »
Try it like this:
Code: [Select]
        Dim Port(16) As AdvancedHMIDrivers.ModbusRTUCom
        Dim Logger(16) As AdvancedHMIControls.BasicDataLogger

        ' Port(0).
        Port(0) = New AdvancedHMIDrivers.ModbusRTUCom
        Port(0).PortName = "COM1"
        Port(0).BaudRate = 19200
        Port(0).DataBits = 8
        Port(0).Parity = IO.Ports.Parity.Odd
        Port(0).PollRateOverride = 100
        Port(0).StationAddress = 1
        Port(0).StopBits = IO.Ports.StopBits.One
        Port(0).SwapBytes = True
        Port(0).SwapWords = False
        Port(0).TimeOut = 3000


        Logger(0) = New AdvancedHMIControls.BasicDataLogger
        Logger(0).BeginInit()

        Logger(0).ComComponent = Port(0)
        Logger(0).FileFolder = System.IO.Path.GetDirectoryName(Application.ExecutablePath) & "\DATA"
        Logger(0).FileName = "PLCDataLog1.dlog"
        Logger(0).LogInterval = 1000
        Logger(0).LogTriggerType = AdvancedHMIControls.BasicDataLogger.TriggerType.TimeInterval

        Logger(0).PLCAddressValue = New MfgControl.AdvancedHMI.Drivers.PLCAddressItem("F428675")
        Logger(0).TimeStampFormat = "dd-MMM-yy HH:mm:ss"

        Logger(0).EndInit()

vitico bon

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Dynamically loading ModbusRTUCom and BasicDataLogger
« Reply #2 on: November 12, 2016, 10:20:18 AM »
Great, It is working!
Thank you soo much for your help.