Skip to content

Commit

Permalink
WARNING! Breaking Change!
Browse files Browse the repository at this point in the history
The Connection configuration is now using Enumerations and Timespans where apropiate. This means existing code, using the configuration class directly might break. The configuration file also changed, but the system can load both, the new and old one! So the Configuration file loading mechanism is backwards compatible.

1. Changed int to corresponding Enumerations in PLCConnectionConfiguration and created new Enums where needed.

2. Changed ConnectionConfiguration Loading code, to minimize Breaking change impact. When the Connection file can not be loaded, it tries to fix the existing file and then retries once more. This means, the Configuration file is stil backwards compatible!

3. Timeouts are now defined as Timespan and not as int. PLCConnection is making apropiate use where necesary.

4. Refactored PLCConnection to use Enumerations

5. Refactored PLCConnection.Connect for better readability

6. Change ConnectionEditor so that the Timeout is now edited as miliseconds instead of microseconds. Internally it is an timespan anyway and the PLCConnection still converts it to Microseconds apropiatly

7. Addes lots of Comments to configuration parameters
  • Loading branch information
Stefan Hasensperling authored and Stefan Hasensperling committed Nov 1, 2016
1 parent c1a4aee commit cd59c27
Show file tree
Hide file tree
Showing 8 changed files with 1,633 additions and 1,593 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,16 @@ private void LoadSettings()
txtWritePort.Text = myConfig.WritePort.ToString();
txtLIBNODAVELokalMPI.Text = myConfig.LokalMpi.ToString();
lstLIBNODAVELokalCOMPort.SelectedItem = myConfig.ComPort;
if (myConfig.ComPortParity == 'e')
if (myConfig.ComPortParity == LibNodaveConnectionBusParity.even)
lstLIBNODAVELokalComParity.SelectedItem = "even";
else if (myConfig.ComPortParity == 'o')
else if (myConfig.ComPortParity == LibNodaveConnectionBusParity.odd)
lstLIBNODAVELokalComParity.SelectedItem = "odd";
else
lstLIBNODAVELokalComParity.SelectedItem = "none";
lstLIBNODAVELokalComSpeed.SelectedItem = myConfig.ComPortSpeed;

EnumListBoxExtensions.SelectEnumListItem(lstLIBNODAVEConnectionType, myConfig.ConnectionType);
EnumListBoxExtensions.SelectEnumListItem(lstLIBNODAVEBusSpeed, myConfig.BusSpeed);
EnumListBoxExtensions.SelectEnumListItem(lstLIBNODAVEConnectionType, (int)myConfig.ConnectionType);
EnumListBoxExtensions.SelectEnumListItem(lstLIBNODAVEBusSpeed, (int)myConfig.BusSpeed);

txtRoutingDestination.Text = myConfig.RoutingDestination;
txtRoutingRack.Text = myConfig.RoutingDestinationRack.ToString();
Expand All @@ -183,15 +183,15 @@ private void LoadSettings()
txtRoutingSubnetFirst.Text = myConfig.RoutingSubnet1.ToString("X");
txtRoutingSubnetSecond.Text = myConfig.RoutingSubnet2.ToString("X");

txtTimeout.Text = myConfig.Timeout.ToString();
txtTimeoutIPConnect.Text = myConfig.TimeoutIPConnect.ToString();
txtTimeout.Text = myConfig.Timeout.TotalMilliseconds.ToString();
txtTimeoutIPConnect.Text = myConfig.TimeoutIPConnect.TotalMilliseconds.ToString();

chkNetlinkReset.Checked = myConfig.NetLinkReset;

chkUseShortRequest.Checked = myConfig.UseShortDataBlockRequest;

lstConnType.SelectedIndex = myConfig.PLCConnectionType;
lstConnTypeRouting.SelectedIndex = myConfig.RoutingPLCConnectionType;
lstConnType.SelectedIndex = (int)myConfig.PLCConnectionType;
lstConnTypeRouting.SelectedIndex = (int)myConfig.RoutingPLCConnectionType;

cmdUndo.Visible = false;
cmdSave.Visible = false;
Expand Down Expand Up @@ -226,15 +226,15 @@ private void updateConfig()
myConfig.ComPortSpeed = lstLIBNODAVELokalComSpeed.SelectedItem.ToString();

if (lstLIBNODAVELokalComParity.SelectedItem.ToString() == "even")
myConfig.ComPortParity = 'e';
myConfig.ComPortParity = LibNodaveConnectionBusParity.even;
else if (lstLIBNODAVELokalComParity.SelectedItem.ToString() == "odd")
myConfig.ComPortParity = 'o';
myConfig.ComPortParity = LibNodaveConnectionBusParity.odd;
else
myConfig.ComPortParity = 'n';
myConfig.ComPortParity = LibNodaveConnectionBusParity.none;

myConfig.ConnectionType = lstLIBNODAVEConnectionType.SelectedItem != null ? ((EnumListItem)lstLIBNODAVEConnectionType.SelectedItem).Value : 0;
myConfig.ConnectionType = (LibNodaveConnectionTypes)(lstLIBNODAVEConnectionType.SelectedItem != null ? ((EnumListItem)lstLIBNODAVEConnectionType.SelectedItem).Value : 0);

myConfig.BusSpeed = lstLIBNODAVEBusSpeed.SelectedItem != null ? ((EnumListItem)lstLIBNODAVEBusSpeed.SelectedItem).Value : 0;
myConfig.BusSpeed = (LibNodaveConnectionBusSpeed)(lstLIBNODAVEBusSpeed.SelectedItem != null ? ((EnumListItem)lstLIBNODAVEBusSpeed.SelectedItem).Value : 0);

myConfig.NetLinkReset = chkNetlinkReset.Checked;

Expand All @@ -247,11 +247,11 @@ private void updateConfig()
myConfig.RoutingSubnet1 = Convert.ToInt32(txtRoutingSubnetFirst.Text, 16);
myConfig.RoutingSubnet2 = Convert.ToInt32(txtRoutingSubnetSecond.Text, 16);

myConfig.Timeout = Convert.ToInt32(txtTimeout.Text);
myConfig.TimeoutIPConnect = Convert.ToInt32(txtTimeoutIPConnect.Text);
myConfig.Timeout = TimeSpan.FromMilliseconds(Convert.ToInt32(txtTimeout.Text));
myConfig.TimeoutIPConnect = TimeSpan.FromMilliseconds(Convert.ToInt32(txtTimeoutIPConnect.Text));

myConfig.PLCConnectionType = lstConnType.SelectedIndex;
myConfig.RoutingPLCConnectionType = lstConnTypeRouting.SelectedIndex;
myConfig.PLCConnectionType = (LibNodaveConnectionResource)lstConnType.SelectedIndex;
myConfig.RoutingPLCConnectionType = (LibNodaveConnectionResource)lstConnTypeRouting.SelectedIndex;
}

private void SaveSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ ADVERTENCIA: Conexiones de otros Software hacia Netlinka tambien seran desconect
<value>92, 13</value>
</data>
<data name="lblTimeout.Text" xml:space="preserve">
<value>Tiempo de espera</value>
<value>Timeout</value>
</data>
<data name="lblTimeout.ToolTip" xml:space="preserve">
<value>Tiempo de espera de los datos de la CPU</value>
Expand Down Expand Up @@ -325,15 +325,6 @@ ADVERTENCIA: Conexiones de otros Software hacia Netlinka tambien seran desconect
<data name="lblLIBNODAVELokalComParity.ToolTip" xml:space="preserve">
<value />
</data>
<data name="lstLIBNODAVELokalComParity.Items" xml:space="preserve">
<value>Ninguno</value>
</data>
<data name="lstLIBNODAVELokalComParity.Items1" xml:space="preserve">
<value>par</value>
</data>
<data name="lstLIBNODAVELokalComParity.Items2" xml:space="preserve">
<value>impar</value>
</data>
<data name="lstLIBNODAVELokalComParity.ToolTip" xml:space="preserve">
<value />
</data>
Expand Down
Loading

0 comments on commit cd59c27

Please sign in to comment.