52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace StacjaProb
|
|
{
|
|
public partial class ModbusServerConfigForm : Form
|
|
{
|
|
public ModbusServerConfigForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void ModbusServerConfigForm_Load(object sender, EventArgs e)
|
|
{
|
|
inSterownikIP.Text = vGlobal.vModbus_hostname;
|
|
inSterownikPort.Text = vGlobal.vModbus_port;
|
|
}
|
|
|
|
private void inButtonOK_Click(object sender, EventArgs e)
|
|
{
|
|
modBusFunctions.CloseConnection();
|
|
|
|
const string userRoot = "HKEY_CURRENT_USER\\SoftSPM";
|
|
|
|
vGlobal.vModbus_hostname = inSterownikIP.Text;
|
|
vGlobal.vModbus_port = inSterownikPort.Text;
|
|
|
|
Microsoft.Win32.Registry.SetValue(userRoot + "\\SPM_TST", "MODBUS_TCP", inSterownikIP.Text);
|
|
Microsoft.Win32.Registry.SetValue(userRoot + "\\SPM_TST", "MODBUS_PORT", inSterownikPort.Text);
|
|
|
|
|
|
modBusFunctions.initConnection();
|
|
if (!modBusFunctions.isConnected)
|
|
MessageBox.Show("Problem z połączeniem z serwerem Modbus TCP");
|
|
else
|
|
{
|
|
modBusFunctions.isConnected = false;
|
|
//ReadWriteFile.SaveDbAccessConfig();
|
|
this.Close();
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|