~>Lc@s ddlmZddlmZddlmZmZddlmZm Z m Z ddl m Z ddl mZddlmZmZdefd YZed kreZxced D]UZejd ed ejdejded ejedqWndS(i(tMessage(t SocketClient(tMap2DtRoadMap(t EnMsgPltfCtrlt PltfParamst BoardType(t StatePltf(tThread(tsleeptctimetPltfCtrlClientcBsfeZdZdZdZdZdZdddZdZd Z d Z d Z d Z d Z dZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZd Z d!Z!d"Z"d#Z#d$Z$d%Z%d&Z&d'Z'd(Z(d)Z)d*Z*d+Z+d,Z,d-Z-d.Z.d/Z/d0Z0d1Z1d2Z2d3Z3d4Z4d5Z5d6Z6d7Z7d8Z8d9Z9d:Z:d;Z;d<Z<d=Z=d>Z>d?Z?d@Z@dAZAdBZBeCdCZDRS(DcCsad|_t|_d|_t|_g|_tj |ddd|j t |j dS(Ng?tPltfClientThread( tNonet socketClienttFalset_PltfCtrlClient__connectedt_PltfCtrlClient__requestTimeRt statePltft$_PltfCtrlClient__connectionListenersRt__init__t setDaemontTruetstart(tself((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyR$s      cCs+t|_x|jD]}|jqWdS(N(RRRt onConnect(Rtlistener((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyR1s cCs4t|_d|_x|jD]}|jqWdS(N(RRR RRt onDisconnect(RR((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyR8s  cCse|j}|tjkr.|jj|n|tjkr@nx|jD]}|j|qJWdS(N(tgetMessageTypeRtCMD_GET_STATUSRtupdateStateFromMessagetCMD_GET_DEBUG_DATARt onReceive(RtmsgttypeR((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyR @s cCs:x3tr5|jr%|jtjnt|jqWdS(N(RRtsendCmdRRR R(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytrunMs  i'icCs@|d|_t|_|jj||jj||tS(Ng@@(RRRtaddConnectionListenertconnectR(Rtaddresstportt requestTime((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyR&cs   cCs|jjdS(N(Rtclose(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt disconnecttscCs|jdS(N(R+(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytcloseConnection{scCst}|j||tjkr5|jtn,|tjkrT|jtn |jt|j||j j |dS(N( Rt writeByteRRt setHasReplyRRRtsetMessageTypeRtaddToSendQueue(RtcmdR!((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyR#s    cCs|jS(N(R(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt isConnectedscCs|jtjdS(N(R#RtCMD_SHUTDOWN_HOST(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt shutdownHostscCs|jtjdS(N(R#RtCMD_STOP_MOTIONTHREAD(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytstopMotionThreadscCs|jtjdS(N(R#RtCMD_RESTART_MOTIONTHREAD(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytrestartMotionThreadscCst}|jtj|j|d|j||j|d|j|d|jd|jd|jt|jtj|j j |dS(Niii( RR-RtCMD_SET_PLTF_PARAMt writeStringtwriteIntR.RR/RR0(Rt parametertvalueR!((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt setParameters     cCs|jt}|jtj|j||jt|jtj|j j |x|j |s|t dq`W|j tjdS(Ng?(t stopPlatformRR-Rt CMD_SET_MODER;R.RR/RR0tisMotionModeSetR R#t CMD_START(RtmodeR!((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt setMotionModes    cCs!|jjj|krtStSdS(N(RtpltfDatat motionModeRR(RRC((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyRAscCs|jtjdS(N(R#RtCMD_STOP(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyR?scCsa|j||jtjd}x7|jjjr\td|d}|dkr&tSq&Wt S(Nig?ii( t_PltfCtrlClient__moveToStationR#RRBRREtpltfTargetReachedR RR(Rtstationttimeout((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytmoveToStationNonBlocking s    cCs{|j||jtjx|jjjr<tdq Wx|jjjs\tdq@Wtt d|dGHdS(Ng?s target s reached( RHR#RRBRRERIR tstrR (RRJ((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytmoveToStationBlockings cCsWt}|jtj|j||jt|jtj|jj |dS(N( RR-RtCMD_MOVE_TO_STATIONR:R.RR/RR0(RRJR!((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt__moveToStation&s    cCsg|j||||jtjd}x7|jjjrbtd|d}|dkr,tSq,Wt S(Nig?ii( t_PltfCtrlClient__moveAbsR#RRBRRERIR RR(RtxtytalphaRK((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytmoveAbsoluteNonBlocking<s   cCsy|j||||jtjx|jjjrBtdq&Wx|jjjsbtdqFWtt dGHdS(Ng?s position reached.( RQR#RRBRRERIR RMR (RRRRSRT((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytmoveAbsoluteBlockingPscCszt}|jtj|j||j||jtj||jt|j tj|j j |dS(N( RR-Rt CMD_MOVE_ABSR;R tconvertRadToDegreeR.RR/RR0(RRRRSRTR!((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt __moveAbsZs    cCsg|j||||jtjd}x7|jjjrbtd|d}|dkr,tSq,Wt S(Nig?ii( t_PltfCtrlClient__moveRelR#RRBRRERIR RR(RRRRSRTRK((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytmoveRelativeNonBlockingrs   cCsy|j||||jtjx|jjjrBtdq&Wx|jjjsbtdqFWtt dGHdS(Ng?s position reached.( RZR#RRBRRERIR RMR (RRRRSRT((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytmoveRelativeBlockingscCszt}|jtj|j||j||jtj||jt|j tj|j j |dS(N( RR-Rt CMD_MOVE_RELR;R RXR.RR/RR0(RRRRSRTR!((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt __moveRels    cCs|jtjdS(N(R#RtCMD_AUTOMATIC_CHARGE(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytautomaticDockingscCs|jtjdS(N(R#RtCMD_LEAVE_CHARGESTATION(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytleaveChargeStationscCs3|r|jtjdn|jtjddS(Nttruetfalse(R>RtPlanningEnabled(Rtenabled((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytsetReactivePlanningEnabledscCs|jtjddS(NRc(R>RtMotionBackwardEnabled(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytenableBackwardMovescCs|jtjddS(NRd(R>RRh(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytdisableBackwardMovescCsut}|jtj|j||j||j|d|jt|jtj|jj |dS(Ni ( RR-RtCMD_SET_FRM_PLTFR;R.RR/RR0(RRRRStangleDegR!((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt setPltfFrames    cCsC|dkr|jjjS|dkr2|jjjS|jjjSdS(Nii(Rt frmPltfEstRRRStangDeg(RtnumCoord((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt getPltfEstPoss   cCs|jjj S(N(RRERI(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytisPlanningFinishedscCs |jjjS(N(RRERI(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytisTargetReachedscCs!|jjjdkrtStSdS(Ni(RREtstateEmergencyRR(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytisEmStopActive scCs!|jjjdkrtStSdS(Ni(RRERtRR(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytisScannerStopActivescCs!|jjjdkrtStSdS(Ni(RRERtRR(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytisEmergencyReset'scCs!|jjjdkrtStSdS(Ni(RREtstateOperationRR(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt isStopped3scCs%|jjjd|krtStSdS(Ni(Rt boardDatatrelBoardAnalogInRR(RR=((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytisVoltageUnderAscCs|jjjdGHdS(Ni(RRzR{(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt printVoltageKscCs|jjjdS(Ni(RRzR{(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt getVoltageSscCst}|j|t}|jtj|j|j|jt |j |j |j |j tj|j t|jj||jtjdS(N(Rt loadFromDiskRR-Rt CMD_SET_MAPR:tnameR;tlentrawDatatextendR/R.RRR0R#t CMD_SAVE_MAP(RtpathtmapR!((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytloadMap\s    cCst}|j|t}|jtj|j|j|jt |j |j |j |j tj|j t|jj||jtjdS(N(RRRR-RtCMD_SET_ROADMAPR:RR;RRRR/R.RRR0R#tCMD_SAVE_ROADMAP(RRRR!((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt loadRoadMapws    cCs9|r|jttttn|jttttdS(N(t&_PltfCtrlClient__setSurveillanceParamsRR(RtbOnOff((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt enableSurveillanceModeInMovementscCs9|r|jttttn|jttttdS(N(RRR(RR((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytenableSurveillanceModeStandingscCsP|jtj||jtj||jtj||jtj|dS(N(R>RtSurveillanceModeEnabledtScannerSurveillancetRadarSensorsEnabledtPIRSensorsEnabled(RtsurveyEnt scannerEntRadarEntpirEn((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt__setSurveillanceParamsscCs |jjjS(N(RtsurvDatat alarmEnabled(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytisAlarmscCsl|dkr|jdS|dkr2|jdS|dkrK|jdS|dkrd|jdStSdS( NtF1itF2itF3itF4i(t _PltfCtrlClient__isKeyPadPressedR(RtKey((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt isKeyPresseds        cCs9|jjjd}d|>}||@dkr1tStSdS(Niii(RRzR{RR(RRt keyPadDatatmask((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt__isKeyPadPresseds  cCs`xY|jdrdS|jdr)dS|jdr<dS|jdrOdStd qdS( NiRiRiRiRg333333?(RR (R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytwaitUntilKeyPressedscCsT|jdrdS|jdr&dS|jdr9dS|jdrLdSd SdS( NiRiRiRiRR (R(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt getPressedKeyscCsqt}|jtj|j||j||j||jtj|jt|j j |dS(N( RR-RtCMD_SET_DIGOUTR;t writeBooleanR/R.RRR0(RtchannelR=t boardTypeR!((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt setDigOuts     cCs>x7tddD]&}|j|ttjtdqWdS(Niig?(tranget sendSetDigOutRRt TYPE_IOBOARDR (RR((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytswitchAllIOBoardChannelsOffscCs$|j|ttjtddS(Ng?(RRRRR (RR((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytenableIOBoardChannelscCs$|j|ttjtddS(Ng?(RRRRR (RR((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytdisableIOBoardChannel"scCs$|j|ttjtddS(Ng?(RRRtTYPE_RELAYBOARDR (RtiChannel((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytenableRelayChannel/scCs$|j|ttjtddS(Ng?(RRRRR (RR((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytdisableRelayChannel8scCsdt}|jtj|j||j||jt|jtj|j j |dS(N( RR-Rt CMD_WRITE_LCDRR:R.RR/RR0(Rttextt modeMotionR!((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt __writeLCDBs    cCs|j|tdS(N(t_PltfCtrlClient__writeLCDR(RR((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytwriteLCDTscCs|j|tdS(N(RR(RR((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytwriteModeMotionToLCD\scCs|jdtdS(Nt(RR(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytclearLCDcscCs |jjjS(N(RRztgpsLat(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt getGPSLatlscCs |jjjS(N(RRztgpsLon(R((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyt getGPSLonuscCsWt}|jtj|j||jtj|jt|jj |dS(N( RR-RtCMD_SPEAK_TEXTR:R/R.RRR0(RRR!((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pytspeaks    cCs|dS(NgcܥL@((tangRad((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyRXs(Et__name__t __module__RRRR R$R&R+R,R#R2R4R6R8R>RDRAR?RLRNRHRURVRQR[R\RZR`RbRgRiRjRmRqRrRsRuRvRwRyR|R}R~RRRRRRRRRRRRRRRRRRRRRRRt staticmethodRX(((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyR "s                               t__main__is 127.0.0.1isDC:/Users/Trackium/Desktop/MobileArmGUI - JH/content/map/Neobotix.mapsGC:/Users/Trackium/Desktop/MobileArmGUI - JH/content/roadmap/Neobotix.rmiN(tNeobotix.Bases.MessageRtNeobotix.Bases.SocketClientRtNeobotix.Nav.MapRRt"Neobotix.Pltf.Comm.EnumMsgPltfCtrlRRRtNeobotix.Pltf.Data.StatePltfRt threadingRttimeR R R Rt pltfClientRtiR&RRR+(((sWC:\Users\aron\Desktop\Neobotix\Recovery\NeoInterpreter\Neobotix\Pltf\Client\PltfCtrl.pyts(v