11import typing
2+ from __future__ import annotation
23from underautomation .fanuc .common .languages import Languages
34from underautomation .fanuc .cgtp .program_sub_type import ProgramSubType
5+ from underautomation .fanuc .cgtp .io_port_type import IoPortType
6+ from underautomation .fanuc .common .cartesian_position import CartesianPosition
7+ from underautomation .fanuc .common .joints_position import JointsPosition
48from UnderAutomation .Fanuc .Cgtp import CgtpClientBase as cgtp_client_base
59from UnderAutomation .Fanuc .Common import Languages as languages
610from UnderAutomation .Fanuc .Cgtp import ProgramSubType as program_sub_type
11+ from UnderAutomation .Fanuc .Cgtp import IoPortType as io_port_type
712
813class CgtpClientBase :
914 '''Base implementation for the CGTP Web Server client.'''
@@ -17,7 +22,7 @@ def disconnect(self) -> None:
1722 '''Disconnect from the CGTP Web Server. After calling this method, the client must be reconnected before it can be used again.'''
1823 self ._instance .Disconnect ()
1924
20- def abort_task (self , progName : str = " None" ) -> None :
25+ def abort_task (self , progName : str = None ) -> None :
2126 '''Abort the task specified by progName. Set to null to abort all user tasks.'''
2227 self ._instance .AbortTask (progName )
2328
@@ -80,7 +85,7 @@ def set_program_sub_type(self, progName: str, subType: ProgramSubType) -> None:
8085 '''Set the sub-type of program progName.'''
8186 self ._instance .SetProgramSubType (progName , program_sub_type (int (subType )))
8287
83- def create_program (self , progName : str , owner : str = " None" , comment : str = " None" , defaultGroup : int = 0 , subType : ProgramSubType = ProgramSubType .None ) -> None :
88+ def create_program (self , progName : str , owner : str = None , comment : str = None , defaultGroup : int = 0 , subType : ProgramSubType = ProgramSubType .None_ ) -> None :
8489 '''Create a new TP program on the controller.
8590
8691 :param progName: New program name
@@ -107,14 +112,42 @@ def pause_all_programs(self) -> None:
107112 '''Pause program execution on the controller.'''
108113 self ._instance .PauseAllPrograms ()
109114
110- def read_variable_as_string (self , varName : str , progName : str = " None" ) -> str :
115+ def read_variable_as_string (self , varName : str , progName : str = None ) -> str :
111116 '''Read the value of variable varName in program progName.'''
112117 return self ._instance .ReadVariableAsString (varName , progName )
113118
114- def write_variable (self , varName : str , value : str , progName : str = " None" ) -> None :
119+ def write_variable (self , varName : str , value : str , progName : str = None ) -> None :
115120 '''Write value to variable varName in program progName.'''
116121 self ._instance .WriteVariable (varName , value , progName )
117122
123+ def read_io (self , portType : IoPortType , index : int ) -> int :
124+ '''Read the value of I/O port at index of type portType.'''
125+ return self ._instance .ReadIo (io_port_type (int (portType )), index )
126+
127+ def write_io (self , portType : IoPortType , index : int , value : int ) -> None :
128+ '''Set the value of I/O port at index of type portType.'''
129+ self ._instance .WriteIo (io_port_type (int (portType )), index , value )
130+
131+ def get_io_simulation_status (self , portType : IoPortType , index : int ) -> bool :
132+ '''Check whether I/O port at index of type portType is simulated.'''
133+ return self ._instance .GetIoSimulationStatus (io_port_type (int (portType )), index )
134+
135+ def simulate_io (self , portType : IoPortType , index : int ) -> None :
136+ '''Set I/O port at index of type portType to simulated.'''
137+ self ._instance .SimulateIo (io_port_type (int (portType )), index )
138+
139+ def unsimulate_io (self , portType : IoPortType , index : int ) -> None :
140+ '''Remove simulation from I/O port at index of type portType.'''
141+ self ._instance .UnsimulateIo (io_port_type (int (portType )), index )
142+
143+ def read_cartesian_position (self , groupNum : int = 1 ) -> CartesianPosition :
144+ '''Read the current Cartesian position of motion group groupNum.'''
145+ return CartesianPosition (None , None , None , None , None , None , None , self ._instance .ReadCartesianPosition (groupNum ))
146+
147+ def read_joint_position (self , groupNum : int = 1 ) -> JointsPosition :
148+ '''Read the current joint angles of motion group groupNum.'''
149+ return JointsPosition (None , None , None , None , None , None , None , None , None , self ._instance .ReadJointPosition (groupNum ))
150+
118151 def list_files (self , pathName : str = "MD:" ) -> typing .List [str ]:
119152 '''List files at the specified path on the controller.'''
120153 return self ._instance .ListFiles (pathName )
0 commit comments