7 #include "PlusConfigure.h" 45 LOG_ERROR(
"Failed to initialize SEI! COMPort=" << this->
m_COMPort);
51 LOG_ERROR(
"Failed to set baud rate for SEI!");
57 LOG_DEBUG(
"No need to initialize SEI, it's already connected!");
63 const long devNumber = 0;
65 long lSerialNumber = 0;
70 LOG_ERROR(
"Failed to get SEI device info for device number: " << devNumber);
79 LOG_WARNING(
"No device connected to ED2!");
96 LOG_ERROR(
"Failed to close SEI!");
105 double& GPosition,
double& RPosition,
unsigned long& PositionRequestNumber)
121 LOG_ERROR(
"Failed to get position1 (rotation angle) from E2 device!");
128 long probePositionInCm(0);
131 LOG_ERROR(
"Failed to get position2 (probe position) from E2 device!");
138 PPosition = -1.0 * PPosition;
149 int sign = ((floatPoint >> 31) == 0) ? 1 : -1;
154 int exp = ((floatPoint >> 23) & 0xff);
159 int m = (exp == 0) ? (floatPoint & 0x7fffff) << 1 : (floatPoint & 0x7fffff) | 0x800000;
163 _ltoa_s(m, bitset, 25, 2);
167 for (
int i = 0;
i < 24;
i++)
169 const char bit = bitset[
i];
170 mantissa += atoi(&bit) * pow(2.0, -
i);
175 const double bias = 127;
179 double decimalPoint = sign * mantissa * pow(2.0, exp - bias);
188 long lSerialNumber = 0;
193 LOG_ERROR(
"Failed to get SEI device info for device number: " << this->
m_DeviceNumber);
198 std::ostringstream strVersion;
199 strVersion << lVersion;
200 version = strVersion.str();
203 std::ostringstream strModel;
205 model = strModel.str();
208 std::ostringstream strSerial;
210 serial = strModel.str();
220 LOG_ERROR(
"Failed to reset SEI bus!");
231 CalibMsg =
"Encoder values set to 0!";
256 LOG_ERROR(
"Failed to set baud rate for SEI!");
270 LOG_DEBUG(
"Unable to set serial port number, stepper already connected!");
287 if (::
GetDeviceInfo(devnum, &model, &serialnum, &version, &addr) != 0)
289 LOG_ERROR(
"Failed to get device info from SEI with device number: " << devnum);
virtual PlusStatus ResetStepper()
virtual PlusStatus Disconnect()
long __stdcall ResetSEI()
virtual PlusStatus IsStepperAlive()
long GetDeviceInfo(long devnum, long &serialnum, long &addr, char *model, char *firmwareVersion)
PlusStatus GetSeiDeviceInfo(long devnum, long &model, long &serialnum, long &version, long &addr)
virtual ~PlusCivcoBrachyStepper()
virtual PlusStatus GetEncoderValues(double &PPosition, double &GPosition, double &RPosition, unsigned long &PositionRequestNumber)
long InitializeSEI(long comm, long mode, int devicesExpected)
PlusCivcoBrachyStepper(unsigned long COMPort=1, unsigned long BaudRate=9600)
virtual PlusStatus GetDeviceModelInfo(std::string &version, std::string &model, std::string &serial)
virtual PlusStatus Connect()
double ConvertFloatToDecimal(long floatPoint)
virtual PlusStatus InitializeStepper(std::string &CalibMsg)
unsigned long m_PositionRequestNumber
virtual PlusStatus SetBaudRate(unsigned long BaudRate)
virtual PlusStatus SetCOMPort(unsigned long COMPort)
long GetNumberOfDevices()
long __stdcall ED2GetPosition2(long address, long *pos)
long __stdcall ED2GetPosition1(long address, long *pos)
long GetNumberOfSeiDevices()