Control Head mode
Python
[set] Head Mode Change SLD On/Off [get] sld on/off mode type pspd align [dependency] - SmartRemote
main
1 file
Control Head mode..py
head_mode.py
2.8 KB
Control Head mode..py
2886 bytes
from SmartRemote import SmartRemote
class HeadMode:
def __init__(self, SR:SmartRemote):
self.__sr = SR
def set_head_mode(self, mode:str='contact'):
"""Set head mode
Args:
mode (str, mode): contact, ncm, tapping. Defaults to 'contact'.
"""
reply = self.__sr.run(f'spm.head.setMode(\'{mode}\')')
return reply
def is_head_mode(self, mode:str='contact'):
"""Check head mode
Args:
mode (str, mode): contact, ncm, tapping. Defaults to 'contact'.
"""
reply = self.__sr.run(f'spm.head.isMode(\'{mode}\')')
is_true = reply["value"].lower() == 'true'
return is_true
def is_contact_type(self):
"""Check head mode is contact type"""
reply = self.__sr.run(f'spm.head.isContactType')
is_true = reply["value"].lower() == 'true'
return is_true
def is_non_contact_type(self):
"""Check head mode is non-contact type"""
reply = self.__sr.run(f'spm.head.isNonContactType')
is_true = reply["value"].lower() == 'true'
return is_true
def is_connected(self):
"""Check head mode is connected"""
reply = self.__sr.run(f'spm.head.isConnected')
is_true = reply["value"].lower() == 'true'
return is_true
def is_pspd_aligned(self):
"""Check PSPD aligned"""
reply = self.__sr.run(f'spm.head.isPspdAligned')
is_true = reply["value"].lower() == 'true'
return is_true
def current_head_mode(self):
"""Get current head mode"""
reply = self.__sr.run('spm.head.modeName')
return reply["value"]
def set_sld_on(self,on:bool=True):
"""Set SLD on/off
Args:
on (bool, optional): SLD on/off. Defaults to True.
"""
reply = self.__sr.run(f'spm.head.beam={int(on)}')
return reply
def get_sld_on(self):
"""Get SLD on/off
"""
reply = self.__sr.run(f'spm.head.beam')
return reply['value'].lower() == 'true'
if __name__ == "__main__":
sr = SmartRemote()
handle = HeadMode(sr)
reply = handle.set_head_mode('contact')
is_true = handle.is_head_mode('contact')
current_mode = handle.current_head_mode()
print(f'Current Head mode : {current_mode}')
is_true = handle.is_pspd_aligned()
print(f'PSPD Aligned : {is_true}')
is_true = handle.is_contact_type()
print(f'Is Contact Type : {is_true}')
is_true = handle.is_non_contact_type()
print(f'Is Non-Contact Type : {is_true}')
is_true = handle.is_connected()
print(f'Is Connected : {is_true}')
handle.set_sld_on(False)
sld_status = handle.get_sld_on()
print(f'SLD On : {sld_status}')
Comments (0)
No comments yet. Be the first to comment!