Пример #1
0
//_____________________________________
// Read user input and act on it
bool controlMode( char ch ) {
    static int arg = -1;
    int retval = false;
    if (isdigit( ch )) {
      if (arg < 0) arg = 0;
      arg = arg * 10 + (ch - '0');
      return false;
    }
    switch ( ch ) {
    // 'N' triggers the NTP protocol manually
    case 'N': case 'n': triggerNtp() ; retval = true ; break ;

    // Left-arrow (Less-Than) slows down the clock for simulation runs
    case '<': case ',': slowDown() ;   retval = true ; break ;

    // Right-arrow (Greater-Than) speeds up the clock for simulation runs
    case '>': case '.': speedUp() ;    retval = true ; break ;

    // PLUS advances the digital clock minute
    case '+': case '=': incMinutes() ; retval = true ; break ;

    // MINUS decrements the digital clock minute
    case '_': case '-': decMinutes() ; retval = true ; break ;

    // H, M, S set hours, minutes, seconds
    case 'H': case 'h': if (arg >= 0) setHours(arg);                retval = true ;      break ;
    case 'M': case 'm': if (arg >= 0) setMinutes(arg);              retval = true ;      break ;
    case 'S': case 's': if (arg >= 0) setSeconds(arg); syncTime() ; retval = true ;      break ;

    // 'Z' resets the digital clock seconds
    case 'z': case 'Z': setSeconds(0) ; syncTime() ; return true ;

    // A, B and C manually force the A/B output pulses but do not affect the internal clock
    // A and B add to the force count for the A and B signals.  C adds to both signals.
    case 'A': case 'a': if (arg < 0) arg = 1 ;    sendPulsesA(arg) ;                     break ;
    case 'B': case 'b': if (arg < 0) arg = 1 ;    sendPulsesB(arg) ;                     break ;
    case 'C': case 'c': if (arg < 0) arg = 1 ;    sendPulsesA(arg) ;  sendPulsesB(arg) ; break ;
    case 'D': case 'd': if (arg < 0) arg = 1 ;    sendPulsesD(arg) ;                     break ;
    case 'E': case 'e':                           sendPulsesE(1)   ;                     break ;

    case 'f':                                     setState(LOW);                         break ;
    case 'F':                                     setState(HIGH);                        break ;

    case 'I': case 'i': if (arg < 0) arg = 60*60; clockHold(arg, arg) ;                  break ;
    case 'U': case 'u': if (arg < 0) arg = 60*60; clockHold(arg, 0) ;                    break ;
    case 'V': case 'v': if (arg < 0) arg = 60*60; clockHold(0, arg) ;                    break ;
    default: break;
  }
  arg = -1;
  return retval ;
}
Пример #2
0
LinearVelocity::LinearVelocity(const Distance* const newDistance, const Time* const newTime)
{
    STANDARD_CONSTRUCTOR()

    distance = 1;
    time = 1;

    //Set checks to false
    bool okDistance = false;
    bool okTime = false;

    //Check and convert the distance to meters
    if (newDistance != nullptr)
    {
        LCreal finalDistance = Meters::convertStatic( *newDistance );
        okDistance = setMeters(finalDistance);
    }

    //Check and convert the time to seconds
    if (newTime != nullptr)
    {
        LCreal finaltime = Seconds::convertStatic( *newTime );
        okTime = setSeconds(finaltime);
    }

    //Check that both were set correctly - if not give error
    if ( !okTime || !okDistance )
    {
        //Give error if something was not set correctly:
        std::cerr << "Distance or Time not set correctly - new LinearVelocity Object bad." << std::endl;

    }

}
Пример #3
0
TimeStamp::TimeStamp(byte seconds, byte minutes, byte hours, byte dayOfWeek, byte day, byte month, byte year) {
  setSeconds(seconds);
  setMinutes(minutes);
  setHours(hours);
  setDayOfWeek(dayOfWeek);
  setDay(day);
  setMonth(month);
  setYear(year);
}
Пример #4
0
void Time::setMilliseconds(float newMilliseconds)
{
    if (fabs(newMilliseconds) > 1)
    {
        int secondsInMS = truncf(newMilliseconds);
        setSeconds((unsigned int) secondsInMS);
        milliseconds = newMilliseconds - secondsInMS;
    }
    else milliseconds = newMilliseconds;
}
Пример #5
0
Timer::Timer( int hours, int minutes, int seconds, QObject *parent ) :
    QObject( parent )
{
    setSeconds( seconds );
    setMinutes( minutes );
    setHours( hours );

    time = new QTime( 0, 0, 0 );
    timer = new QTimer( this );
}
Пример #6
0
void RootOperationData::setAttr(const std::string& name, const Element& attr)
{
    if (name == SERIALNO_ATTR) { setSerialno(attr.asInt()); return; }
    if (name == REFNO_ATTR) { setRefno(attr.asInt()); return; }
    if (name == FROM_ATTR) { setFrom(attr.asString()); return; }
    if (name == TO_ATTR) { setTo(attr.asString()); return; }
    if (name == SECONDS_ATTR) { setSeconds(attr.asFloat()); return; }
    if (name == FUTURE_SECONDS_ATTR) { setFutureSeconds(attr.asFloat()); return; }
    if (name == ARGS_ATTR) { setArgsAsList(attr.asList()); return; }
    RootData::setAttr(name, attr);
}
Пример #7
0
//------------------------------------------------------------------------------
// setSlotTime() -- sets time based on input object and its value:
//------------------------------------------------------------------------------
bool AngularVelocity::setSlotTime(const Time* const msg)
{
    bool ok = false;

    //Try to convert Number to a time:
    if(msg != nullptr)
    {
        LCreal finalNumber = Seconds::convertStatic(*msg);
        ok = setSeconds(finalNumber);
    }
    return ok;
}
Пример #8
0
//------------------------------------------------------------------------------
// setRadiansPerSecond() -- sets our angularVelocity:
//------------------------------------------------------------------------------
bool AngularVelocity::setRadiansPerSecond(const LCreal newAngularVelocity)
{

    //Set angle and time - units in radians per second -> num = input; den = 1:
    bool ok1 = setRadians(newAngularVelocity);
    bool ok2 = setSeconds(1);

    //Check both values for ok:
    ok1 = (ok1)&&(ok2);

    return ok1;
}
Пример #9
0
//---------------------------------------------------------------------
// setMetersPerSecond()
//---------------------------------------------------------------------
bool LinearVelocity::setMetersPerSecond(const LCreal newLinearVelocity)
{

    //Set distance and time - units in meters per second -> num = input; den = 1
    bool ok1 = setMeters(newLinearVelocity);
    bool ok2 = setSeconds(1);

    //Check both values for ok:
    ok1 = (ok1)&&(ok2);

    return ok1;
}
Пример #10
0
void Date::adjustSeconds(
		   int aAmount
		   )
  throw( DateException )
{
  int addSeconds = getSecond() + aAmount;
  if( addSeconds > 86400 )
    {
      adjustDay( addSeconds / 86400 );
      addSeconds = addSeconds % 86400;
    }
  setSeconds( addSeconds );
} /* end Date::adjustSeconds() */
Пример #11
0
Message::Message()
{
    d = new MessageData;
    qRegisterMetaType<Message>("Message");
    setType( "" );
    setPayload( "" );
    setSenderID( 0 );
    setGroupID( 0 );
    setSeconds( 0 );
    setUseconds( 0 );
    setBridgeID( 0 );
    setHist( false );
    setName( "Unknown" );
    setSender( 0 );
}
Пример #12
0
Message::Message( QString type, QByteArray payload, quint64 senderID, quint64 groupID,
                    quint32 seconds, quint32 useconds, quint32 bridgeID, bool hist ,
                    QString name, Target* sender )
{
    d = new MessageData;
    qRegisterMetaType<Message>("Message");

    setType( type );
    setPayload( payload );
    setSenderID( senderID );
    setGroupID( groupID );
    setSeconds( seconds );
    setUseconds( useconds );
    setBridgeID( bridgeID );
    setHist( hist );
    setName( name );
    setSender( sender );
}
Пример #13
0
TimeCode::TimeCode
    (int hours,
     int minutes,
     int seconds,
     int frame,
     bool dropFrame,
     bool colorFrame,
     bool fieldPhase,
     bool bgf0,
     bool bgf1,
     bool bgf2,
     int binaryGroup1,
     int binaryGroup2,
     int binaryGroup3,
     int binaryGroup4,
     int binaryGroup5,
     int binaryGroup6,
     int binaryGroup7,
     int binaryGroup8)
{
    setHours (hours);
    setMinutes (minutes);
    setSeconds (seconds);
    setFrame (frame);
    setDropFrame (dropFrame);
    setColorFrame (colorFrame);
    setFieldPhase (fieldPhase);
    setBgf0 (bgf0);
    setBgf1 (bgf1);
    setBgf2 (bgf2);
    setBinaryGroup (1, binaryGroup1);
    setBinaryGroup (2, binaryGroup2);
    setBinaryGroup (3, binaryGroup3);
    setBinaryGroup (4, binaryGroup4);
    setBinaryGroup (5, binaryGroup5);
    setBinaryGroup (6, binaryGroup6);
    setBinaryGroup (7, binaryGroup7);
    setBinaryGroup (8, binaryGroup8);
}
Пример #14
0
AngularVelocity::AngularVelocity(const Angle* const newAngle, const Time* const newTime)
{
    STANDARD_CONSTRUCTOR()

    //Set a default angle, time, and angularVelocity
    angle = 1;
    time = 1;
    val = 1;

    //Set Checks to false:
    bool okAngle = false;
    bool okTime = false;

    //Check and convert the angle to radians
    if (newAngle != nullptr)
    {
        LCreal finalAngle = static_cast<LCreal>(Radians::convertStatic(*newAngle));
        okAngle = setRadians(finalAngle);
    }

    //Check and convert the time to seconds
    if (newTime != nullptr)
    {
        LCreal finaltime = Seconds::convertStatic( *newTime );
        okTime = setSeconds(finaltime);
    }

    //Check that both were set correctly - if not give error:
    if ( !okTime || !okAngle )
    {
        //Give error if something was not set correctly:
        std::cerr << "Angle or Time not set correctly - new AngularVelocity Object bad." << std::endl;

    }

}
Пример #15
0
void Feed::setAll(const char* allch) {
	if (strlen(allch) <= 0) {
		allch = "";
	}
	String all = allch;
	int indexof = all.find(",");
	if (indexof > -1) {
		setUsername(all.substr(0,indexof++).c_str());
		all=all.substr(indexof);
		indexof = all.find(",");
		setEncrypt(all.substr(0,indexof++).c_str());
		all=all.substr(indexof);
		indexof = all.find(",");
		setUnsuccessful(all.substr(0,indexof++).c_str());
		all=all.substr(indexof);
		indexof = all.find(",");
		setReplaceWhiteSpaces(all.substr(0,indexof++).c_str());
		all=all.substr(indexof);
		indexof = all.find(",");
		setReplaceSpecialCharacters(all.substr(0,indexof++).c_str());
		all=all.substr(indexof);
		indexof = all.find(",");
		setCredits(all.substr(0,indexof++).c_str());
		all=all.substr(indexof);
		indexof = all.find(",");
		setEmail(all.substr(0,indexof++).c_str());
		all=all.substr(indexof);
		indexof = all.find(",");
		setHandle(all.substr(0,indexof++).c_str());
		all=all.substr(indexof);
		indexof = all.find(",");
		setTouch(all.substr(0,indexof++).c_str());
		all=all.substr(indexof);
		indexof = all.find(",");
		setSeconds(all.substr(0,indexof++).c_str());
		all=all.substr(indexof);
		indexof = all.find(",");
		setRegistered(all.substr(0,indexof++).c_str());
		all=all.substr(indexof);
		indexof = all.find(",");
		setNoteSeconds(all.substr(0,indexof++).c_str());
		all=all.substr(indexof);
		setLoaded(true);
		if ((getUsername().length() <= 0)||(getEncrypt().length() <= 0)) {
			setUsername("");
			setEncrypt("");
			setLoaded(false);
		}
	} else {
		setLoaded(false);
		setUsername("");
		setEncrypt("");
		setUnsuccessful("");
		setReplaceWhiteSpaces("");
		setReplaceSpecialCharacters("");
		setCredits("");
		setEmail("");
		setHandle("");
		setTouch("false");
		setRegistered("0");
		setNoteLoaded(false);
		setNoteSeconds("");
	}
}