@@ -37,14 +37,50 @@ def activate(self, callingWindow, fullContext, mainItem, i):
37
37
fitID = self .mainFrame .getActiveFit ()
38
38
fit = Fit .getInstance ().getFit (fitID )
39
39
cleanInput = re .sub (r'[^0-9.]' , '' , dlg .input .GetLineText (0 ).strip ())
40
-
41
40
if mainItem in fit .drones :
42
41
position = fit .drones .index (mainItem )
43
42
self .mainFrame .command .Submit (cmd .GuiSplitLocalDroneStackCommand (
44
43
fitID = fitID , position = position , amount = int (cleanInput )))
45
44
46
45
46
+ class DroneSplitStackBandwidth (DroneSplitStack ):
47
+ """
48
+ Split drone stack to match ship's available bandwidth, ensuring that only
49
+ one of the stacks is active so as not to exceed the bandwidth limit.
50
+ """
51
+ def getText (self , callingWindow , itmContext , mainItem ):
52
+ return "Split {} Stack to Fit Max Bandwidth" .format (itmContext )
53
+
54
+ def activate (self , callingWindow , fullContext , mainItem , i ):
55
+ fitID = self .mainFrame .getActiveFit ()
56
+ fit = Fit .getInstance ().getFit (fitID )
57
+ bandwidth_per_drone = fit .drones [0 ].item . \
58
+ attributes ['droneBandwidthUsed' ].value
59
+ ship_bandwidth = fit .ship .item .attributes ['droneBandwidth' ].value
60
+ max_active_drones = int (ship_bandwidth / bandwidth_per_drone )
61
+ if max_active_drones == 0 :
62
+ wx .MessageDialog (
63
+ None , "Cannot split drone stack to fit bandwidth. Each drone "
64
+ "uses {0} mbit/s and this ship only has {1} mbit/s."
65
+ .format (int (bandwidth_per_drone ), int (ship_bandwidth )),
66
+ "Ship drone bandwidth exceeded" , wx .OK | wx .ICON_ERROR
67
+ ).ShowModal ()
68
+ else :
69
+ if max_active_drones > 5 :
70
+ max_active_drones = 5
71
+
72
+ if mainItem in fit .drones :
73
+ position = fit .drones .index (mainItem )
74
+ self .mainFrame .command .Submit (
75
+ cmd .GuiSplitLocalDroneStackCommand (fitID = fitID ,
76
+ position = position ,
77
+ amount = max_active_drones ,
78
+ deactivate = True )
79
+ )
80
+
81
+
47
82
DroneSplitStack .register ()
83
+ DroneSplitStackBandwidth .register ()
48
84
49
85
50
86
class DroneStackSplit (wx .Dialog ):
0 commit comments