Skip to content

Commit 7e9bcca

Browse files
committed
FunkMan v0.4.0
**FunkSock** - Changed key and values in EvalData function to be compatible with DCSSererBot **FunkPlot** - matplotlib uses "Agg" backend **Misc** - Added trapsheet test file
1 parent 80d4a98 commit 7e9bcca

File tree

5 files changed

+105
-30
lines changed

5 files changed

+105
-30
lines changed

funkman/funkbot/funkbot.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,20 @@ async def on_ready(self):
7070
# Init FunkPlot.
7171
funkyplot=FunkPlot()
7272

73-
# Trap sheet file.
74-
trapfile="./testfiles/Trapsheet-FA-18C_hornet-001.csv"
73+
# Trap sheet files.
74+
trapfiles=["./testfiles/Trapsheet-FA-18C_hornet-001.csv", "./testfiles/Trapsheet-FA-18C_hornet-002.csv"]
7575

76-
# Get result from trap file.
77-
result=getResultTrap(trapfile)
76+
for trapfile in trapfiles:
7877

79-
# Test LSO embed.
80-
self.SendLSOEmbed(result, self.channelID)
78+
# Get result from trap file.
79+
result=getResultTrap(trapfile)
8180

82-
# Test trap.
83-
f1, a1=testTrap(funkyplot, trapfile)
84-
self.SendFig(f1, self.channelID)
81+
# Test LSO embed.
82+
self.SendLSOEmbed(result, self.channelID)
83+
84+
# Test trap.
85+
f1, a1=testTrap(funkyplot, trapfile)
86+
self.SendFig(f1, self.channelID)
8587

8688
# Test bomb.
8789
f2, a2=testBomb(funkyplot)

funkman/funkplot/funkplot.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ def PlotBombRun(self, result):
112112
Creates a bomb run figure for a given result table.
113113
"""
114114

115+
# Set matplotlib backend.
116+
matplotlib.use('Agg')
117+
plt.ioff()
118+
115119
# Length of axes.
116120
zmax=195
117121

@@ -227,6 +231,10 @@ def PlotStrafeRun(self, result):
227231
Creates a strafe run figure for a given result table.
228232
"""
229233

234+
# Set matplotlib backend.
235+
matplotlib.use('Agg')
236+
plt.ioff()
237+
230238
# Get info from result table.
231239
player=_GetVal(result, "player", "GhostRider")
232240
actype=_GetVal(result, "airframe", "Unknown AC")
@@ -338,6 +346,10 @@ def PlotTrapSheet(self, result):
338346
Creates trapsheet figure for a given player data table.
339347
"""
340348

349+
# Set matplotlib backend.
350+
matplotlib.use('Agg')
351+
plt.ioff()
352+
341353
# Trapsheet data.
342354
try:
343355
trapsheet=result["trapsheet"]
@@ -422,16 +434,6 @@ def PlotTrapSheet(self, result):
422434
# Set figure size. Needed to have the carrier images in the right place!
423435
fig.set_size_inches(8, 6)
424436

425-
# Set matplotlib backend.
426-
#matplotlib.use('Agg')
427-
#plt.ioff()
428-
429-
# Annotation box with Carrier data.
430-
#offsetbox = TextArea(f'{carriername}\n{carriertype}\nCase {case}\nWind {windondeck}',
431-
#textprops={"alpha": 0.8, "color": "lightsteelblue", "backgroundcolor": PlotColor.FACE.value})
432-
#ab = AnnotationBbox(offsetbox, (1.0, 1.08), xycoords='figure fraction', horizontalalignment='right', verticalalignment="top") #, boxcoords='axes fraction')
433-
#axs[0].add_artist(ab)
434-
435437
# second annotation relative to the axis limits
436438
bbox_props = dict(boxstyle="round, pad=0.5", fc=PlotColor.FACE.value, ec="lightsteelblue", lw=1)
437439

@@ -450,7 +452,7 @@ def PlotTrapSheet(self, result):
450452
# These are the CVN images:
451453

452454
# Top-down view.
453-
axs[0].figure.figimage(self.imageCVNtop, 1000, 370, alpha=0.45, zorder=1, clip_on=True)
455+
axs[0].figure.figimage(self.imageCVNtop, 1000, 347, alpha=0.45, zorder=1, clip_on=True)
454456

455457
# Side view.
456458
axs[0].figure.figimage(self.imageCVNside, 1000, 567, alpha=0.45, zorder=1, clip_on=True)
@@ -471,8 +473,8 @@ def PlotTrapSheet(self, result):
471473
# Set axis.
472474
ax = axs[1]
473475

474-
# y-axis limit
475-
#ax.set_ylim([-401,801])
476+
# y-axis limit.
477+
ax.set_ylim([-501,901])
476478

477479
# Line up referece line.
478480
if angledRunway:

funkman/funksock/funksock.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class FunkSocket(socketserver.UDPServer):
5050
UDP socket server. It inherits "socketserver.UDPServer".
5151
"""
5252

53-
def __init__(self, Host="127.0.0.1", Port=10123) -> None:
53+
def __init__(self, Host="127.0.0.1", Port=10042) -> None:
5454

5555
super().__init__((Host, Port), FunkHandler)
5656

@@ -104,10 +104,16 @@ def EvalData(self, table):
104104
print(table)
105105
print("--------------------------------------")
106106

107+
key="command"
108+
textmessage="moose_text"
109+
bombresult="moose_bomb_result"
110+
straferesult="moose_strafe_result"
111+
lsograde="moose_lso_grade"
112+
107113
# Treat different cases.
108-
if "dataType" in table:
114+
if key in table:
109115

110-
if table["dataType"]=="Text Message":
116+
if table[key]==textmessage:
111117
print("Got text message!")
112118

113119
# Extract text.
@@ -116,7 +122,7 @@ def EvalData(self, table):
116122
# Send text to Discord.
117123
self.funkbot.SendText(text, self.channelIDmessage)
118124

119-
if table["dataType"]=="Bomb Result":
125+
if table[key]==bombresult:
120126
print("Got bomb result!")
121127

122128
# Create bomb run figure.
@@ -125,7 +131,7 @@ def EvalData(self, table):
125131
# Send figure to Discord.
126132
self.funkbot.SendFig(fig, self.channelIDrange)
127133

128-
elif table["dataType"]=="Strafe Result":
134+
elif table[key]==straferesult:
129135
print("Got strafe result!")
130136

131137
# Create strafe run figure.
@@ -134,7 +140,7 @@ def EvalData(self, table):
134140
# Send figure to discord.
135141
self.funkbot.SendFig(fig, self.channelIDrange)
136142

137-
elif table["dataType"]=="Trap Sheet":
143+
elif table[key]==lsograde:
138144
print("Got trap sheet!")
139145

140146
# Send LSO grade.

funkman/utils/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def getResultStrafe():
1313

1414
# Result.
1515
resultStrave = {
16-
"dataType": "Strafe Result",
16+
"command": "moose_strafe_result",
1717
"player": "funkyfranky",
1818
"name": "My Target",
1919
"clock": "9:45:01",
@@ -34,7 +34,7 @@ def getResultBomb():
3434

3535
# Result.
3636
result={
37-
"dataType": "Bomb Result",
37+
"command": "moose_bomb_result",
3838
"name": "Target Name",
3939
"distance": randint(5,300),
4040
"radial": randint(1,360),
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#Time,Rho,X,Z,Alt,AoA,GSE,LUE,Vtot,Vy,Gamma,Pitch,Roll,Yaw,Step,Grade,Points,Details
2+
0.00,1.153,2298.3,37.1,332.3,8.69,-0.88,-8.03,180.7,161.0,52.8,7.2,-41.7,-0.0,X0,OK,4.0,
3+
0.50,1.141,2275.0,72.3,333.4,9.20,-0.84,-7.10,180.0,110.3,49.5,7.1,-44.2,-0.0,X0,OK,4.0,
4+
1.00,1.128,2250.2,105.9,334.1,10.06,-0.81,-6.19,179.2,49.3,45.7,7.2,-46.7,-0.0,X0,OK,4.0,
5+
1.50,1.115,2223.9,137.7,334.2,10.16,-0.78,-5.30,178.6,-28.0,42.3,6.9,-48.5,-0.0,X0,OK,4.0,
6+
2.00,1.101,2195.9,167.6,333.5,10.35,-0.75,-4.44,178.9,-123.4,38.8,6.5,-50.1,-0.0,X0,OK,4.0,
7+
2.50,1.087,2166.3,195.6,332.1,10.53,-0.73,-3.61,179.3,-224.2,35.2,6.1,-51.3,-0.0,X0,OK,4.0,
8+
3.00,1.071,2135.0,221.5,329.7,9.74,-0.71,-2.81,179.7,-344.7,32.5,5.4,-50.5,-0.0,X0,OK,4.0,
9+
3.50,1.055,2102.2,245.4,326.2,9.28,-0.70,-2.04,180.3,-462.5,30.0,4.9,-48.5,-0.0,X0,OK,4.0,
10+
4.00,1.038,2068.0,267.1,322.0,9.91,-0.69,-1.31,181.0,-547.5,26.5,5.0,-47.9,-0.0,X0,OK,4.0,
11+
4.50,1.021,2032.6,286.7,317.3,10.40,-0.69,-0.60,181.5,-586.9,22.8,5.2,-48.4,-0.0,X0,OK,4.0,
12+
5.00,1.003,1996.1,303.9,312.2,10.25,-0.69,0.06,181.8,-633.0,19.5,4.8,-49.4,-0.0,X0,OK,4.0,
13+
5.50,0.984,1958.6,318.6,306.5,10.07,-0.69,0.68,182.4,-713.0,16.2,4.2,-50.6,-0.0,X0,OK,4.0,
14+
6.00,0.965,1920.2,330.8,300.2,10.39,-0.69,1.25,182.9,-809.3,12.6,4.1,-51.5,-0.0,X0,OK,4.0,
15+
6.50,0.945,1881.0,340.4,293.1,10.73,-0.70,1.77,183.4,-890.7,8.9,4.1,-51.0,-0.0,X0,OK,4.0,
16+
7.00,0.925,1841.3,347.2,285.4,10.80,-0.72,2.22,183.8,-939.6,5.6,4.2,-49.7,-0.0,X0,OK,4.0,
17+
7.50,0.904,1801.1,351.2,277.5,10.78,-0.74,2.61,184.2,-960.0,2.4,4.3,-48.5,-0.0,X0,OK,4.0,
18+
8.00,0.883,1760.7,352.4,269.5,10.85,-0.76,2.93,184.7,-955.2,0.9,4.5,-47.2,-0.0,X0,OK,4.0,
19+
8.50,0.861,1720.1,351.0,261.7,10.95,-0.77,3.17,185.0,-905.3,3.7,5.2,-43.5,-0.0,X0,OK,4.0,
20+
9.00,0.839,1679.6,346.9,254.8,10.56,-0.78,3.33,185.3,-751.7,5.8,5.9,-38.4,-0.0,X0,OK,4.0,
21+
9.50,0.817,1639.2,340.5,249.4,9.23,-0.77,3.42,185.7,-556.3,7.1,5.9,-34.7,-0.0,X0,OK,4.0,
22+
10.00,0.795,1599.1,332.1,245.4,8.42,-0.74,3.44,186.4,-410.4,8.5,6.0,-31.4,-0.0,X0,OK,4.0,
23+
10.50,0.773,1559.0,321.9,242.8,8.58,-0.69,3.39,187.0,-218.3,10.0,7.0,-27.2,-0.0,X0,OK,4.0,
24+
11.00,0.750,1519.2,310.1,242.1,8.24,-0.62,3.28,187.4,63.1,10.7,8.0,-21.1,-0.0,X0,OK,4.0,
25+
11.50,0.728,1479.7,297.0,243.8,6.42,-0.52,3.11,187.7,341.9,10.3,7.4,-13.3,-0.0,XX,OK,4.0,
26+
12.00,0.706,1440.4,283.2,247.1,3.96,-0.39,2.89,186.9,437.2,10.0,5.3,-7.7,-0.0,XX,--,2.0,F(LO)_OS_X
27+
12.50,0.684,1401.5,269.2,250.3,2.87,-0.25,2.66,185.5,357.2,10.1,3.9,-5.2,-0.0,XX,--,2.0,_F_(LO)_OS_X
28+
13.00,0.662,1363.0,255.2,252.9,2.52,-0.12,2.40,184.0,264.1,10.3,3.3,-1.1,-0.0,XX,--,2.0,_F_(LO)_OS_X
29+
13.50,0.640,1324.9,241.1,254.5,1.97,0.01,2.12,182.5,137.3,10.3,2.4,7.1,-0.0,XX,--,2.0,_F_(LO)_OS_X
30+
14.00,0.619,1287.1,227.5,254.9,1.80,0.13,1.84,181.1,-28.3,10.0,1.8,11.2,-0.0,XX,--,2.0,_F_(LO)_OS_X
31+
14.50,0.597,1249.6,214.3,253.9,1.30,0.24,1.56,179.7,-200.6,9.6,0.8,12.0,-0.0,XX,--,2.0,_F_(LO)_OS_X
32+
15.00,0.576,1212.2,201.5,251.1,1.43,0.32,1.28,178.6,-449.3,8.9,0.2,11.9,-0.0,XX,--,2.0,_F_(LO)_OS_X
33+
15.50,0.555,1175.0,189.3,246.7,3.45,0.39,1.00,177.4,-599.3,7.8,1.6,11.4,-0.0,XX,--,2.0,_F_(LO)_OS_X
34+
16.00,0.535,1138.0,177.6,241.8,4.19,0.44,0.73,176.0,-599.2,6.9,2.3,11.4,-0.0,XX,--,2.0,_F_(LO)_OS_X
35+
16.50,0.514,1101.2,166.4,236.6,3.52,0.50,0.47,174.7,-644.5,6.3,1.4,11.5,-0.0,XX,--,2.0,/_F_(LO)_OS_X
36+
17.00,0.493,1064.6,155.8,230.8,3.91,0.55,0.22,173.7,-746.7,5.6,1.4,11.0,-0.0,IM,--,2.0,/_F_(LO)_OS_X
37+
17.50,0.473,1028.2,145.6,224.5,4.75,0.60,-0.03,172.5,-758.4,4.9,2.2,11.0,-0.0,IM,--,2.0,/_F_(LO)_OS_X _F_(H)IM
38+
18.00,0.453,992.0,136.1,218.1,4.19,0.64,-0.26,171.1,-765.9,4.4,1.6,11.8,-0.0,IM,--,2.0,/_F_(LO)_OS_X _F_(H)IM
39+
18.50,0.433,956.1,127.0,211.3,3.56,0.68,-0.48,169.7,-855.5,4.0,0.7,11.9,-0.0,IM,--,2.0,/_F_(LO)_OS_X _F_(H) (DL)IM
40+
19.00,0.413,920.4,118.5,203.8,3.97,0.71,-0.68,168.2,-958.3,3.3,0.8,10.9,-0.0,IM,--,2.0,/_F_(LO)_OS_X _F_(H) (DL)IM
41+
19.50,0.394,885.1,110.6,195.6,4.76,0.72,-0.87,166.5,-1009.5,2.6,1.3,9.8,-0.0,IM,--,2.0,/_F_(LO)_OS_X _F_(HLUL) (DL)IM
42+
20.00,0.375,850.1,103.1,187.0,5.02,0.72,-1.05,164.7,-1035.8,2.0,1.4,9.2,-0.0,IM,--,2.0,/_F_(LO)_OS_X _F_(HLUL) (DL)IM
43+
20.50,0.356,815.5,96.1,178.2,5.12,0.71,-1.21,163.1,-1081.0,1.4,1.3,7.9,-0.0,IM,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM
44+
21.00,0.337,781.2,89.5,169.1,5.65,0.69,-1.36,162.0,-1111.5,0.9,1.7,5.9,-0.0,IM,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM
45+
21.50,0.318,747.1,83.2,159.9,6.17,0.67,-1.50,162.1,-1100.5,0.5,2.3,5.0,-0.0,IM,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM
46+
22.00,0.299,712.7,77.0,151.0,6.15,0.66,-1.63,163.3,-1043.1,0.2,2.4,5.3,-0.0,IM,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM
47+
22.50,0.280,677.9,71.1,142.4,5.31,0.65,-1.77,164.1,-1012.7,0.1,1.7,6.1,-0.0,IM,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM
48+
23.00,0.261,643.1,65.4,133.8,4.98,0.64,-1.88,163.9,-1051.6,0.3,1.3,5.8,-0.0,IM,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM
49+
23.50,0.242,608.4,60.0,124.9,5.41,0.63,-1.99,163.1,-1077.4,0.4,1.7,4.9,-0.0,IC,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM
50+
24.00,0.223,573.9,54.8,115.9,5.47,0.60,-2.09,161.9,-1077.1,0.6,1.8,4.7,-0.0,IC,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC
51+
24.50,0.205,539.7,49.8,106.8,5.17,0.57,-2.18,160.5,-1106.7,0.9,1.3,4.0,-0.0,IC,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC
52+
25.00,0.186,505.8,45.1,97.4,5.40,0.50,-2.26,159.2,-1165.2,1.2,1.2,3.0,-0.0,IC,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC
53+
25.50,0.168,472.3,40.6,87.5,6.13,0.41,-2.33,158.6,-1192.5,1.5,1.8,2.7,-0.0,IC,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC
54+
26.00,0.150,438.7,36.1,77.7,6.62,0.31,-2.40,159.2,-1165.6,1.8,2.4,2.8,-0.0,IC,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC
55+
26.50,0.131,404.7,31.8,68.3,6.54,0.20,-2.46,161.0,-1111.8,2.1,2.6,2.9,-0.0,IC,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC
56+
27.00,0.113,370.3,27.5,59.2,6.28,0.10,-2.51,163.2,-1055.6,2.4,2.6,2.9,-0.0,IC,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC
57+
27.50,0.093,335.2,23.3,50.7,5.98,0.01,-2.54,165.1,-996.3,2.6,2.5,1.9,-0.0,IC,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC
58+
28.00,0.074,299.8,19.2,42.5,5.40,-0.07,-2.54,165.4,-963.5,2.4,2.2,-0.4,-0.0,IC,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC
59+
28.50,0.055,264.5,15.1,34.4,5.05,-0.18,-2.54,165.2,-971.6,2.0,1.8,-2.1,-0.0,IC,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC
60+
29.00,0.036,229.2,10.9,26.3,5.30,-0.34,-2.58,165.0,-989.9,1.6,1.9,-2.8,-0.0,AR,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC
61+
29.50,0.017,193.9,6.6,18.1,5.65,-0.63,-2.71,164.8,-983.6,1.2,2.3,-2.3,-0.0,AR,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC _F_(LO)LULAR
62+
30.00,-0.003,158.8,2.2,10.0,5.75,-1.15,-3.06,164.6,-955.5,1.0,2.5,-2.5,-0.0,AR,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC _F_(LO)LULAR
63+
30.50,-0.022,123.7,-2.3,2.5,4.39,-2.38,-4.21,164.5,-832.0,0.8,1.6,-2.8,-0.0,AR,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC _F_(LO)LULAR
64+
31.00,-0.041,88.8,-7.0,-0.4,-0.96,-5.06,-27.96,163.2,6.4,0.8,-0.9,0.0,-0.0,AR,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC _F_(LO)LULAR
65+
31.50,-0.060,54.2,-11.6,-0.3,-0.36,-3.67,-178.07,158.8,-1.4,1.1,-0.4,-0.0,-0.0,AR,--,2.0,/_F_(LO)_OS_X _F_(H)LUL (DL)IM _F_(H)LULIC _F_(LO)LULAR

0 commit comments

Comments
 (0)