Exemplo n.º 1
0
BOOL	LLMultiSlider::handleKeyHere(KEY key, MASK mask)
{
	BOOL handled = FALSE;
	switch(key)
	{
	case KEY_UP:
	case KEY_DOWN:
		// eat up and down keys to be consistent
		handled = TRUE;
		break;
	case KEY_LEFT:
		setCurSliderValue(getCurSliderValue() - getIncrement());
		onCommit();
		handled = TRUE;
		break;
	case KEY_RIGHT:
		setCurSliderValue(getCurSliderValue() + getIncrement());
		onCommit();
		handled = TRUE;
		break;
	default:
		break;
	}
	return handled;
}
Exemplo n.º 2
0
AREXPORT void ArLaser::laserConnect(void)
{
  // figure out how many readings we can have and set the current
  // buffer size to that
  double degrees;

  myLastReading.setToNow();

  if (canSetDegrees())
  {
    //degrees = fabs(ArMath::subAngle(getStartDegrees(), getEndDegrees()));
    degrees = fabs(getStartDegrees() - getEndDegrees());
    ArLog::log(myInfoLogLevel, 
	       "%s: Using degrees settings of %g to %g for %g degrees",
	       getName(), getStartDegrees(), getEndDegrees(), 
	       degrees);
  }
  else if (canChooseDegrees())
  {
    degrees = getDegreesChoiceDouble();
    ArLog::log(myInfoLogLevel, "%s: Using choice of %g degrees",
	       getName(), degrees);
  }
  else
  {
    degrees = 360;
    ArLog::log(ArLog::Terse, "%s: Don't have any settings for degrees, arbitrarily using 360", getName());
  }

  double increment;
  if (canSetIncrement())
  {
    increment = getIncrement();
    ArLog::log(myInfoLogLevel, "%s: Using increment setting of %g degrees",
	       getName(), increment);
  }
  else if (canChooseIncrement())
  {
    increment = getIncrementChoiceDouble();
    ArLog::log(myInfoLogLevel, "%s: Using increment setting of %g degrees",
	       getName(), increment);
  }
  else
  {
	// PS 10/20/11 - This was missing causing buffer size to be very large
	// set this to the lowest, note both the SZ and S3 are setting the buffer
	// size but it's being overriden by this procedure - do we want to fix
	// this or just leave it at the max value 360/.25=1440???
	increment = .25;
    ArLog::log(ArLog::Terse, "%s: Don't have any settings for increment, arbitrarily using .25", getName());
  }
  
  int size = (int)ceil(degrees / increment) + 1;
  ArLog::log(myInfoLogLevel, "%s: Setting current buffer size to %d", 
	     getName(), size);
  setCurrentBufferSize(size);
  
  ArLog::log(myInfoLogLevel, "%s: Connected", getName());
  myConnectCBList.invoke();
}
Exemplo n.º 3
0
void Board::restoreWord(const AXIS::Axis axis, Cell *cell, Cell* copyBuff) {
    int incr = getIncrement(axis);
    while(copyBuff->letter!=(char)0) {
        *cell = *copyBuff++;
        cell+=incr;
    }
}
Exemplo n.º 4
0
void Board::addWord(const string& testWord, const AXIS::Axis testAxis, const int testRow, const int testCol) {
    Cell *cell = getCell(testRow, testCol);
    int incr = getIncrement(testAxis);
    for(uint i=0;i<testWord.size();i++) {
        cell->set(testWord[i]);
        cell+=incr;
    }
}
Exemplo n.º 5
0
double OnionSkinMask::getOnionSkinFade(int rowsDistance) {
  if (rowsDistance == 0) return 0.9;

  double fade =
      MINFADE +
      abs(rowsDistance) *
          getIncrement(Preferences::instance()->getOnionPaperThickness());
  return tcrop(fade, MINFADE, MAXFADE);
}
Exemplo n.º 6
0
BOOL LLSlider::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
	if ( mOrientation == VERTICAL )
	{
		F32 new_val = getValueF32() - clicks * getIncrement();
		setValueAndCommit(new_val);
		return TRUE;
	}
	return LLF32UICtrl::handleScrollWheel(x,y,clicks);
}
int LOOP::doupdate()
{
	double p[9];
	update(p, 9);

	_amp = p[3];
	_incr = getIncrement(p[4]);
	_pan = _usesPan ? p[8] : 0.5;
	return calculateLoop(p);
}
Exemplo n.º 8
0
AREXPORT void ArLaser::laserConnect(void)
{
  // figure out how many readings we can have and set the current
  // buffer size to that
  double degrees;

  myLastReading.setToNow();

  if (canSetDegrees())
  {
    degrees = fabs(getStartDegrees() - getEndDegrees());
    ArLog::log(myInfoLogLevel, 
	       "%s: Using degrees settings of %g to %g for %g degrees",
	       getName(), getStartDegrees(), getEndDegrees(), 
	       degrees);
  }
  else if (canChooseDegrees())
  {
    degrees = getDegreesChoiceDouble();
    ArLog::log(myInfoLogLevel, "%s: Using choice of %g degrees",
	       getName(), degrees);
  }
  else
  {
    degrees = 360;
    ArLog::log(ArLog::Terse, "%s: Don't have any settings for degrees, arbitrarily using 360", getName());
  }

  double increment;
  if (canSetIncrement())
  {
    increment = getIncrement();
    ArLog::log(myInfoLogLevel, "%s: Using increment setting of %g degrees",
	       getName(), increment);
  }
  else if (canChooseIncrement())
  {
    increment = getIncrementChoiceDouble();
    ArLog::log(myInfoLogLevel, "%s: Using increment setting of %g degrees",
	       getName(), increment);
  }
  else
  {
    ArLog::log(ArLog::Terse, "%s: Don't have any settings for degrees, arbitrarily using 1000 for current buffer size", getName());
  }
  
  int size = (int)ceil(degrees / increment) + 1;
  ArLog::log(myInfoLogLevel, "%s: Setting current buffer size to %d", 
	     getName(), size);
  setCurrentBufferSize(size);
  
  ArLog::log(myInfoLogLevel, "%s: Connected", getName());
  myConnectCBList.invoke();
}
Exemplo n.º 9
0
void Board::cementWord(const char *word, const AXIS::Axis testAxis, Cell *cell, Cell* copyBuff) {
    int incr = getIncrement(testAxis);
    char *testWord = const_cast<char *>(word);
    do {
        *copyBuff++ = *cell; //*testWord+=incr;
        cell->set(*testWord++);
        cell->assertCovered();
        cell+=incr;
    } while(*testWord);
    copyBuff->letter = (char)0;
}
Exemplo n.º 10
0
BOOL LLSlider::handleKeyHere(KEY key, MASK mask)
{
	BOOL handled = FALSE;
	switch(key)
	{
	case KEY_DOWN:
	case KEY_LEFT:
		setValueAndCommit(getValueF32() - getIncrement());
		handled = TRUE;
		break;
	case KEY_UP:
	case KEY_RIGHT:
		setValueAndCommit(getValueF32() + getIncrement());
		handled = TRUE;
		break;
	default:
		break;
	}
	return handled;
}
Exemplo n.º 11
0
// virtual
LLXMLNodePtr LLSlider::getXML(bool save_children) const
{
	LLXMLNodePtr node = LLUICtrl::getXML();

	node->createChild("initial_val", TRUE)->setFloatValue(getInitialValue());
	node->createChild("min_val", TRUE)->setFloatValue(getMinValue());
	node->createChild("max_val", TRUE)->setFloatValue(getMaxValue());
	node->createChild("increment", TRUE)->setFloatValue(getIncrement());
	node->createChild("volume", TRUE)->setBoolValue(mVolumeSlider);

	return node;
}
Exemplo n.º 12
0
  void processAudio(AudioBuffer &buffer) {
    FloatArray left = buffer.getSamples(LEFT_CHANNEL);
    FloatArray right = buffer.getSamples(RIGHT_CHANNEL);
    for(int i = 0; i<buffer.getSize(); i++){
      if(abs(last-target) < 0.001){
	last = target;
	target = noise->getNextSample()*range;
      }
      left[i] = last;
      last += getIncrement();
      right[i] = hz.voltsToSample(quantize(hz.sampleToVolts(right[i])));
    }
  }
Exemplo n.º 13
0
// virtual
LLXMLNodePtr LLMultiSlider::getXML(bool save_children) const
{
    LLXMLNodePtr node = LLUICtrl::getXML();

    node->setName(LL_MULTI_SLIDER_TAG);

    node->createChild("initial_val", TRUE)->setFloatValue(getInitialValue());
    node->createChild("min_val", TRUE)->setFloatValue(getMinValue());
    node->createChild("max_val", TRUE)->setFloatValue(getMaxValue());
    node->createChild("increment", TRUE)->setFloatValue(getIncrement());

    return node;
}
Exemplo n.º 14
0
void initializeEverything()
{
	int i, j, k;
	uint32_t increment;
	LCDInitialize();
	SPI_Initialize();
	//* setup oscs
	initializeOscillators();
	// Setup the keyboard usb
	SynthStationUsbInitialize();
	//calculate the note frequencies
		WaveformTablesInitialize();
		
	/** Calculate frequency increments */
	for(i = 0; i < 120; i++)
	{
		increment = noteTable[i];
		noteTable[i] = getIncrement(increment);
	}
	
	/** Initialize sequencer layerw */
	
	for(i = 0; i < 8; i++)
	{
		for(j = 0; j < SEQUENCER_STEPS; j++)
		{
				synthLayers[i].sequenceNotes[j] = 0xFFFF;
		}
		synthLayers[i].waveType = currentSelectedWaveForm;
	}
	
	synthLayers[0].layerFlags |= LAYER_FLAGS_ENABLED;
	synthLayers[1].layerFlags |= LAYER_FLAGS_ENABLED;
	
	noteListHead = (noteListItem *)malloc(sizeof(noteListItem));
	noteListHead->pNextItem = NULL;
	noteListHead->pNote = NULL;
	noteListTail = noteListHead;
		
	currentSelectedMode = SYNTH_RECORDING;
	setBPM(DEFAULT_BPM);
	
	BEAT_LED_START_DD = BEAT_LED_DD = 1;
	BEAT_LED_START = BEAT_LED = 0;
	
	//listTest();
	
}
short ElemDDLSGOptions::genSGA(SequenceGeneratorAttributes &sga)
{
  sga.setSGStartValue(getStartValue());
  sga.setSGIncrement(getIncrement());
  sga.setSGMinValue(getMinValue());
  sga.setSGMaxValue(getMaxValue());

  sga.setSGCache(getCache());
  sga.setSGCycleOption(isCycle());

  sga.setSGFSDataType(getFSDataType());

  sga.setSGResetOption(isReset());

  return 0;
}
Exemplo n.º 16
0
uint Board::scoreAxis(const Cell* cell, AXIS::Axis axis, string prefix) {
    uint score = 0;
    uint wf = 1;
    uint incr = getIncrement(axis);
    Cell *from, *to;
    if (getEndpoints(cell, axis, from, to) && from != to) {
        //cout << "\n\n";
        for (const Cell* c = from; c <= to; c += incr) {
            uint lf = c->letterFactor;
            uint lwf = c->wordFactor;
            uint va = c->value;
            wf *= lwf;
            score += lf * va;
        }
        score *= wf;
    }
    return score;
}
Exemplo n.º 17
0
uint Board::scoreMove(const Cell* cell, AXIS::Axis axis) {
    uint primaryScore = scoreAxis(cell, axis);
    uint dualScores = 0;
    uint numChanged = 0;
    Cell *from, *to;
    uint incr = getIncrement(axis);
    AXIS::Axis dual = getDual(axis);
    if (getEndpoints(cell, axis, from, to)) {
        for (const Cell* c = from; c <= to; c += incr) {
            if (changed(c)) {
                numChanged++;
                uint sec = scoreAxis(c, dual, "   ");
                dualScores += sec;
            }
        }
    }
    uint totalScore = primaryScore + dualScores;
    if(numChanged == Common::rackSize) totalScore+=Common::bingoValue;
    return totalScore;
}
Exemplo n.º 18
0
void ddaLine(unsigned int x1,unsigned int x2,unsigned int y1,unsigned int y2){
  int dy = y2-y1;
  int dx = x2-x1;
  int increment = getIncrement(dx,dy);
  float x = x1,y = y1;
  int i = 0,j=0;

  float yIncrement = dy/(float)increment;
  float xIncrement = dx/(float)increment;

  matrix[ROUND_NUMBER(y)][ROUND_NUMBER(x)] = 1;

  for(i=0;i<increment;i++){
    x+= xIncrement;
    y+= yIncrement;
    matrix[ROUND_NUMBER(y)][ROUND_NUMBER(x)] = 1;
  }

  createImage(W,H,matrix);
}
Exemplo n.º 19
0
// virtual
LLXMLNodePtr LLSlider::getXML(bool save_children) const
{
	LLXMLNodePtr node = LLUICtrl::getXML();

	if (mVolumeSlider)
	{
		node->setName(LL_VOLUME_SLIDER_CTRL_TAG);
	}
	else
	{
		node->setName(LL_SLIDER_TAG);
	}

	node->createChild("initial_val", TRUE)->setFloatValue(getInitialValue());
	node->createChild("min_val", TRUE)->setFloatValue(getMinValue());
	node->createChild("max_val", TRUE)->setFloatValue(getMaxValue());
	node->createChild("increment", TRUE)->setFloatValue(getIncrement());
	node->createChild("volume", TRUE)->setBoolValue(mVolumeSlider);

	return node;
}
Exemplo n.º 20
0
int LOOP::init(double p[], int n_args)
{
	if (n_args < 7)
		return die("LOOP",
				   "Usage: LOOP(start, inskip, dur, amp, trans, loopstart, looplen[, inchan, pan])");

	const float outskip = p[0];
	const float inskip = p[1];
	float dur = p[2];
	if (dur < 0.0)
		dur = -dur - inskip;

	_incr = getIncrement(p[4]);
	
	_inchan = (n_args > 7) ? (int) p[7] : 0;
	_usesPan = (n_args > 8);
	_pan = _usesPan ? p[8] : 0.5;

	if (calculateLoop(p) == -1)
		return DONT_SCHEDULE;
	
	if (rtsetoutput(outskip, dur, this) == -1)
		return DONT_SCHEDULE;

	if (outputChannels() > 2)
		return die("LOOP", "Use mono or stereo output only.");

	if (rtsetinput(inskip, this) == -1)
		return DONT_SCHEDULE;

	if (_inchan >= inputChannels())
		return die("LOOP", "You asked for channel %d of a %d-channel input.", _inchan, inputChannels());

	_position = inskip * SR;	// Actual starting position in the input file
	_inOffset = 0;	// Offset of first sample in _in array compared to _position.
	
	return nSamps();
}
AREXPORT bool ArUrg::blockingConnect(void)
{
  if (!getRunning())
    runAsync();

  myConnMutex.lock();
  if (myConn == NULL)
  {
    ArLog::log(ArLog::Terse, 
	       "%s: Could not connect because there is no connection defined", 
	       getName());
    myConnMutex.unlock();
    failedToConnect();
    return false;
  }

  ArSerialConnection *serConn = NULL;
  serConn = dynamic_cast<ArSerialConnection *>(myConn);

  if (serConn != NULL)
    serConn->setBaud(atoi(getStartingBaudChoice()));

  if (myConn->getStatus() != ArDeviceConnection::STATUS_OPEN && 
      !myConn->openSimple())
  {
    ArLog::log(ArLog::Terse, 
	       "%s: Could not connect because the connection was not open and could not open it", 
	       getName());
    myConnMutex.unlock();
    failedToConnect();
    return false;
  }
  myConnMutex.unlock();

  lockDevice();
  myTryingToConnect = true;
  unlockDevice();

  laserPullUnsetParamsFromRobot();
  laserCheckParams();
  
  setParams(getStartDegrees(), getEndDegrees(), getIncrement(), getFlipped());
  
  ArUtil::sleep(100);

  bool connected = false;

  if (internalConnect())
    connected = true;

  if (connected)
  {
    lockDevice();
    myIsConnected = true;
    myTryingToConnect = false;
    unlockDevice();
    ArLog::log(ArLog::Normal, "%s: Connected to laser", getName());
    laserConnect();
    return true;
  }
  else
  {
    failedToConnect();
    return false;
  }
}
Exemplo n.º 22
0
bool ArUrg_2_0::internalConnect(void)

{
  bool ret = true;
  char buf[1024];
  

  ArSerialConnection *serConn = NULL;
  serConn = dynamic_cast<ArSerialConnection *>(myConn);

  bool alreadyAtAutobaud = false;



  // empty the buffer...
  /*
  sendCommandAndRecvStatus(
	  "RS", "reset", 
	  buf, sizeof(buf), 1000);
  readLine(buf, sizeof(buf), 1, true, false);

  sendCommandAndRecvStatus(
	  "SCIP2.0", "SCIP 2.0 request", 
	  buf, sizeof(buf), 1000);
  */

  writeLine("RS");
  ArUtil::sleep(100);

  writeLine("SCIP2.0");
  ArUtil::sleep(100);

  ArTime startedFlushing;

  while (readLine(buf, sizeof(buf), 1, true, false) ||
	 startedFlushing.mSecSince() < 1000);

  buf[0] = '\0';

  if (!(ret = sendCommandAndRecvStatus(
		"VV", "version request", 
		buf, sizeof(buf), 10000)) || 
      strcasecmp(buf, "00") != 0)      
  {
    // if we didn't get it and have an autobaud, try it at what the autobaud rate is
    if (serConn != NULL && atoi(getAutoBaudChoice()) > 0)
    {
      alreadyAtAutobaud = true;
      serConn->setBaud(atoi(getAutoBaudChoice()));
      ArUtil::sleep(100);

      writeLine("RS");
      ArUtil::sleep(100);
      
      writeLine("SCIP2.0");
      ArUtil::sleep(100);
      
      startedFlushing.setToNow();
      while (readLine(buf, sizeof(buf), 1, true, false) ||
	     startedFlushing.mSecSince() < 1000);
      
      if (!(ret = sendCommandAndRecvStatus(
		"VV", "version request after falling back to autobaudchoice", 
		buf, sizeof(buf), 10000)) || 
	  strcasecmp(buf, "00") != 0)      
      {
	if (ret && strcasecmp(buf, "00") != 0)      
	  ArLog::log(ArLog::Normal, 
		     "%s::blockingConnect: Bad status on version response after falling back to autobaudchoice", 
		     getName());
	return false;
      }
    }
    // if we don't have a serial port or no autobaud then we can't
    // change the baud, so just fail
    else
    {
      if (ret && strcasecmp(buf, "00") != 0)      
	ArLog::log(ArLog::Normal, 
		   "%s::blockingConnect: Bad status on version response (%s)",
		   getName(), buf);
      return false;
    }
  }

  // if we want to autobaud, then give it a whirl
  if (!alreadyAtAutobaud && serConn != NULL && atoi(getAutoBaudChoice()) > 0)
  {

    // empty the buffer from the last version request
    while (readLine(buf, sizeof(buf), 100, true, false));

    // now change the baud...
    sprintf(buf, "SS%06d", atoi(getAutoBaudChoice()));
    if (!writeLine(buf))
      return false;

    ArUtil::sleep(100);

    //serConn->setBaud(115200);
    serConn->setBaud(atoi(getAutoBaudChoice()));
    // wait a second for the baud to change...
    ArUtil::sleep(100);

    // empty the buffer from the baud change
    while (readLine(buf, sizeof(buf), 100, true, false));
    
    if (!(ret = sendCommandAndRecvStatus(
		  "VV", "version request after switching to autobaudchoice", 
		  buf, sizeof(buf), 10000)) || 
	strcasecmp(buf, "00") != 0)      
    {
      if (ret && strcasecmp(buf, "00") != 0)      
	ArLog::log(ArLog::Normal, 
		   "%s::blockingConnect: Bad status on version response after switching to autobaudchoice", 
		   getName());
      return false;
    }

    ArLog::log(ArLog::Verbose, "%s: Switched to %s baud rate",
	       getName(), getAutoBaudChoice());
  }

  while (readLine(buf, sizeof(buf), 10000, false, true))
  {
    if (strlen(buf) == 0)
      break;

    if (strncasecmp(buf, "VEND:", strlen("VEND:")) == 0)
      myVendor = &buf[5];
    else if (strncasecmp(buf, "PROD:", strlen("PROD:")) == 0)
      myProduct = &buf[5];
    else if (strncasecmp(buf, "FIRM:", strlen("FIRM:")) == 0)
      myFirmwareVersion = &buf[5];
    else if (strncasecmp(buf, "PROT:", strlen("PROT:")) == 0)
      myProtocolVersion = &buf[5];
    else if (strncasecmp(buf, "SERI:", strlen("SERI:")) == 0)
      mySerialNumber = &buf[5];
    else if (strncasecmp(buf, "STAT:", strlen("STAT:")) == 0)
      myStat = &buf[5];
  }

  if (myVendor.empty() || myProduct.empty() || myFirmwareVersion.empty() || 
      myProtocolVersion.empty() || mySerialNumber.empty())
  {
    ArLog::log(ArLog::Normal, 
	       "%s::blockingConnect: Missing information in version response",
	       getName());
    return false;
  }

  if (!(ret = sendCommandAndRecvStatus(
		"PP", "parameter info request", 
		buf, sizeof(buf), 10000)) || 
      strcasecmp(buf, "00") != 0)      
  {
    ArLog::log(ArLog::Normal, 
	       "%s::blockingConnect: Bad response to parameter info request",
	       getName());
    return false;
  }

  while (readLine(buf, sizeof(buf), 10000, false, true))
  {
    if (strlen(buf) == 0)
      break;

    if (strncasecmp(buf, "MODL:", strlen("MODL:")) == 0)
      myModel = &buf[5];
    else if (strncasecmp(buf, "DMIN:", strlen("DMIN:")) == 0)
      myDMin = atoi(&buf[5]);
    else if (strncasecmp(buf, "DMAX:", strlen("DMAX:")) == 0)
      myDMax = atoi(&buf[5]);
    else if (strncasecmp(buf, "ARES:", strlen("ARES:")) == 0)
      myARes = atoi(&buf[5]);
    else if (strncasecmp(buf, "AMIN:", strlen("AMIN:")) == 0)
      myAMin = atoi(&buf[5]);
    else if (strncasecmp(buf, "AMAX:", strlen("AMAX:")) == 0)
      myAMax = atoi(&buf[5]);
    else if (strncasecmp(buf, "AFRT:", strlen("AFRT:")) == 0)
      myAFront = atoi(&buf[5]);
    else if (strncasecmp(buf, "SCAN:", strlen("SCAN:")) == 0)
      myScan = atoi(&buf[5]);
  }

  if (myModel.empty() || myDMin == 0 || myDMax == 0 || myARes == 0 ||
      myAMin == 0 || myAMax == 0 || myAFront == 0 || myScan == 0)
  {
    ArLog::log(ArLog::Normal, 
	       "%s::blockingConnect: Missing information in parameter info response",
	       getName());
    return false;
  }

  myStepSize = 360.0 / myARes;
  myStepFirst = myAFront * myStepSize;
  
  if (myMaxRange > myDMax)
    setMaxRange(myDMax);

  //log();

  setParams(getStartDegrees(), getEndDegrees(), getIncrement(), getFlipped());

  //myLogMore = true;
  //  myLogMore = false;
  ArUtil::sleep(100);
  
  
  //printf("myRequestString %s\n", myRequestString);

  if (!(ret = sendCommandAndRecvStatus(
		myRequestString, "request distance reading", 
		buf, sizeof(buf), 10000)) || 
      strcasecmp(buf, "00") != 0)
  {
    if (ret && strcasecmp(buf, "00") != 0) 
      ArLog::log(ArLog::Normal, 
	 "%s::blockingConnect: Bad status on distance reading response (%s)",
		 getName(), buf);
    return false;
  }
  
  //myLogMore = false;

  ArTime started;
  started.setToNow();
  while (started.secSince() < 10 && 
	 readLine(buf, sizeof(buf), 10000, true, false))
  {
    if (strlen(buf) == 0)
      return true;
  }

  ArLog::log(ArLog::Normal, "%s::blockingConnect: Did not get distance reading back",
	     getName());
  return false;
}
// queryType:  0, create sequence.  1, alter sequence.  2, IDENTITY col.
short ElemDDLSGOptions::validate(short queryType)
{
  char queryTypeStr[40];

  if (queryType == 0)
    strcpy(queryTypeStr, "CREATE SEQUENCE");
  else if (queryType == 1)
    strcpy(queryTypeStr, "ALTER SEQUENCE");
  else
    strcpy(queryTypeStr, "IDENTITY column");

  Int64 minValue = 0;
  Int64 startValue = 0;
  Int64 increment = 0;
  Int64 maxValue = LONG_MAX - 1;

  NAString dtStr;
  if (fsDataType_ != COM_UNKNOWN_FSDT)
    {
      switch (fsDataType_)
        {
        case COM_UNSIGNED_BIN16_FSDT:
          maxValue = USHRT_MAX;
          dtStr = COM_SMALLINT_UNSIGNED_SDT_LIT;
          break;
        case COM_UNSIGNED_BIN32_FSDT:
          maxValue = UINT_MAX;
          dtStr = COM_INTEGER_UNSIGNED_SDT_LIT;
          break;
        case COM_SIGNED_BIN64_FSDT:
          maxValue = LONG_MAX - 1;
          dtStr =  COM_LARGEINT_SIGNED_SDT_LIT;
          break;
        default:
          *CmpCommon::diags() << DgSqlCode(-1510);
          return -1;
        }
    }

  if (queryType == 1) // alter
    {
      if ((isMinValueSpecified()|| isStartValueSpecified()))
        {
          *CmpCommon::diags() << DgSqlCode(-1592)
                              << (isMinValueSpecified() ? DgString0("MINVALUE") : DgString0("START WITH"))
                              << DgString1(queryTypeStr);
          
          return -1;
        }
      
      minValue = getMinValue();
      startValue = getStartValue();
      increment = getIncrement();

      if (isMaxValueSpecified() && (NOT isNoMaxValue()))
        {
          if ((fsDataType_ != COM_UNKNOWN_FSDT) &&
              (getMaxValue() > maxValue))
            {
              *CmpCommon::diags() << DgSqlCode(-1576)
                                  << DgString0("MAXVALUE")
                                  << DgString1(dtStr);
              
              return -1;
            }
        }

      maxValue = getMaxValue();
    } // alter
  else
    {
      if (isResetSpecified())
        {
          *CmpCommon::diags() << DgSqlCode(-1592)
                              << DgString0("RESET") 
                              << DgString1(queryTypeStr);
          
          return -1;
        }
 
      minValue = ((isMinValueSpecified() && (NOT isNoMinValue())) ? 
                  getMinValue() : 1LL); 
      startValue = (isStartValueSpecified() ? getStartValue() : minValue);
      increment = (isIncrementSpecified() ? getIncrement() : 1LL);
    } //else

  if (isMaxValueSpecified() && (NOT isNoMaxValue()))
    {
      if ((fsDataType_ != COM_UNKNOWN_FSDT) &&
          (getMaxValue() > maxValue))
        {
          *CmpCommon::diags() << DgSqlCode(-1576)
                              << DgString0("MAXVALUE")
                              << DgString1(dtStr);
          
          return -1;
        }

      maxValue = getMaxValue();
    }

  if (minValue == 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1571)
			  << DgString0("MINVALUE")
			  << DgString1(queryTypeStr);
      
      return -1;
    }

  if (minValue < 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1572)
			  << DgString0("MINVALUE")
			  << DgString1(queryTypeStr);
      
      return -1;
    }

  if (maxValue == 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1571)
			  << DgString0("MAXVALUE")
			  << DgString1(queryTypeStr);
      
      return -1;
    }

  if (maxValue < 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1572)
			  << DgString0("MAXVALUE")
			  << DgString1(queryTypeStr);
      
      return -1;
    }

  if (increment == 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1571)
			  << DgString0("INCREMENT BY")
			  << DgString1(queryTypeStr);
      
      return -1;
    }

  if (increment < 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1572)
			  << DgString0("INCREMENT BY")
			  << DgString1(queryTypeStr);  
      return -1;
    }

  if (startValue < 0)
    {
      *CmpCommon::diags() << DgSqlCode(-1572)
			  << DgString0("START WITH")
			  << DgString1(queryTypeStr);
      
      return -1;
    }

  if (maxValue <= minValue)
    {
      *CmpCommon::diags() << DgSqlCode(-1570)
			  << DgString0(queryTypeStr);      
      return -1;
    }

  if (startValue > maxValue)
    {
      *CmpCommon::diags() << DgSqlCode(-1573)
			  << DgString0(queryTypeStr);      
      return -1;
    }

  if (startValue < minValue)
    {
      *CmpCommon::diags() << DgSqlCode(-1573)
			  << DgString0(queryTypeStr);      
      return -1;
    }

  if (increment > (maxValue - minValue))
    {
      *CmpCommon::diags() << DgSqlCode(-1575)
			  << DgString0(queryTypeStr);      
      return -1;
    }

  Int64 cache = 0;
  Int64 minVal = MAXOF(startValue, minValue);
  Int64 rangeOfVals = (maxValue-minVal)/increment + 1;

  if (isCacheSpecified())
    cache = getCache();
  else
    cache = MINOF(rangeOfVals, 25);

  if (NOT isNoCache())
    {
      if ((cache <= 1) ||
	  (cache > rangeOfVals))
	{
	  *CmpCommon::diags() << DgSqlCode(-1577)
			      << DgString0(queryTypeStr);	  
	  return -1;
	}
    }
  
  cache = MINOF(rangeOfVals, cache);

  setStartValue(startValue);
  setIncrement(increment);
  setMinValue(minValue);
  setMaxValue(maxValue);
  if (NOT isCacheSpecified())
    setCache(cache);

  return 0;
}
NATraceList
ElemDDLSGOptions::getDetailInfo() const
{
  NAString        detailText;
  NATraceList detailTextList;

  detailTextList.append("Sequence Generator Options:");
  detailText = "    SG Type:      ";

  if (isInternalSG())
    detailText = "INTERNAL ";
  else if (isExternalSG())
    detailText = "EXTERNAL ";
  else
    detailText = "UNKNOWN ";
  detailTextList.append(detailText);

  detailText = "    Start Value specified?   ";
  detailText += YesNo(isStartValueSpecified());
  detailTextList.append(detailText);

  detailText = "    Start Value:      ";
  detailText += Int64ToNAString(getStartValue());
  detailTextList.append(detailText);

  detailText = "    Increment specified?   ";
  detailText += YesNo(isIncrementSpecified());
  detailTextList.append(detailText);

  detailText = "    Increment:      ";
  detailText += Int64ToNAString(getIncrement());
  detailTextList.append(detailText);

  detailText = "    MaxValue specified?   ";
  detailText += YesNo(isMaxValueSpecified());
  detailTextList.append(detailText);

  if (isNoMaxValue())
  {
    detailText = "    Max Value:  NO MAXVAL      ";
    detailTextList.append(detailText);
  }
  else
  {
    detailText = "    Max Value:      ";
    detailText += Int64ToNAString(getMaxValue());
    detailTextList.append(detailText);
  }

  detailText = "    MinValue specified?   ";
  detailText += YesNo(isMinValueSpecified());
  detailTextList.append(detailText);

  if (isNoMinValue())
  {
    detailText = "    Min Value:  NO MINVAL      ";
    detailTextList.append(detailText);
  }
  else
  {
    detailText = "    Min Value:      ";
    detailText += Int64ToNAString(getMinValue());
    detailTextList.append(detailText);
  }

  detailText = "    Cycle specified?   ";
  detailText += YesNo(isCycleSpecified());
  detailTextList.append(detailText);

  if (isNoCycle())
  {
    detailText = "    Cycle Option:  NO CYCLE      ";
    detailTextList.append(detailText);
  }
  else
  {
    detailText = "    Cycle Option:  CYCLE      ";
    detailTextList.append(detailText);
  }

  detailText = "    Cache specified?   ";
  detailText += YesNo(isCacheSpecified());
  detailTextList.append(detailText);

  if (isNoCache())
  {
    detailText = "    Cache Option:  NO CACHE      ";
    detailTextList.append(detailText);
  }
  else
  {
    detailText = "    Cache Option:  CACHE      ";
    detailTextList.append(detailText);
  }

  return detailTextList;
}
Exemplo n.º 25
0
void FileGrabForeground::draw(DrawActionBase *action, Viewport *port)
{
    if(getActive() == false)
        return;
    
    if(getName().empty())
    {
        FWARNING(("FileGrabForeground::draw: no name ?!?\n"));
        return;
    }
    
    Image::PixelFormat pixelFormat = (Image::PixelFormat)getPixelFormat();
    pixelFormat = (pixelFormat == 0) ? Image::OSG_RGB_PF : pixelFormat;
    
    // do we have an image yet? If not, create one.
    if(getImage() == NullFC)
    {
        beginEditCP(this->getPtr(), FileGrabForeground::ImageFieldMask);
        {
			ImagePtr iPtr = Image::create();
			
			iPtr->set(pixelFormat, 1);
			
            setImage(iPtr);
        }
        endEditCP  (this->getPtr(), FileGrabForeground::ImageFieldMask);
    }
    else if(getImage()->getPixelFormat() != pixelFormat)
    {
        ImagePtr iPtr = getImage();
        
        beginEditCP(iPtr, Image::PixelFormatFieldMask);
        {
            iPtr->reformat(pixelFormat);
        }
        endEditCP  (iPtr, Image::PixelFormatFieldMask);
    }
    
    // read pixels
    Inherited::draw(action,port);
    
    Char8 *name = new Char8 [ getName().size() + 32 ]; // this is really 
                                                       // arbitrary... :(

    sprintf(name, getName().c_str(), getFrame());
    
    ImagePtr i = getImage();

    i->write(name);
    
    delete [] name;
    
    if(getIncrement() != false)
    {
        beginEditCP(this->getPtr(), FileGrabForeground::FrameFieldMask);
        {
            setFrame(getFrame() + 1);
        }
        endEditCP  (this->getPtr(), FileGrabForeground::FrameFieldMask);
    }   
}