Skip to content

Commit fc81866

Browse files
committed
Add enum ConnectionType, selecting connection on panel
1 parent 37133bc commit fc81866

5 files changed

+93
-38
lines changed

Clusterization_algorithms.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
</ItemGroup>
4848
<ItemGroup>
4949
<Compile Include="Calculator.cs" />
50+
<Compile Include="ConnectionType.cs" />
5051
<Compile Include="EnergyCalculator.cs" />
5152
<Compile Include="Forel.cs" />
5253
<Compile Include="Form1.cs">

ConnectionType.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Clusterization_algorithms
8+
{
9+
enum ConnectionType
10+
{
11+
DT_to_Center, //direct transmittion, send to center of cluster (station static position)
12+
DT_to_Route, // *to closer point on station route
13+
PP_to_Center, // Point to point
14+
PP_to_Route
15+
}
16+
}

EnergyCalculator.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,32 @@ public Dictionary<Point, int> GetNodesChargeDictionary()
4848
return chargeList;
4949
}
5050

51-
public void CalculteAllNodesEnergy(Dictionary<Point, int> nodesClustered, List<Point> routeList, int stationHeight) {
51+
public void CalculteAllNodesEnergy(ConnectionType connectionType, Dictionary<Point, int> nodesClustered, List<Point> routeList, int stationHeight) {
5252

5353
for (int i = 1; i < routeList.Count - 1; i++) {
5454
List<Point> cluster = Calculator.getClusterList(i, nodesClustered);
55-
//Start_DT_Protocol(cluster, stationHeight);
56-
Start_DT_ToCloserPositionOnWay(cluster, stationHeight, routeList);
5755

56+
switch (connectionType) {
57+
58+
case ConnectionType.DT_to_Center:
59+
Start_DT_Protocol(cluster, stationHeight);
60+
break;
61+
62+
case ConnectionType.DT_to_Route:
63+
Start_DT_ToRoute(cluster, stationHeight, routeList);
64+
break;
65+
66+
case ConnectionType.PP_to_Center:
67+
break;
68+
69+
case ConnectionType.PP_to_Route:
70+
break;
71+
}
5872

5973
}
6074
}
6175

62-
public void Start_DT_ToCloserPositionOnWay(List<Point> cluster, int stationHeight, List<Point> routeList) { // transmission while station moving on route
76+
public void Start_DT_ToRoute(List<Point> cluster, int stationHeight, List<Point> routeList) { // transmission while station moving on route
6377
Point center = Calculator.findCentroid(cluster);
6478
List<Point> routeFragment = Calculator.getRouteFragment(center, routeList);
6579

Form1.Designer.cs

Lines changed: 35 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Form1.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,29 @@ private void DrawAllSavedObjects() {
222222

223223
private void btnCalcEnergy_Click(object sender, EventArgs e) {
224224
DrawAllSavedObjects();
225-
energyCalculator.CalculteAllNodesEnergy(allPointsClustered, routeBuilder.RouteList, ReadStationHeighth());
225+
226+
ConnectionType connectionType = ConnectionType.DT_to_Center;
227+
228+
switch (comboBoxConnectionType.SelectedIndex) {
229+
230+
case 0:
231+
//by default
232+
break;
233+
234+
case 1:
235+
connectionType = ConnectionType.DT_to_Route;
236+
break;
237+
238+
case 2:
239+
connectionType = ConnectionType.PP_to_Center;
240+
break;
241+
242+
case 3:
243+
connectionType = ConnectionType.PP_to_Route;
244+
break;
245+
}
246+
247+
energyCalculator.CalculteAllNodesEnergy(connectionType, allPointsClustered, routeBuilder.RouteList, ReadStationHeighth());
226248
PrintToTextBoxInfo(allPointsClustered);
227249
}
228250

0 commit comments

Comments
 (0)