Example #1
0
def test_Exchange_loco_poached_response_v2():
    e = Exchange.parse('71 A4 03 00 00 00 A7')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 17
    assert e.short_desc(
    ) == 'CS Locomotive is being operated by another device (V2)'
Example #2
0
def test_Exchange_loco_speed_and_direction_128_xn():
    e = Exchange.parse('59 E4 13 00 03 7F 8B')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 25
    assert e.short_desc(
    ) == 'D  Locomotive speed and direction 128 (XpressNet)'
Example #3
0
def test_Exchange_accessory_decoder_information_response():
    e = Exchange.parse('ED 42 00 00 42')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 13
    assert e.short_desc() == 'CS Accessory decoder information response'
Example #4
0
def test_Exchange_parse_empty():
    with pytest.raises(ValueError):
        Exchange.parse('')
Example #5
0
def test_Exchange_emergency_stop():
    e = Exchange.parse('60 81 00 81')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 0
    assert e.short_desc() == 'CS Emergency stop'
Example #6
0
def test_Exchange_normal_operation_resumed():
    e = Exchange.parse('60 61 01 60')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 0
    assert e.short_desc() == 'CS Normal operation resumed'
Example #7
0
def test_Exchange_missing_crc():
    e = Exchange.parse('41 00')
    assert not e.isvalid
Example #8
0
def test_Exchange_loco_operations_v2():
    e = Exchange.parse('D8 B4 03 4F 00 00 F8')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 24
    assert e.short_desc() == 'D  Locomotive operations (V2)'
Example #9
0
def test_Exchange_loco_information_request_v1v2():
    e = Exchange.parse('D4 A2 03 00 A1')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 20
    assert e.short_desc() == 'D  Locomotive information request (V1 and V2)'
Example #10
0
def test_Exchange_stop_operations_request():
    e = Exchange.parse('C3 21 80 A1')
    assert e.isvalid
    assert e.address == 3
    assert e.short_desc() == 'D  Stop operations request (emergency off)'
Example #11
0
def test_Exchange_resume_operations_request():
    e = Exchange.parse('42 21 81 A0\n')
    assert e.isvalid
    assert e.address == 2
    assert e.short_desc() == 'D  Resume operations request'
Example #12
0
def test_Exchange_ack_response():
    e = Exchange.parse('41 20 20')
    assert e.isvalid
    assert e.address == 1
    assert e.short_desc() == 'D  Acknowledgement response'
Example #13
0
def test_Exchange_loco_available_response_v2():
    e = Exchange.parse('F0 84 03 00 00 00 87')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 16
    assert e.short_desc() == 'CS Locomotive is available for operation (V2)'
Example #14
0
def test_Exchange_parse_non_hex():
    with pytest.raises(ValueError):
        Exchange.parse('Ds')
Example #15
0
def test_Exchange_loco_available_response_v1():
    e = Exchange.parse('EE 83 03 00 00 80')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 14
    assert e.short_desc() == 'CS Locomotive is available for operation (V1)'
Example #16
0
def test_Exchange_accessory_decoder_operation_request():
    e = Exchange.parse('D2 52 00 88 DA')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 18
    assert e.short_desc() == 'D  Accessory decoder operation request'
Example #17
0
def test_Exchange_loco_information_request_v1():
    e = Exchange.parse('53 A1 03 A2')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 19
    assert e.short_desc() == 'D  Locomotive information request (V1)'
Example #18
0
def test_Exchange_stop_all_locos_request():
    e = Exchange.parse('44 80 80')
    assert e.isvalid
    assert e.address == 4
    assert e.short_desc() == 'D  Stop all locomotives request (emergency stop)'
Example #19
0
def test_Exchange_loco_operations_v1():
    e = Exchange.parse('D7 B3 03 4F 00 FF')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 23
    assert e.short_desc() == 'D  Locomotive operations (V1)'
Example #20
0
def test_Exchange_estop_loco_request_v1v2():
    e = Exchange.parse('C5 91 03 92')
    assert e.isvalid
    assert e.address == 5
    assert e.short_desc() == 'D  Emergency stop a locomotive (V1 and V2)'
Example #21
0
def test_Exchange_estop_loco_request_xpressnet():
    e = Exchange.parse('C6 92 00 03 91')
    assert e.isvalid
    assert e.address == 6
    assert e.short_desc() == 'D  Emergency stop a locomotive (XpressNet)'
Example #22
0
def test_Exchange_command_station_sw_version_request():
    e = Exchange.parse('41 21 21 00')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 1
    assert e.short_desc() == 'D  Command station software version request'
Example #23
0
def test_Exchange_TBD():
    e = Exchange.parse('21')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 1
    assert e.short_desc() == 'TBD (Future Command)'
Example #24
0
def test_Exchange_command_station_status_request():
    e = Exchange.parse('42 21 24 05')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 2
    assert e.short_desc() == 'D  Command station status request'
Example #25
0
def test_Exchange_track_power_off():
    e = Exchange.parse('60 61 00 61')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 0
    assert e.short_desc() == 'CS Track power off'
Example #26
0
def test_Exchange_normal_enquiry():
    e = Exchange.parse('41')
    assert e.isvalid
    assert e.isenquiry
    assert e.address == 1
    assert e.short_desc() == 'CS Normal Enquiry'
Example #27
0
def test_Exchange_service_mode_entry():
    e = Exchange.parse('60 61 02 63')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 0
    assert e.short_desc() == 'CS Service mode entry'
Example #28
0
def test_Exchange_accessory_decoder_information_request():
    e = Exchange.parse('D1 42 00 80 C2')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 17
    assert e.short_desc() == 'D  Accessory decoder information request'
Example #29
0
def test_Exchange_feedback_broadcast():
    e = Exchange.parse('A0 41 00 00 41')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 0
    assert e.short_desc() == 'CS Feedback broadcast'
Example #30
0
def test_Exchange_unsupported_instruction():
    e = Exchange.parse('6C 61 82 E3')
    assert e.isvalid
    assert not e.isenquiry
    assert e.address == 12
    assert e.short_desc() == 'CS Unsupported instruction'