// Refresh the soft higher and lower limit void CPI_E761_ZStage::refreshPosLimit() { double low, high; int ret = GetLimits(low, high); if (ret != DEVICE_OK) return; SetPropertyLimits(MM::g_Keyword_Position, low, high); }
float VolumeControl::_PointForValue(int32 value) const { int32 min, max; GetLimits(&min, &max); if (Orientation() == B_HORIZONTAL) { return ceilf(1.0f * (value - min) / (max - min) * (BarFrame().Width() - 2) + BarFrame().left + 1); } return ceilf(BarFrame().top - 1.0f * (value - min) / (max - min) * BarFrame().Height()); }
//function to execute SELECT * query wyInt32 TableView::ExecuteTableData() { wyString query; wyInt32 ret; MySQLDataEx* pdata; query.Sprintf("select * from `%s`.`%s`", m_mydata->m_db.GetString(), m_mydata->m_table.GetString()); //get filter info GetFilterInfo(query); //get sort info GetSortInfo(query); //get limits GetLimits(query); //execut query m_mydata->m_datares = ExecuteQuery(query); //is thread stopped if(ThreadStopStatus()) { return TE_STOPPED; } //any error? show error dialog if(!m_mydata->m_datares) { return HandleErrors(query); } //allocate row array, if the thread is stopped, delete them if((ret = AllocateRowsExArray()) != TE_SUCCESS || (ret = GetTableDetails()) != TE_SUCCESS) { pdata = ResetData(m_data); delete pdata; return ret; } //add new row in the end AddNewRow(); return TE_SUCCESS; }
/* virtual */ void SizeSlider::SetValue(int32 value) { int32 max, min; GetLimits(&min, &max); const int32 numValues = 1 + (max - min) / fStep; int32 validValues[numValues]; for (int32 i = 0; i < numValues; i++) validValues[i] = min + fStep * i; for (int32 i = 0; i < numValues - 1; i++) { if (value > validValues[i] && value < validValues[i + 1]) { value = value > validValues[i] + (validValues[i + 1] - validValues[i]) / 2 ? validValues[i + 1] : validValues[i]; } } BSlider::SetValue(value); }
void VolumeControl::DrawBar() { BRect frame = BarFrame(); BView* view = OffscreenView(); if (be_control_look != NULL) { uint32 flags = be_control_look->Flags(this); rgb_color base = LowColor(); rgb_color rightFillColor = (rgb_color){255, 109, 38, 255}; rgb_color leftFillColor = (rgb_color){116, 224, 0, 255}; int32 min, max; GetLimits(&min, &max); float position = (float)min / (min - max); be_control_look->DrawSliderBar(view, frame, frame, base, leftFillColor, rightFillColor, position, flags, Orientation()); return; } BSlider::DrawBar(); }
ULong View::snap2grid (ULong code) { static ULong iPckedPnt = 0; static Bool lock = FALSE; if (code == WM_LBUTTONUP) { PCURVE pCurve = _Editor.GetActiveCurve (); if (pCurve != NULL) { if (_Editor.pCurrView->GetNearestPoint (pCurve, _Editor.MousePos, iPckedPnt)) { lock = TRUE; FP x,y; x = _Editor.pCurrCurve->CurveData[iPckedPnt].index; y = _Editor.pCurrCurve->CurveData[iPckedPnt].value; // calc new position FP xmin,xmax,ymin,ymax; GetLimits (xmin,xmax,ymin,ymax); // numbers & grads FP incx = 1e6; FP incy = 1e6; FP lx = (xmax - xmin) / 10; FP ly = (ymax - ymin) / 10; while (incx > lx) incx /= 10; while (incy > ly) incy /= 10; x = (floor((x / incx) + 0.5)) * incx; y = (floor((y / incy) + 0.5)) * incy; // change point pos pCurve->UnDrawCurve (_Editor.pCurrView); pCurve->CurveData[iPckedPnt].index = x; pCurve->CurveData[iPckedPnt].value = y; pCurve->DrawCurve (_Editor.pCurrView); } } } return lock; }
//function to execute SELECT * query wyInt32 TableView::ExecuteTableData() { wyString query; wyInt32 ret,extraindex,j=0,no_row; MySQLDataEx* pdata; MYSQL_ROW fieldrow; query.Sprintf("select * from `%s`.`%s`", m_mydata->m_db.GetString(), m_mydata->m_table.GetString()); //get filter info GetFilterInfo(query); //get sort info GetSortInfo(query); //get limits GetLimits(query); //execut query m_mydata->m_datares = ExecuteQuery(query); //is thread stopped if(ThreadStopStatus()) { return TE_STOPPED; } //any error? show error dialog if(!m_mydata->m_datares) { return HandleErrors(query); } //allocate row array, if the thread is stopped, delete them if((ret = AllocateRowsExArray()) != TE_SUCCESS || (ret = GetTableDetails()) != TE_SUCCESS) { pdata = ResetData(m_data); delete pdata; return ret; } extraindex = GetFieldIndex(m_wnd->m_tunnel, m_data->m_fieldres, "Extra"); no_row = m_wnd->m_tunnel->mysql_num_rows(m_data->m_fieldres); m_data->m_colvirtual = (wyInt32*)calloc(no_row, sizeof(wyInt32)); while(fieldrow = m_wnd->m_tunnel->mysql_fetch_row(m_data->m_fieldres)){ if(!strstr(fieldrow[extraindex], "VIRTUAL") && !strstr(fieldrow[extraindex], "PERSISTENT") && !strstr(fieldrow[extraindex], "STORED")) { m_data->m_colvirtual[j++] = 0; } else { m_data->m_colvirtual[j++] = 1; } } //add new row in the end AddNewRow(); return TE_SUCCESS; }
void ConnectTel(void) { struct termios tty; /* Packet to request version of azimuth motor driver */ char sendstr[] = { 0x50, 0x01, 0x10, 0xfe, 0x00, 0x00, 0x00, 0x02 }; /* Packet format: */ /* preamble */ /* packet length */ /* destination */ /* message id */ /* three message bytes */ /* number of response bytes */ char returnstr[32]; /* Packet format: */ /* response bytes if any */ /* # */ int numRead; int limits, flag; if(TelConnectFlag != FALSE) { return; } /* Make the connection */ /* TelPortFD = open("/dev/ttyS0",O_RDWR); */ TelPortFD = open(telserial,O_RDWR); if(TelPortFD == -1) { fprintf(stderr,"Serial port not available ... \n"); return; } tcgetattr(TelPortFD,&tty); cfsetospeed(&tty, (speed_t) B9600); cfsetispeed(&tty, (speed_t) B9600); tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; tty.c_iflag = IGNBRK; tty.c_lflag = 0; tty.c_oflag = 0; tty.c_cflag |= CLOCAL | CREAD; tty.c_cc[VMIN] = 1; tty.c_cc[VTIME] = 5; tty.c_iflag &= ~(IXON|IXOFF|IXANY); tty.c_cflag &= ~(PARENB | PARODD); tcsetattr(TelPortFD, TCSANOW, &tty); /* Flush the input (read) buffer */ tcflush(TelPortFD,TCIOFLUSH); /* Test connection by asking for version of azimuth motor */ writen(TelPortFD,sendstr,8); numRead=readn(TelPortFD,returnstr,3,2); if (numRead == 3) { fprintf(stderr,"RA/Azimuth "); fprintf(stderr,"controller version %d.%d ", returnstr[0], returnstr[1]); fprintf(stderr,"connected \n"); } else { fprintf(stderr,"RA/Azimuth drive not responding ...\n"); return; } /* Test connection by asking for version of altitude motor */ sendstr[2] = 0x11; /* Flush the input buffer */ tcflush(TelPortFD,TCIOFLUSH); /* Send the request */ writen(TelPortFD,sendstr,8); numRead=readn(TelPortFD,returnstr,3,2); /* Add null terminator to simplify handling the return data */ returnstr[numRead] = '\0'; if (numRead == 3) { fprintf(stderr,"Declination/Altitude "); fprintf(stderr,"controller version %d.%d ", returnstr[0], returnstr[1]); fprintf(stderr,"connected\n"); TelConnectFlag = TRUE; } else { fprintf(stderr,"Declination/altitude drive not responding ...\n"); return; } /* Perform startup tests */ flag = GetLimits(&limits); usleep(500000); limits = FALSE; flag = SetLimits(limits); usleep(500000); flag = GetLimits(&limits); /* Set global switch angles for a GEM OTA over the pier pointing at pole */ /* They correspond to ha ~ -6 hr and dec ~ +90 deg for northern telescope */ /* They correspond to ha ~ +6 hr and dec ~ -90 deg for southern telescope */ /* Non-zero values work better in goto routines on nexstar */ switchaz = 1.; switchalt = -1.0; /* Hardcoded defaults for homeha and homedec are overridden by prefs */ /* GEM: over the pier pointing at the pole */ /* EQFORK: pointing at the equator on the meridian */ /* ALTAZ: level and pointing north */ if ( homenow != TRUE ) { if (telmount == GEM) { if (SiteLatitude < 0.) { homedec = -89.9999; homeha = 6.; } else { homedec = 89.9999; homeha = -6.; } } else if (telmount == EQFORK) { if (SiteLatitude < 0.) { homedec = 0.; homeha = 0.; } else { homedec = 0.; homeha = 0.; } } else if (telmount == ALTAZ) { /* Set azimuth */ homeha = 0.; /* Set altitude */ homedec = 0.; } else { fprintf(stderr,"Telescope mounting must be GEM, EQFORK, or ALTAZ\n"); return; } } fprintf(stderr, "Using initial HA: %lf\n", homeha); fprintf(stderr, "Using initial Dec: %lf\n",homedec); flag = SetTelEncoders(homeha, homedec); if (flag != TRUE) { fprintf(stderr,"Initial telescope pointing request was out of range ... \n"); return; } /* Read encoders and confirm pointing */ GetTel(&homera, &homedec, RAW); fprintf(stderr, "Local latitude: %lf\n", SiteLatitude); fprintf(stderr, "Local longitude: %lf\n", SiteLongitude); fprintf(stderr, "Local sidereal time: %lf\n", LSTNow()); fprintf(stderr, "Mount type: %d\n", telmount); fprintf(stderr, "Mount now reading RA: %lf\n", homera); fprintf(stderr, "Mount now reading Dec: %lf\n", homedec); fprintf(stderr, "The telescope is running ...\n\n"); /* Flush the input buffer in case there is something left from startup */ tcflush(TelPortFD,TCIOFLUSH); }