/** * Get the PWM value in terms of speed. * * This is intended to be used by speed controllers. * * @pre SetMaxPositivePwm() called. * @pre SetMinPositivePwm() called. * @pre SetMaxNegativePwm() called. * @pre SetMinNegativePwm() called. * * @return The most recently set speed between -1.0 and 1.0. */ float PWM::GetSpeed() { if (StatusIsFatal()) return 0.0; INT32 value = GetRaw(); if (value > GetMaxPositivePwm()) { return 1.0; } else if (value < GetMinNegativePwm()) { return -1.0; } else if (value > GetMinPositivePwm()) { return (float)(value - GetMinPositivePwm()) / (float)GetPositiveScaleFactor(); } else if (value < GetMaxNegativePwm()) { return (float)(value - GetMaxNegativePwm()) / (float)GetNegativeScaleFactor(); } else { return 0.0; } }
void RarTime::SetAgeText(char *TimeText) { uint Seconds=0,Value=0; for (int I=0;TimeText[I]!=0;I++) { int Ch=TimeText[I]; if (IsDigit(Ch)) Value=Value*10+Ch-'0'; else { switch(etoupper(Ch)) { case 'D': Seconds+=Value*24*3600; break; case 'H': Seconds+=Value*3600; break; case 'M': Seconds+=Value*60; break; case 'S': Seconds+=Value; break; } Value=0; } } SetCurrentTime(); int64 RawTime=GetRaw(); SetRaw(RawTime-INT32TO64(0,Seconds)*10000000); }
void Timer::Start(Time timeout, Time repeat) { Invoke(&uv_timer_start, GetRaw(), [](uv_timer_t* handle) { Timer& h = *static_cast<Timer*>(handle->data); h.timeout(); }, timeout.count(), repeat.count()); }
static std::unique_ptr<SpinButton> grid_spinbutton(wxWindow* parent, wxSizer* sizer, winvec_t& showhide, const on_spin_up& onSpinUp, const on_spin_down& onSpinDown) { // Create the buttons for single-stepping the spacing auto spinButton = std::make_unique<SpinButton>(parent, IntSize(40,50), "Adjust Grid Spacing", onSpinUp, onSpinDown); spinButton->GetRaw()->Hide(); sizer->Add(spinButton->GetRaw()); showhide.push_back(spinButton->GetRaw()); return spinButton; }
std::shared_ptr<Timer> Timer::Create(Loop& loop) { auto h = std::make_shared<Timer>(private_init{}); int err = uv_timer_init(loop.GetRaw(), h->GetRaw()); if (err < 0) { loop.ReportError(err); return nullptr; } h->Keep(); return h; }
std::shared_ptr<Tty> Tty::Create(Loop& loop, uv_file fd, bool readable) { auto h = std::make_shared<Tty>(private_init{}); int err = uv_tty_init(loop.GetRaw(), h->GetRaw(), fd, readable ? 1 : 0); if (err < 0) { loop.ReportError(err); return nullptr; } h->Keep(); return h; }
/** * Get the PWM value in terms of a position. * * This is intended to be used by servos. * * @pre SetMaxPositivePwm() called. * @pre SetMinNegativePwm() called. * * @return The position the servo is set to between 0.0 and 1.0. */ float PWM::GetPosition() const { if (StatusIsFatal()) return 0.0; int32_t value = GetRaw(); if (value < GetMinNegativePwm()) { return 0.0; } else if (value > GetMaxPositivePwm()) { return 1.0; } else { return (float)(value - GetMinNegativePwm()) / (float)GetFullRangeScaleFactor(); } }
wxIDirectFBSurfacePtr wxIDirectFBSurface::Clone() { wxIDirectFBSurfacePtr snew(CreateCompatible()); if ( !snew ) return NULL; if ( !snew->SetBlittingFlags(DSBLIT_NOFX) ) return NULL; if ( !snew->Blit(GetRaw(), NULL, 0, 0) ) return NULL; return snew; }
/** * Get the PWM value in terms of a position. * * This is intended to be used by servos. * * @pre SetMaxPositivePwm() called. * @pre SetMinNegativePwm() called. * * @return The position the servo is set to between 0.0 and 1.0. */ float PWM::GetPosition() { INT32 value = GetRaw(); if (value < GetMinNegativePwm()) { return 0.0; } else if (value > GetMaxPositivePwm()) { return 1.0; } else { return (float)(value - GetMinNegativePwm()) / (float)GetFullRangeScaleFactor(); } }
/** * Returns the (cloned) raw command converted into a CString. * * The method should only be called when the called is sure * that the current command isn't a binary command. * The returned string must be deleted by the called * (exception to the rule). */ CString* CNaoCommand::GetShortenString(int length) { if (IsEmpty()) return new CString(_T("")); CString* s=new CString(GetRaw()); if (s->GetLength()>120) { CString* s2=new CString(s->Left(120)+_T("...")); delete s; return s2; // We are returning a pointer, so it must be on the heap // to stay in focus. } else { return s; } }
/** * Get the PWM value in terms of speed. * * This is intended to be used by speed controllers. * * @pre SetMaxPositivePwm() called. * @pre SetMinPositivePwm() called. * @pre SetMaxNegativePwm() called. * @pre SetMinNegativePwm() called. * * @return The most recently set speed between -1.0 and 1.0. */ float PWM::GetSpeed() const { if (StatusIsFatal()) return 0.0; int32_t value = GetRaw(); if (value == PWM::kPwmDisabled) { return 0.0; } else if (value > GetMaxPositivePwm()) { return 1.0; } else if (value < GetMinNegativePwm()) { return -1.0; } else if (value > GetMinPositivePwm()) { return (float)(value - GetMinPositivePwm()) / (float)GetPositiveScaleFactor(); } else if (value < GetMaxNegativePwm()) { return (float)(value - GetMaxNegativePwm()) / (float)GetNegativeScaleFactor(); } else { return 0.0; } }
// Adds another string to the end of this string void String::Append(const String * a_other) { // Gets the c style string of the this object const char* temp = GetRaw(); // Get the length of this object and the other string and adds 1 to the end for the null // terminator int length = GetLength() + a_other->GetLength() + 1; // Stores the this string length int lengthOld = GetLength(); // Requests the memory for this char array to be dellocated Kill(); // Creates a new char array with the length from before combining both + 1 m_data = new char[length]; // Adds all the old characters into the array first as this is a append. This uses that // length of the original string. for (int i = 0; i < lengthOld; i++) { m_data[i] = temp[i]; } // Adds the characters from the appending string to this string object. for (int i = 0; i < a_other->GetLength(); i++) { m_data[lengthOld + i] = a_other->At(i); } // Sets the last the character, the reason for the plus 1 is so I can add the null // terminator m_data[length - 1] = '\0'; //Deletes the Get raw memory allocation which is used above delete[] temp; }
VOID CHOSTAPI(ULONG * pEAX, ULONG * pEBX, ULONG * pECX, ULONG * pEDX, VOID ** pESI, VOID ** pEDI) { ULONG EAX = *pEAX; ULONG EBX = *pEBX; ULONG ECX = *pECX; ULONG EDX = *pEDX; VOID * ESI = *pESI; VOID * EDI = *pEDI; int Command; int Stream; int n; int Temp; PBPQVECSTRUC HostVec; TRANSPORTENTRY * Session; /* ; COMMANDS SUPPORTED ARE ; ; AH = 0 Get node/switch version number and description. On return ; AH = major version number and AL = minor version number, ; and user's buffer pointed to by ES:ESI is set to the text ; string normally output by the USERS command, eg: ; "G8BPQ Packet Switch Version 4.01 Dev". CX is set to the ; length of the text string. ; ; ; AH = 1 Set application mask to value in DL (or even DX if 16 ; applications are ever to be supported). ; ; Set application flag(s) to value in CL (or CX). ; whether user gets connected/disconnected messages issued ; by the node etc. ; ; ; AH = 2 Send frame in ES:ESI (length CX) ; ; ; AH = 3 Receive frame into buffer at ES:ESI, length of frame returned ; in CX. BX returns the number of outstanding frames still to ; be received (ie. after this one) or zero if no more frames ; (ie. this is last one). ; ; ; ; AH = 4 Get stream status. Returns: ; ; CX = 0 if stream disconnected or CX = 1 if stream connected ; DX = 0 if no change of state since last read, or DX = 1 if ; the connected/disconnected state has changed since ; last read (ie. delta-stream status). ; ; ; ; AH = 6 Session control. ; ; CX = 0 Conneect - _APPLMASK in DL ; CX = 1 connect ; CX = 2 disconnect ; CX = 3 return user to node ; ; ; AH = 7 Get buffer counts for stream. Returns: ; ; AX = number of status change messages to be received ; BX = number of frames queued for receive ; CX = number of un-acked frames to be sent ; DX = number of buffers left in node ; SI = number of trace frames queued for receive ; ;AH = 8 Port control/information. Called with a stream number ; in AL returns: ; ; AL = Radio port on which channel is connected (or zero) ; AH = SESSION TYPE BITS ; BX = L2 paclen for the radio port ; CX = L2 maxframe for the radio port ; DX = L4 window size (if L4 circuit, or zero) ; ES:EDI = CALLSIGN ;AH = 9 Fetch node/application callsign & alias. AL = application ; number: ; ; 0 = node ; 1 = BBS ; 2 = HOST ; 3 = SYSOP etc. etc. ; ; Returns string with alias & callsign or application name in ; user's buffer pointed to by ES:ESI length CX. For example: ; ; "WORCS:G8TIC" or "TICPMS:G8TIC-10". ; ; ; AH = 10 Unproto transmit frame. Data pointed to by ES:ESI, of ; length CX, is transmitted as a HDLC frame on the radio ; port (not stream) in AL. ; ; ; AH = 11 Get Trace (RAW Data) Frame into ES:EDI, ; Length to CX, Timestamp to AX ; ; ; AH = 12 Update Switch. At the moment only Beacon Text may be updated ; DX = Function ; 1=update BT. ES:ESI, Len CX = Text ; 2=kick off nodes broadcast ; ; AH = 14 Internal Interface for IP Router ; ; Send frame - to NETROM L3 if DL=0 ; to L2 Session if DL<>0 ; ; ; AH = 15 Get interval timer ; */ Command = (EAX & 0xFFFF) >> 8; Stream = (EAX & 0xFF); n = Stream - 1; // API Numbers Streams 1-64 if (n < 0 || n > 63) n = 64; HostVec = &BPQHOSTVECTOR[n]; Session = HostVec->HOSTSESSION; switch (Command) { case 0: // Check Loaded/Get Version EAX = ('P' << 8) | 'B'; EBX = ('Q' << 8) | ' '; EDX = (MAJORVERSION << 8) | MINORVERSION; break; case 1: // Set Appl mAsk HostVec->HOSTAPPLMASK = EDX; // APPL MASK HostVec->HOSTAPPLFLAGS = (UCHAR)ECX; // APPL FLAGS // If either is non-zero, set allocated and Process. This gets round problem with // stations that don't call allocate stream if (ECX || EBX) { HostVec->HOSTFLAGS |= 0x80; // SET ALLOCATED BIT HostVec->STREAMOWNER = GetCurrentProcessId(); // Set Program Name memcpy(&HostVec->PgmName, pgm, 31); } break; case 2: // Send Frame // ES:ESI = MESSAGE, CX = LENGTH, BX = VECTOR EAX = SendMsg(Stream, ESI, ECX); break; case 3: // AH = 3 Receive frame into buffer at ES:EDI, length of frame returned // in CX. BX returns the number of outstanding frames still to // be received (ie. after this one) or zero if no more frames // (ie. this is last one). EAX = GetMsg(Stream, EDI, &ECX, &EBX); break; case 4: // AH = 4 Get stream status. Returns: // CX = 0 if stream disconnected or CX = 1 if stream connected // DX = 0 if no change of state since last read, or DX = 1 if // the connected/disconnected state has changed since // last read (ie. delta-stream status). ECX = EDX = 0; if (HostVec->HOSTFLAGS & 3) //STATE CHANGE BITS EDX = 1; if (Session) ECX = 1; break; case 5: // AH = 5 Ack stream status change HostVec->HOSTFLAGS &= 0xFC; // Clear Chnage Bits break; case 6: // AH = 6 Session control. // CX = 0 Conneect - APPLMASK in DL // CX = 1 connect // CX = 2 disconnect // CX = 3 return user to node SessionControl(Stream, ECX, EDX); break; case 7: // AH = 7 Get buffer counts for stream. Returns: // AX = number of status change messages to be received // BX = number of frames queued for receive // CX = number of un-acked frames to be sent // DX = number of buffers left in node // SI = number of trace frames queued for receive ECX = 0; // unacked frames EDX = QCOUNT; ESI = (void *)MONCount(Stream); EBX = RXCount(Stream); ECX = TXCount(Stream); EAX = 0; // Is this right ??? break; case 8: // AH = 8 Port control/information. Called with a stream number // in AL returns: // // AL = Radio port on which channel is connected (or zero) // AH = SESSION TYPE BITS // BX = L2 paclen for the radio port // CX = L2 maxframe for the radio port // DX = L4 window size (if L4 circuit, or zero) // ES:EDI = CALLSIGN GetConnectionInfo(Stream, EDI, &EAX, &Temp, &EBX, &ECX, &EDX); // Return the Secure Session Flag rather than not connected EAX |= Temp <<8; break; case 9: // Not Implemented break; case 10: // AH = 10 Unproto transmit frame. Data pointed to by ES:ESI, of // length CX, is transmitted as a HDLC frame on the radio // port (not stream) in AL. EAX = SendRaw(EAX, ESI, ECX); return; case 11: // AH = 11 Get Trace (RAW Data) Frame into ES:EDI, // Length to CX, Timestamp to AX EAX = GetRaw(Stream, EDI, &ECX, &EBX); break; case 12: // Update Switch if (EDX == 2) { SENDNODESMSG(); break; } if (EDX == 2) { // UPDATE BT BTLENGTH = ECX; memcpy(BTEXTFLD, ESI, ECX + 7); } break; case 13: // BPQALLOC // AL = 0 = Find Free // AL != 0 Alloc or Release if (EAX == 0) { EAX = FindFreeStream(); break; } if (ECX == 1) // Allocate { EAX = AllocateStream(Stream); break; } DeallocateStream(Stream); break; case 14: // AH = 14 Internal Interface for IP Router // Send frame - to NETROM L3 if DL=0 // to L2 Session if DL<>0 break; // Shouldn't be needed case 15: // GETTIME EAX = REALTIMETICKS; EBX = 0; #ifdef EXCLUDEBITS EBX = (ULONG)ExcludeList; #endif break; } *pEAX = EAX; *pEBX = EBX; *pECX = ECX; *pEDX = EDX; *pESI = ESI; *pEDI = EDI; return; }
/** * Gets the current count. * * Returns the current count on the Encoder. This method compensates for the * decoding type. * * @return Current count from the Encoder adjusted for the 1x, 2x, or 4x scale * factor. */ int32_t Encoder::Get() const { if (StatusIsFatal()) return 0; return (int32_t)(GetRaw() * DecodingScaleFactor()); }
/** * Get the distance the robot has driven since the last reset. * * @return The distance driven since the last reset as scaled by the value from * SetDistancePerPulse(). */ double Encoder::GetDistance() const { if (StatusIsFatal()) return 0.0; return GetRaw() * DecodingScaleFactor() * m_distancePerPulse; }
/** * Get the distance the robot has driven since the last reset. * * @return The distance driven since the last reset as scaled by the value from SetDistancePerPulse(). */ double Encoder::GetDistance() { return GetRaw() * DecodingScaleFactor() * m_distancePerPulse; }
bool GetString(pfc::string_base & out) { pfc::array_t<t_uint8> temp; if (!GetRaw(CF_TCHAR,temp)) return false; out = pfc::stringcvt::string_utf8_from_os(reinterpret_cast<const TCHAR*>(temp.get_ptr()),temp.get_size() / sizeof(TCHAR)); return true; }
bool RarTime::operator < (RarTime &rt) { return(GetRaw()<rt.GetRaw()); }
/** * Gets the current count. * Returns the current count on the Encoder. * This method compensates for the decoding type. * * @return Current count from the Encoder adjusted for the 1x, 2x, or 4x scale factor. */ INT32 Encoder::Get() { return (INT32) (GetRaw() * DecodingScaleFactor()); }
bool RarTime::operator > (RarTime &rt) { return(GetRaw()>rt.GetRaw()); }
int Player::ToScore () const { return 1 - int(GetRaw() + GetRaw()) ; }
Player Player::Other() const { return Player(GetRaw() ^ 1); }
/** * Gets the current count. * Returns the current count on the Encoder. * This method compensates for the decoding type. * * @return Current count from the Encoder adjusted for the 1x, 2x, or 4x scale factor. */ INT32 Encoder::Get() { if (StatusIsFatal()) return 0; return (INT32) (GetRaw() * DecodingScaleFactor()); }
void Idle::Start() { Invoke(&uv_idle_start, GetRaw(), [](uv_idle_t* handle) { Idle& h = *static_cast<Idle*>(handle->data); h.idle(); }); }