|
24 | 24 | logger = logging.getLogger(__name__) |
25 | 25 |
|
26 | 26 |
|
| 27 | +def to_ReferencingAxisState(cri_value: int) -> ReferencingAxisState: |
| 28 | + """ |
| 29 | + Parses a referencing state bitset value from CRI into the ReferencingAxisState enum |
| 30 | +
|
| 31 | + Parameters |
| 32 | + ---------- |
| 33 | + cri_value: referencing state value from CRI, this is an integer encoded bitset |
| 34 | +
|
| 35 | + Returns |
| 36 | + ------- |
| 37 | + Parsed ReferencingAxisState value |
| 38 | + """ |
| 39 | + all_axes_referenced = (cri_value & 0x1) != 0 |
| 40 | + is_referencing = (cri_value & 0x2) != 0 |
| 41 | + if is_referencing: |
| 42 | + return ReferencingAxisState.REFERENCING |
| 43 | + elif all_axes_referenced: |
| 44 | + return ReferencingAxisState.REFERENCED |
| 45 | + else: |
| 46 | + return ReferencingAxisState.NOT_REFERENCED |
| 47 | + |
| 48 | + |
27 | 49 | class CRIProtocolParser: |
28 | 50 | """Class handling the parsing of CRI messages to the robot state.""" |
29 | 51 |
|
@@ -674,19 +696,19 @@ def _parse_info(self, parameters: list[str]) -> str | None: |
674 | 696 | parameters.insert(14, parameters[14][0]) |
675 | 697 |
|
676 | 698 | ref_state = ReferencingState( |
677 | | - global_state=ReferencingAxisState(int(parameters[1])), |
678 | | - A1=ReferencingAxisState(int(parameters[3])), |
679 | | - A2=ReferencingAxisState(int(parameters[4])), |
680 | | - A3=ReferencingAxisState(int(parameters[5])), |
681 | | - A4=ReferencingAxisState(int(parameters[6])), |
682 | | - A5=ReferencingAxisState(int(parameters[7])), |
683 | | - A6=ReferencingAxisState(int(parameters[8])), |
684 | | - E1=ReferencingAxisState(int(parameters[9])), |
685 | | - E2=ReferencingAxisState(int(parameters[10])), |
686 | | - E3=ReferencingAxisState(int(parameters[11])), |
687 | | - E4=ReferencingAxisState(int(parameters[12])), |
688 | | - E5=ReferencingAxisState(int(parameters[13])), |
689 | | - E6=ReferencingAxisState(int(parameters[14])), |
| 699 | + global_state=to_ReferencingAxisState(int(parameters[1])), |
| 700 | + A1=to_ReferencingAxisState(int(parameters[3])), |
| 701 | + A2=to_ReferencingAxisState(int(parameters[4])), |
| 702 | + A3=to_ReferencingAxisState(int(parameters[5])), |
| 703 | + A4=to_ReferencingAxisState(int(parameters[6])), |
| 704 | + A5=to_ReferencingAxisState(int(parameters[7])), |
| 705 | + A6=to_ReferencingAxisState(int(parameters[8])), |
| 706 | + E1=to_ReferencingAxisState(int(parameters[9])), |
| 707 | + E2=to_ReferencingAxisState(int(parameters[10])), |
| 708 | + E3=to_ReferencingAxisState(int(parameters[11])), |
| 709 | + E4=to_ReferencingAxisState(int(parameters[12])), |
| 710 | + E5=to_ReferencingAxisState(int(parameters[13])), |
| 711 | + E6=to_ReferencingAxisState(int(parameters[14])), |
690 | 712 | mandatory=bool(parameters[16] == "1"), |
691 | 713 | ref_prog_enabled=bool(parameters[18] == "1"), |
692 | 714 | ref_prog_running=bool(parameters[19] == "1"), |
|
0 commit comments