Author Topic: using class with AdvancedHMI  (Read 3347 times)

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: using class with AdvancedHMI
« Reply #15 on: December 27, 2018, 10:23:59 AM »
If you tell me what your objective is (not your solution for the problem), I can give you better examples. Why do you want to put this in another class?

MEDALI1TN

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Re: using class with AdvancedHMI
« Reply #16 on: December 27, 2018, 10:39:49 AM »
I have a lot of variables and a lot of connection to different database tables.
As all the code is written under the MainForm, each time the program executes all the code.
when i open the app it can stay 10 min for it to appear.
Also it become very difficult to understand.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: using class with AdvancedHMI
« Reply #17 on: December 27, 2018, 09:13:46 PM »
It sounds like maybe the thing to do is to extend the BasicDataLogger to write to a database instead of a file. Are you just logging values to a database on a time interval?

Phrog30

  • Guest
Re: using class with AdvancedHMI
« Reply #18 on: December 28, 2018, 12:17:36 AM »
You should consider posting your application so we can take a closer look. Use OneDrive, Google drive, Dropbox, etc. The part about taking 10 minutes is interesting.

MEDALI1TN

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
Re: using class with AdvancedHMI
« Reply #19 on: December 29, 2018, 07:31:40 AM »
Hello,
I do not use the the BasicDataLogger.
i use this code (exemple with one variable) :

Code: [Select]

  Dim conString As String = "server=localhost;userid=root;password=;database=my_database"
            Using con As New MySqlConnection(conString)
                Using cmd As New MySqlCommand
                    With cmd
                        .Connection = con
                        .CommandText = "insert into my_database.my_table (var1) values (@var1)"
                        .CommandType = CommandType.Text
                        .Parameters.AddWithValue("@var1", var1)
                   
                    End With
                    Try
                        con.Open()
                        cmd.ExecuteNonQuery()
                        con.Close()
                    Catch ex As MySqlException
                        MessageBox.Show(ex.Message + System.Environment.NewLine, "MySQL Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    End Try
                End Using
            End Using


if the BasicDataLogger is better, please told me how can i use it in order to have the same result.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: using class with AdvancedHMI
« Reply #20 on: December 29, 2018, 07:55:42 AM »
Hello,
I do not use the the BasicDataLogger.
i use this code (exemple with one variable) :
if the BasicDataLogger is better, please told me how can i use it in order to have the same result.
It depends how you log data. If you log on an interval or event, then you can extend the BasicDataLogger to write to a DB. That would then allow you to encapsulate all of your data logging away from your MainForm and into a separate component.

aquilmustafa

  • Full Member
  • ***
  • Posts: 121
    • View Profile
Re: using class with AdvancedHMI
« Reply #21 on: February 20, 2019, 11:21:57 PM »
Hey Archie,

Can u please help me modify this class of yours to work with Micrologix-1400 PLC.