forked from thomas-pythonas/saspy
-
Notifications
You must be signed in to change notification settings - Fork 6
/
sas.py
3533 lines (3016 loc) · 118 KB
/
sas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
# -*- coding: utf8 -*-
import serial
import time
import binascii
import logging
import datetime
from utils import Crc
from utils.Decorators import deprecated
from multiprocessing import log_to_stderr
from models import *
from error_handler import *
__author__ = "Zachary Tomlinson, Antonio D'Angelo"
__credits__ = ["Thomas Pythonas", "Grigor Kolev"]
__license__ = "MIT"
__version__ = "2.0.0"
__maintainer__ = "Zachary Tomlinson, Antonio D'Angelo"
__status__ = "Staging"
class Sas:
"""Main SAS Library Class"""
def __init__(
self,
port, # Serial Port full Address
timeout=2, # Connection timeout
poll_address=0x82, # Poll Address
denom=0.01, # Denomination
asset_number="01000000", # Asset Number
reg_key="0000000000000000000000000000000000000000", # Reg Key
pos_id="B374A402", # Pos ID
key="44", # Key
debug_level="DEBUG", # Debug Level
perpetual=False, # When this is true the lib will try forever to connect to the serial
check_last_transaction=True,
wait_for_wake_up=0.00,
):
# Let's address some internal var
self.poll_timeout = timeout
self.address = None
self.machine_n = None
self.check_last_transaction = check_last_transaction
self.denom = denom
self.asset_number = asset_number
self.reg_key = reg_key
self.pos_id = pos_id
self.transaction = None
self.my_key = key
self.poll_address = poll_address
self.perpetual = perpetual
self.wait_for_wake_up = wait_for_wake_up
# Init the Logging system
self.log = log_to_stderr()
self.log.setLevel(logging.getLevelName(debug_level))
self.last_gpoll_event = None
# Open the serial connection
while 1:
try:
self.connection = serial.Serial(
port=port,
baudrate=19200,
timeout=timeout,
)
self.close()
self.timeout = timeout
self.log.info("Connection Successful")
break
except:
if not self.perpetual:
self.log.critical(
"Error while connecting to the machine....Quitting..."
)
exit(1) # Make a graceful exit since it's expected behaviour
self.log.critical("Error while connecting to the machine....")
time.sleep(1)
return
def is_open(self):
return self.connection.is_open
def flush(self):
try:
if self.is_open() == False:
self.open()
self.connection.flush()
except Exception as e:
self.log.error(e, exc_info=True)
def flush_hard(self):
"""Flush the serial buffer in input and output"""
try:
if not self.is_open():
self.open()
self.connection.reset_output_buffer()
self.connection.reset_input_buffer()
except Exception as e:
self.log.error(e, exc_info=True)
# self.close()
def start(self):
"""Warm Up the connection to the VLT"""
self.log.info("Connecting to the machine...")
while True:
if not self.is_open():
try:
self.open()
if not self.is_open():
self.log.error("Port is NOT open")
except SASOpenError:
self.log.critical("No SAS Port")
except Exception as e:
self.log.critical(e, exc_info=True)
else:
self.connection.reset_output_buffer()
self.connection.reset_input_buffer()
response = self.connection.read(1)
if not response:
self.log.error("No SAS Connection")
time.sleep(1)
if response != b"":
self.address = int(binascii.hexlify(response))
self.machine_n = response.hex()
self.log.info("Address Recognized " + str(self.address))
break
else:
self.log.error("No SAS Connection")
time.sleep(1)
self.close()
return self.machine_n
def close(self):
"""Close the connection to the serial port"""
self.connection.close()
def open(self):
"""Open connection to the VLT"""
try:
if self.connection.is_open is not True:
self.connection.open()
except:
raise SASOpenError
def _conf_event_port(self):
"""Do magick to make SAS Happy and work with their effing wakeup bit"""
self.open()
self.connection.flush()
self.connection.timeout = self.poll_timeout
self.connection.parity = serial.PARITY_NONE
self.connection.stopbits = serial.STOPBITS_TWO
self.connection.reset_input_buffer()
def _conf_port(self):
"""As per _conf_event_port Do magick to make SAS Happy and work with their effing parity"""
self.open()
self.connection.flush()
self.connection.timeout = self.timeout
self.connection.parity = serial.PARITY_MARK
self.connection.stopbits = serial.STOPBITS_ONE
self.connection.reset_input_buffer()
def _send_command(
self, command, no_response=False, timeout=None, crc_need=True, size=1
):
"""Main function to physically send commands to the VLT"""
try:
buf_header = [self.address]
self._conf_port()
buf_header.extend(command)
if crc_need:
buf_header.extend(Crc.calculate(bytes(buf_header)))
self.connection.write([self.poll_address, self.address])
time.sleep(self.wait_for_wake_up)
self.close()
self.connection.parity = serial.PARITY_SPACE
self.open()
self.connection.write((buf_header[1:]))
except Exception as e:
self.log.error(e, exc_info=True)
try:
response = self.connection.read(size)
if no_response:
try:
return int(binascii.hexlify(response))
except ValueError as e:
self.log.critical("no sas response %s" % (str(buf_header[1:])))
return None
else:
if not response:
raise NoSasConnection
elif int(binascii.hexlify(response)[2:4], 16) != buf_header[1]:
raise BadCommandIsRunning(
"response %s run %s"
% (
binascii.hexlify(response),
binascii.hexlify(bytearray(buf_header)),
)
)
response = Crc.validate(response)
self.log.debug("sas response %s", binascii.hexlify(response))
return response
except Exception as e:
self.log.critical(e, exc_info=True)
return None
@deprecated("use utils.Crc validation fuction")
def _check_response(rsp):
"""Function in charge of the CRC Check"""
if rsp == "":
raise NoSasConnection
mac_crc = [int.from_bytes(rsp[-2:-1]), int.from_bytes(rsp[-1:])]
my_crc = Crc.calculate(rsp[0:-2])
if mac_crc != my_crc:
raise BadCRC(binascii.hexlify(rsp))
else:
return rsp[1:-2]
def events_poll(self):
"""Events Poll function
See Also
--------
WiKi : https://github.com/zacharytomlinson/saspy/wiki/4.-Important-To-Know#event-reporting
"""
self._conf_event_port()
cmd = [0x80 + self.address]
self.connection.write([self.poll_address])
try:
self.connection.write(cmd)
event = self.connection.read(1)
if event == "":
raise NoSasConnection
event = GPoll.GPoll.get_status(event.hex())
except KeyError as e:
raise EMGGpollBadResponse
except Exception as e:
raise e
if self.last_gpoll_event != event:
self.last_gpoll_event = event
else:
event = GPoll.GPoll.STATUS_MAP["00"]
return event
def shutdown(self):
"""Make the VLT unplayable
:note: This is a LONG POLL COMMAND
"""
# [0x01]
if self._send_command([0x01], True, crc_need=True) == self.address:
return True
return False
def startup(self):
"""Synchronize to the host polling cycle
Notes
-------
This is a LONG POLL COMMAND
"""
if self._send_command([0x02], True, crc_need=True) == self.address:
return True
return False
def sound_off(self):
"""Disable VLT sounds
Notes
-------
This is a LONG POLL COMMAND
"""
if self._send_command([0x03], True, crc_need=True) == self.address:
return True
return False
def sound_on(self):
"""Enable VLT sounds
Notes
-------
This is a LONG POLL COMMAND
"""
if self._send_command([0x04], True, crc_need=True) == self.address:
return True
return False
def reel_spin_game_sounds_disabled(self):
"""Reel spin or game play sounds disabled
Notes
-------
This is a LONG POLL COMMAND
"""
if self._send_command([0x05], True, crc_need=True) == self.address:
return True
return False
def enable_bill_acceptor(self):
"""Enable the Bill Acceptor
Notes
-------
This is a LONG POLL COMMAND
"""
if self._send_command([0x06], True, crc_need=True) == self.address:
return True
return False
def disable_bill_acceptor(self):
"""Disable the Bill Acceptor
Notes
-------
This is a LONG POLL COMMAND
"""
if self._send_command([0x07], True, crc_need=True) == self.address:
return True
return False
def configure_bill_denom(self, bill_denom=[0xFF, 0xFF, 0xFF], action_flag=[0xFF]):
"""Configure Bill Denominations
Parameters
----------
bill_denom : dict
Bill denominations sent LSB first (0 = disable, 1 = enable)
===== ===== ======== ======== =====
Bit LSB 2nd Byte 3rd Byte MSB
===== ===== ======== ======== =====
0 $1 $200 $20000 TBD
1 $2 $250 $25000 TBD
2 $5 $500 $50000 TBD
3 $10 $1000 $100000 TBD
4 $20 $2000 $200000 TBD
5 $25 $2500 $250000 TBD
6 $50 $5000 $500000 TBD
7 $100 $10000 $1000000 TBD
===== ===== ======== ======== =====
action_flag : dict
Action of bill acceptor after accepting a bill
===== ===========
Bit Description
===== ===========
0 0 = Disable bill acceptor after each accepted bill
1 = Keep bill acceptor enabled after each accepted bill
===== ===========
Returns
-------
bool
True if successful, False otherwise.
Notes
-------
This is a LONG POLL COMMAND
"""
cmd = [0x08, 0x00]
cmd.extend(bill_denom)
cmd.extend(action_flag)
if self._send_command(cmd, True, crc_need=True) == self.address:
return True
return False
def en_dis_game(self, game_number=None, en_dis=False):
"""Enable or Disable a specific game
Parameters
----------
game_number : bcd
0001-9999 Game number
en_dis : bool
Default is False. True enable a game | False disable it
Returns
-------
bool
True if successful, False otherwise.
"""
if not game_number:
game_number = self.selected_game_number()
game = int(str(game_number), 16)
if en_dis:
en_dis = [0]
else:
en_dis = [1]
cmd = [0x09]
cmd.extend([((game >> 8) & 0xFF), (game & 0xFF)])
cmd.extend(bytearray(en_dis))
if self._send_command(cmd, True, crc_need=True) == self.address:
return True
return False
def enter_maintenance_mode(self):
"""Put the VLT in a state of maintenance mode
Returns
-------
bool
True if successful, False otherwise.
Notes
-------
This is a LONG POLL COMMAND
"""
if self._send_command([0x0A], True, crc_need=True) == self.address:
return True
return False
def exit_maintenance_mode(self):
"""Recover the VLT from a state of maintenance mode
Returns
-------
bool
True if successful, False otherwise.
Notes
-------
This is a LONG POLL COMMAND
"""
if self._send_command([0x0B], True, crc_need=True) == self.address:
return True
return False
def en_dis_rt_event_reporting(self, enable=False):
"""For situations where real time event reporting is desired, the gaming machine can be configured to report events in response to long polls as well as general polls. This allows events such as reel stops, coins in, game end, etc., to be reported in a timely manner
Returns
-------
bool
True if successful, False otherwise.
See Also
--------
WiKi : https://github.com/zacharytomlinson/saspy/wiki/4.-Important-To-Know#event-reporting
"""
if not enable:
enable = [0]
else:
enable = [1]
cmd = [0x0E]
cmd.extend(bytearray(enable))
if self._send_command(cmd, True, crc_need=True) == self.address:
return True
return False
def send_meters_10_15(self, denom=True):
"""Send meters 10 through 15
Parameters
----------
denom : bool
If True will return the values of the meters in float format (i.e. 123.23)
otherwise as int (i.e. 12323)
Returns
-------
Mixed
Object containing the translated meters or None
Notes
-------
This is a LONG POLL COMMAND
"""
cmd = [0x0F]
data = self._send_command(cmd, crc_need=False, size=28)
if data:
meters = {}
if denom:
Meters.Meters.STATUS_MAP["total_cancelled_credits_meter"] = round(
int((binascii.hexlify(bytearray(data[1:5])))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["total_in_meter"] = round(
int(binascii.hexlify(bytearray(data[5:9]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["total_out_meter"] = round(
int(binascii.hexlify(bytearray(data[9:13]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["total_droup_meter"] = round(
int(binascii.hexlify(bytearray(data[13:17]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["total_jackpot_meter"] = round(
int(binascii.hexlify(bytearray(data[17:21]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["games_played_meter"] = int(
binascii.hexlify(bytearray(data[21:25]))
)
else:
Meters.Meters.STATUS_MAP["total_cancelled_credits_meter"] = int(
(binascii.hexlify(bytearray(data[1:5])))
)
Meters.Meters.STATUS_MAP["total_in_meter"] = int(
binascii.hexlify(bytearray(data[5:9]))
)
Meters.Meters.STATUS_MAP["total_out_meter"] = int(
binascii.hexlify(bytearray(data[9:13]))
)
Meters.Meters.STATUS_MAP["total_droup_meter"] = int(
binascii.hexlify(bytearray(data[13:17]))
)
Meters.Meters.STATUS_MAP["total_jackpot_meter"] = int(
binascii.hexlify(bytearray(data[17:21]))
)
Meters.Meters.STATUS_MAP["games_played_meter"] = int(
binascii.hexlify(bytearray(data[21:25]))
)
return Meters.Meters.get_non_empty_status_map()
return None
def total_cancelled_credits(self, denom=True):
"""Send total cancelled credits meter
Parameters
----------
denom : bool
If True will return the values of the meters in float format (i.e. 123.23)
otherwise as int (i.e. 12323)
Returns
-------
Mixed
Round | INT | None
Notes
-------
This is a LONG POLL COMMAND
"""
cmd = [0x10]
data = self._send_command(cmd, crc_need=False, size=8)
if data:
if denom:
return round(
int(binascii.hexlify(bytearray(data[1:5]))) * self.denom, 2
)
else:
return int(binascii.hexlify(bytearray(data[1:5])))
return None
def total_bet_meter(self, denom=True):
"""Send total coin in meter
Parameters
----------
denom : bool
If True will return the values of the meters in float format (i.e. 123.23)
otherwise as int (i.e. 12323)
Returns
-------
Mixed
Round | INT | None
Notes
-------
This is a LONG POLL COMMAND - Pretty sure that the param should not be used @todo CHECK ME
"""
cmd = [0x11]
data = self._send_command(cmd, crc_need=False, size=8)
if data:
if denom:
return round(
int(binascii.hexlify(bytearray(data[1:5]))) * self.denom, 2
)
else:
return int(binascii.hexlify(bytearray(data[1:5])))
return None
def total_win_meter(self, denom=True):
"""Send total coin out meter
Parameters
----------
denom : bool
If True will return the values of the meters in float format (i.e. 123.23)
otherwise as int (i.e. 12323)
Returns
-------
Mixed
Round | INT | None
Notes
-------
This is a LONG POLL COMMAND - Pretty sure that the param should not be used @todo CHECK ME
"""
cmd = [0x12]
data = self._send_command(cmd, crc_need=False, size=8)
if data:
if denom:
return round(
int(binascii.hexlify(bytearray(data[1:5]))) * self.denom, 2
)
else:
return int(binascii.hexlify(bytearray(data[1:5])))
return None
def total_drop_meter(self, denom=True):
"""Send total drop meter
Parameters
----------
denom : bool
If True will return the values of the meters in float format (i.e. 123.23)
otherwise as int (i.e. 12323)
Returns
-------
Mixed
Round | INT | None
Notes
-------
This is a LONG POLL COMMAND - Pretty sure that the param should not be used @todo CHECK ME
"""
cmd = [0x13]
data = self._send_command(cmd, crc_need=False, size=8)
if data:
if denom:
return round(
int(binascii.hexlify(bytearray(data[1:5]))) * self.denom, 2
)
else:
return int(binascii.hexlify(bytearray(data[1:5])))
return None
def total_jackpot_meter(self, denom=True):
"""Send total jackpot meter
Parameters
----------
denom : bool
If True will return the values of the meters in float format (i.e. 123.23)
otherwise as int (i.e. 12323)
Returns
-------
Mixed
Round | INT | None
Notes
-------
This is a LONG POLL COMMAND - Pretty sure that the param should not be used @todo CHECK ME
"""
cmd = [0x14]
data = self._send_command(cmd, crc_need=False, size=8)
if data:
if denom:
return round(
int(binascii.hexlify(bytearray(data[1:5]))) * self.denom, 2
)
else:
return int(binascii.hexlify(bytearray(data[1:5])))
return None
def games_played_meter(self):
"""Send games played meter
Returns
-------
Mixed
INT | None
Notes
-------
This is a LONG POLL COMMAND
"""
cmd = [0x15]
data = self._send_command(cmd, crc_need=False, size=8)
if data:
return int(binascii.hexlify(bytearray(data[1:5])))
return None
def games_won_meter(self, denom=True):
"""Send games won meter
Parameters
----------
denom : bool
If True will return the values of the meters in float format (i.e. 123.23)
otherwise as int (i.e. 12323)
Returns
-------
Mixed
Round | INT | None
Notes
-------
This is a LONG POLL COMMAND - Pretty sure that the param should not be used @todo CHECK ME
"""
cmd = [0x16]
data = self._send_command(cmd, crc_need=False, size=8)
if data:
if denom:
return round(
int(binascii.hexlify(bytearray(data[1:5]))) * self.denom, 2
)
else:
return int(binascii.hexlify(bytearray(data[1:5])))
return None
def games_lost_meter(self):
"""Send games won meter
Returns
-------
Mixed
INT | None
Notes
-------
This is a LONG POLL COMMAND
"""
cmd = [0x17]
data = self._send_command(cmd, crc_need=False, size=8)
if data:
return int(binascii.hexlify(bytearray(data[1:5])))
return None
def games_powerup_door_opened(self):
"""Send meters 10 through 15
Returns
-------
Mixed
Object containing the translated meters or None
Notes
-------
This is a LONG POLL COMMAND
"""
cmd = [0x18]
data = self._send_command(cmd, crc_need=False, size=8)
if data:
Meters.Meters.STATUS_MAP["games_last_power_up"] = int(
binascii.hexlify(bytearray(data[1:3]))
)
Meters.Meters.STATUS_MAP["games_last_slot_door_close"] = int(
binascii.hexlify(bytearray(data[1:5]))
)
return Meters.Meters.get_non_empty_status_map()
return None
def meters_11_15(self, denom=True):
"""Send meters 11 through 15
Parameters
----------
denom : bool
If True will return the values of the meters in float format (i.e. 123.23)
otherwise as int (i.e. 12323)
Returns
-------
Mixed
Object containing the translated meters or None
Notes
-------
This is a LONG POLL COMMAND
"""
cmd = [0x19]
data = self._send_command(cmd, crc_need=False, size=24)
if data:
if not denom:
Meters.Meters.STATUS_MAP["total_bet_meter"] = int(
binascii.hexlify(bytearray(data[1:5]))
)
Meters.Meters.STATUS_MAP["total_win_meter"] = int(
binascii.hexlify(bytearray(data[5:9]))
)
Meters.Meters.STATUS_MAP["total_in_meter"] = int(
binascii.hexlify(bytearray(data[9:13]))
)
Meters.Meters.STATUS_MAP["total_jackpot_meter"] = int(
binascii.hexlify(bytearray(data[13:17]))
)
Meters.Meters.STATUS_MAP["games_played_meter"] = int(
binascii.hexlify(bytearray(data[17:21]))
)
else:
Meters.Meters.STATUS_MAP["total_bet_meter"] = round(
int(binascii.hexlify(bytearray(data[1:5]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["total_win_meter"] = round(
int(binascii.hexlify(bytearray(data[5:9]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["total_in_meter"] = round(
int(binascii.hexlify(bytearray(data[9:13]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["total_jackpot_meter"] = round(
int(binascii.hexlify(bytearray(data[13:17]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["games_played_meter"] = int(
binascii.hexlify(bytearray(data[17:21]))
)
return Meters.Meters.get_non_empty_status_map()
return None
def current_credits(self, denom=True):
"""Send current credits
Parameters
----------
denom : bool
If True will return the value in float format (i.e. 123.23)
otherwise as int (i.e. 12323)
Returns
-------
Mixed
round | int | None
Notes
-------
This is a LONG POLL COMMAND
"""
cmd = [0x1A]
data = self._send_command(cmd, crc_need=False, size=8)
if data:
if denom:
return round(
int(binascii.hexlify(bytearray(data[1:5]))) * self.denom, 2
)
else:
return int(binascii.hexlify(bytearray(data[1:5])))
return None
def handpay_info(self):
"""Send handpay information
Returns
-------
Mixed
Object containing the translated meters or None
Notes
-------
This is a LONG POLL COMMAND - Warning: is missing 2-byte BCD Partial pay amount @todo FIX ME !
"""
cmd = [0x1B]
data = self._send_command(cmd, crc_need=False)
if data:
Meters.Meters.STATUS_MAP["bin_progressive_group"] = int(
binascii.hexlify(bytearray(data[1:2]))
)
Meters.Meters.STATUS_MAP["bin_level"] = int(
binascii.hexlify(bytearray(data[2:3]))
)
Meters.Meters.STATUS_MAP["amount"] = int(
binascii.hexlify(bytearray(data[3:8]))
)
Meters.Meters.STATUS_MAP["bin_reset_ID"] = int(
binascii.hexlify(bytearray(data[8:]))
)
return Meters.Meters.get_non_empty_status_map()
return None
def meters(self, denom=True):
"""Send Meters
Parameters
----------
denom : bool
If True will return the value in float format (i.e. 123.23)
otherwise as int (i.e. 12323)
Returns
-------
Mixed
Object containing the translated meters (in int or float) or None
Notes
-------
This is a LONG POLL COMMAND
"""
cmd = [0x1C]
data = self._send_command(cmd, crc_need=False, size=36)
if data:
if not denom:
Meters.Meters.STATUS_MAP["total_bet_meter"] = int(
binascii.hexlify(bytearray(data[1:5]))
)
Meters.Meters.STATUS_MAP["total_win_meter"] = int(
binascii.hexlify(bytearray(data[5:9]))
)
Meters.Meters.STATUS_MAP["total_drop_meter"] = int(
binascii.hexlify(bytearray(data[9:13]))
)
Meters.Meters.STATUS_MAP["total_jackpot_meter"] = int(
binascii.hexlify(bytearray(data[13:17]))
)
Meters.Meters.STATUS_MAP["games_played_meter"] = int(
binascii.hexlify(bytearray(data[17:21]))
)
Meters.Meters.STATUS_MAP["games_won_meter"] = int(
binascii.hexlify(bytearray(data[21:25]))
)
Meters.Meters.STATUS_MAP["slot_door_opened_meter"] = int(
binascii.hexlify(bytearray(data[25:29]))
)
Meters.Meters.STATUS_MAP["power_reset_meter"] = int(
binascii.hexlify(bytearray(data[29:33]))
)
else:
Meters.Meters.STATUS_MAP["total_bet_meter"] = round(
int(binascii.hexlify(bytearray(data[1:5]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["total_win_meter"] = round(
int(binascii.hexlify(bytearray(data[5:9]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["total_drop_meter"] = round(
int(binascii.hexlify(bytearray(data[9:13]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["total_jackpot_meter"] = round(
int(binascii.hexlify(bytearray(data[13:17]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["games_played_meter"] = int(
binascii.hexlify(bytearray(data[17:21]))
)
Meters.Meters.STATUS_MAP["games_won_meter"] = round(
int(binascii.hexlify(bytearray(data[21:25]))) * self.denom, 2
)
Meters.Meters.STATUS_MAP["slot_door_opened_meter"] = int(
binascii.hexlify(bytearray(data[25:29]))
)
Meters.Meters.STATUS_MAP["power_reset_meter"] = int(
binascii.hexlify(bytearray(data[29:33]))
)
return Meters.Meters.get_non_empty_status_map()
return None
def total_bill_meters(self):
"""Send total bill meters (# of bills)
Returns
-------
Mixed
Object containing the translated meters or None