-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This makes bit operations on these data easier than with immutable strings. Also add image documentation for the different plc data messages and double words.
- Loading branch information
1 parent
e77ce6d
commit e79f736
Showing
7 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
schunk_egu_egk_gripper_dummy/tests/test_plc_communication.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from src.dummy import Dummy | ||
import pytest | ||
|
||
# [1]: https://stb.cloud.schunk.com/media/IM0046706.PDF | ||
|
||
|
||
def test_dummy_initializes_plc_data_buffers(): | ||
dummy = Dummy() | ||
assert dummy.data[dummy.plc_input][0] == dummy.plc_input_buffer.hex().upper() | ||
assert dummy.data[dummy.plc_output][0] == dummy.plc_output_buffer.hex().upper() | ||
|
||
|
||
def test_dummy_returns_plc_data(): | ||
dummy = Dummy() | ||
assert dummy.data[dummy.plc_input] == dummy.get_plc_input() | ||
assert dummy.data[dummy.plc_output] == dummy.get_plc_output() | ||
|
||
|
||
# See p. 24 in | ||
# Booting and establishing operational readiness [1] | ||
|
||
|
||
@pytest.mark.skip() | ||
def test_dummy_starts_in_error_state(): | ||
dummy = Dummy() | ||
query = {"inst": dummy.plc_input, "count": 1} | ||
data = dummy.get_data(query)[0] | ||
assert data[0:2] == "80" | ||
assert data[30:] == "D9" # ERR_FAST_STOP | ||
|
||
|
||
@pytest.mark.skip() | ||
def test_dummy_is_ready_after_acknowledge(): | ||
dummy = Dummy() | ||
control_double_word = "04000000" | ||
set_position = "00000000" | ||
set_speed = "00000000" | ||
gripping_force = "00000000" | ||
command = { | ||
"inst": dummy.plc_output, | ||
"value": control_double_word + set_position + set_speed + gripping_force, | ||
} | ||
dummy.post(command) | ||
|
||
query = {"inst": dummy.plc_input, "count": 1} | ||
data = dummy.get_data(query)[0] | ||
assert data[0:2] == "11" | ||
assert data[30:] == "00" # ERR_NONE |