hey everyone, got a small problem here.
I'm building an application that has settings built into the form for changing the DataSubscriber ComComponent as well as the PLCAdressValue at run-time. i am currently doing this with the BasicIndicator with success but the problem is that the DataSubscriber doesn't seem to want to change the setting that it was given at development. i have tried doing it at the time of form load and after everything is running. do i have to re-initiate the connection? or is it supposed to happen automatically? is there a bug? an i missing something? help is appreciated.
Here are some snippets of code:
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles Me.Load
MessageCenterDisplay.AppendText("*******************************************************" & System.Environment.NewLine & "Start Time: " & DateAndTime.Now & System.Environment.NewLine & "*******************************************************" & System.Environment.NewLine)
EthernetIPforSLCMicro.IPAddress = My.Settings.IP_Address
IPDriverAddressDisplay.Text = EthernetIPforSLCMicro.IPAddress
Lbl_PLC_Tag.Text = DataSubscriberPrint.PLCAddressValue.PLCAddress
FilePath.Text = My.Settings.File_Path
TemplateName.Text = My.Settings.Template_Name
FileExtension.Text = My.Settings.File_Extension
DataSubscriberPrint.PLCAddressValue.PLCAddress = My.Settings.PLC_Tag
ChboxMicrologix.CheckState = My.Settings.MicroLogixPLC_selected
ChboxControlLogix.CheckState = My.Settings.ControlLogixPLC_Selected
' ' If ChboxMicrologix.CheckState = 1 Then
' DataSubscriber1.ComComponent = EthernetIPforSLCMicro
' IndicatorPrintRequested.ComComponent = EthernetIPforSLCMicro
' End If
' If ChboxControlLogix.CheckState = 1 Then
' DataSubscriber1.ComComponent = EthernetIPforCLXCom1
' IndicatorPrintRequested.ComComponent = EthernetIPforCLXCom1
' End If
End Sub
Private Sub Bttn_Save_Trigger_Settings_Click(sender As Object, e As EventArgs) Handles Bttn_Save_Trigger_Settings.Click
If txt_PLC_Tag.Text <> "" Then
Try
'Loads the settings into the PLC Tag setting
DataSubscriberPrint.PLCAddressValue.PLCAddress = txt_PLC_Tag.Text
Lbl_PLC_Tag.Text = DataSubscriberPrint.PLCAddressValue.PLCAddress
IndicatorPrintRequested.PLCAddressSelectColor2 = txt_PLC_Tag.Text
txtIndicatorCom.Text = DataSubscriberPrint.ComComponent.ToString
Catch ex As MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException
If ex.ErrorCode = 1808 Then
MsgBox(" PLC Address not found")
Else
MsgBox(ex.Message)
End If
Catch ex As Exception
'* V3.99w - Catch a more general exception
MsgBox("GE. " & ex.Message)
End Try
MessageCenterDisplay.AppendText("Tag Address Save Successful" & " " & TimeOfDay & System.Environment.NewLine)
MessageCenterDisplay.ScrollToCaret()
Else
MessageCenterDisplay.AppendText("Tag Value Cannot be Null" & " " & TimeOfDay & System.Environment.NewLine)
MessageCenterDisplay.ScrollToCaret()
End If
End Sub
Private Sub MainForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Dim index As Integer
While index < My.Application.OpenForms.Count
If My.Application.OpenForms(index) IsNot Me Then
My.Application.OpenForms(index).Close()
End If
index += 1
End While
'save settings while form closing
My.Settings.IP_Address = EthernetIPforSLCMicro.IPAddress
My.Settings.File_Path = FilePath.Text
My.Settings.Template_Name = TemplateName.Text
My.Settings.File_Extension = FileExtension.Text
My.Settings.PLC_Tag = DataSubscriberPrint.PLCAddressValue.PLCAddress
My.Settings.MicroLogixPLC_selected = ChboxMicrologix.CheckState
My.Settings.ControlLogixPLC_Selected = ChboxControlLogix.CheckState
'Generate File for History
MessageCenterDisplay.AppendText("*******************************************************" & System.Environment.NewLine & "End Time: " & DateAndTime.Now & System.Environment.NewLine & "*******************************************************" & System.Environment.NewLine)
Dim StorageDirectory As String = FilePath.Text & "\"
Dim Path As String = FilePath.Text & "\" & "Print History" & "." & "RTF"
MessageCenterDisplay.SaveFile(Path)
End Sub