示例#1
0
文件: trigger.cpp 项目: zaleilynn/co
bool IdleTrigger::Condition(FrameworkInMachine* fim) {
    bool ret = fim->IsIdle(static_cast<int>(GetPeriod()*60), GetValue(), 1.00, m_id);
    SetTriggerState(ret);
    return ret;
#if 0
    // executor stat is to this trigger
    if (m_id == stat.task_id) {
        // let task num be the quota
        // first in
        if (stat.task_num <= GetValue() && !m_is_ignited) {
            m_start_time = time(0);
            m_is_ignited = true;
            LOG(WARNING) << "Idle Trigger starts to work";
            return false;
        }
        // bomb! trigger is triggered
        if (stat.task_num <= GetValue() && m_is_ignited &&
                (time(0) - m_start_time) >= GetPeriod() * 60) {
            LOG(WARNING) << "Idle Trigger is triggered, begin to shut down the executor: "
                << "framework " << stat.fr_name << " id " << stat.task_id;
            // reset the flag
            m_is_ignited = false;
            return true;
        }
        if (stat.task_num > GetValue() && m_is_ignited)
            m_is_ignited = false;
        return false;
    }
    return false;
#endif
}
void FGameplayEffectSpec::PrintAll() const
{
	ABILITY_LOG(Log, TEXT("Def: %s"), *Def->GetName());
	ABILITY_LOG(Log, TEXT("Duration: %.2f"), GetDuration());
	ABILITY_LOG(Log, TEXT("Period: %.2f"), GetPeriod());
	ABILITY_LOG(Log, TEXT("Modifiers:"));
}
示例#3
0
void WeekView::OnNext()
{
	m_weekNumber++;
	if (m_weekNumber >= GetPeriod().m_dateRange.GetNumberOfWeeks())
		m_weekNumber--;
	Invalidate();
}
示例#4
0
TimeInfo Draw::GetTimeInfo() const {
	TimeInfo t;
	t.begin_time = GetStartTime();
	t.end_time = GetLastTime();
	t.period =  GetPeriod();

	return t;
}
示例#5
0
void Transport::Stop()
{
    DETAIL_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES, "Transport::StartMovement %s (%s) stop moves, period %u/%u",
        GetObjectGuid().GetString().c_str(),
        GetName(),
        m_pathTime,
        GetPeriod()
        );
    SetActiveObjectState(false);
    BuildStopMovePacket(GetMap());
}
int CGXDLMSDemandRegister::GetValue(int index, int selector, CGXDLMSVariant& parameters, CGXDLMSVariant& value)
{    
    if (index == 1)
    {
        GXHelpers::AddRange(value.byteArr, m_LN, 6);
		value.vt = DLMS_DATA_TYPE_OCTET_STRING;
		return ERROR_CODES_OK;
    }
    if (index == 2)
    {
        value = GetCurrentAvarageValue();
		return ERROR_CODES_OK;
    }
    if (index == 3)
    {
        value = GetLastAvarageValue();
		return ERROR_CODES_OK;
    }      
    if (index == 4)
    {
        value.Clear();
		value.vt = DLMS_DATA_TYPE_STRUCTURE;
		value.Arr.push_back(m_Scaler);
		value.Arr.push_back(m_Unit);
		return ERROR_CODES_OK;
    }
    if (index == 5)
    {
        value = GetStatus();
		return ERROR_CODES_OK;
    }
    if (index == 6)
    {
        value = GetCaptureTime();
		return ERROR_CODES_OK;
    }
    if (index == 7)
    {
        value = GetStartTimeCurrent();
		return ERROR_CODES_OK;
    }
    if (index == 8)
    {
        value = GetPeriod();
		return ERROR_CODES_OK;
    } 
    if (index == 9)
    {
        value = GetNumberOfPeriods();
		return ERROR_CODES_OK;
    }         
    return ERROR_CODES_INVALID_PARAMETER;
}
示例#7
0
void MOTransport::Stop()
{
    DETAIL_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES, "Transport::StartMovement %s (%s) stop moves, period %u/%u",
        GetObjectGuid().GetString().c_str(),
        GetName(),
        m_pathTime,
        GetPeriod()
        );
    SetActiveObjectState(false);
    RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
    SetGoState(GO_STATE_READY);
    SetLootState(GO_JUST_DEACTIVATED);
}
示例#8
0
bool MOTransport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint8 animprogress, uint16 dynamicLowValue)
{
    Relocate(WorldLocation(mapid, x, y, z, ang));
    // FIXME - instance id and phaseMask isn't set to values different from std.

    if(!IsPositionValid())
    {
        sLog.outError("Transport (GUID: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",
            guidlow,x,y);
        return false;
    }

    Object::_Create(ObjectGuid(HIGHGUID_MO_TRANSPORT, guidlow));

    GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(guidlow);

    if (!goinfo)
    {
        sLog.outErrorDb("Transport not created: entry in `gameobject_template` not found, guidlow: %u map: %u  (X: %f Y: %f Z: %f) ang: %f",guidlow, mapid, x, y, z, ang);
        return false;
    }

    m_goInfo = goinfo;

    SetObjectScale(goinfo->size);

    SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction);
    //SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags);
    SetUInt32Value(GAMEOBJECT_FLAGS, (GO_FLAG_TRANSPORT | GO_FLAG_NODESPAWN));
    SetUInt32Value(GAMEOBJECT_LEVEL, GetPeriod(true));
    SetEntry(goinfo->id);

    SetDisplayId(goinfo->displayId);

    SetGoState(GO_STATE_READY);
    SetGoType(GameobjectTypes(goinfo->type));
    SetGoArtKit(0);
    SetGoAnimProgress(animprogress);

    SetUInt16Value(GAMEOBJECT_DYNAMIC, 0, dynamicLowValue);
    SetUInt16Value(GAMEOBJECT_DYNAMIC, 1, 0);

    SetName(goinfo->name);

    m_transportKit = new TransportKit(*this);

    m_anchorageTimer.SetInterval(0);
    m_anchorageTimer.Reset();

    return true;
}
示例#9
0
void MOTransport::Update(uint32 update_diff, uint32 p_time)
{
    UpdateSplineMovement(p_time);

    if (!movespline->Finalized())
        return;

    if (m_WayPoints.size() <= 1)
        return;

    bool anchorage = !m_anchorageTimer.Passed();
    if (anchorage)
        m_anchorageTimer.Update(update_diff);

    m_timer = WorldTimer::getMSTime() % GetPeriod(true);
    while (((m_timer - m_curr->first) % m_pathTime) > ((m_next->first - m_curr->first) % m_pathTime))
    {

        DoEventIfAny(*m_curr,true);
        MoveToNextWayPoint();

        // delay detect
        if (m_next->second.delay > 0)
        {
            m_anchorageTimer.SetInterval(m_next->first - m_next->second.delay);
            m_anchorageTimer.Reset();
        }
        DoEventIfAny(*m_curr,false);

        if (!SetPosition(m_curr->second.loc, m_curr->second.teleport))
        {
            if (m_curr->second.loc.GetMapId() == m_next->second.loc.GetMapId() &&
                !m_curr->second.teleport &&
                m_anchorageTimer.Passed() &&
                !(m_curr->second.loc == m_next->second.loc))
            {
                // FIXME - use MovementGenerator instead this
                DEBUG_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES,"Transport::Update %s start spline movement to %f %f %f",GetObjectGuid().GetString().c_str(), m_next->second.loc.x, m_next->second.loc.y, m_next->second.loc.z);
                Movement::MoveSplineInit<GameObject*> init(*this);
                init.MoveTo((Vector3)m_next->second.loc);
                init.SetVelocity(GetGOInfo()->moTransport.moveSpeed);
                init.Launch();
            }
        }
        m_nextNodeTime = m_curr->first;

        DEBUG_FILTER_LOG(LOG_FILTER_TRANSPORT_MOVES, "Transport::Update %s moved to %f %f %f %d %s, next keyframe %u", GetObjectGuid().GetString().c_str(), m_curr->second.loc.x, m_curr->second.loc.y, m_curr->second.loc.z, m_curr->second.loc.GetMapId(), m_curr == m_WayPoints.begin() ? "begin move" : "", m_nextNodeTime);
    }
}
示例#10
0
void WeekView::OnDraw(CDC * pDC)
{
	CFont courier;
	VERIFY(courier.CreatePointFont(120,_T("Courier New")));
	CFont * oldFont = pDC->SelectObject(&courier);
	
	CFont * newFont = pDC->SelectObject(oldFont);

	
	Draw(GetPeriod(),m_weekNumber,pDC);
	


	ASSERT(newFont == &courier);
}
示例#11
0
文件: trigger.cpp 项目: zaleilynn/co
bool CpuTrigger::Condition(FrameworkInMachine* fim) {
    if (!IsTriggered()) {
        // calculate all the executor cpu usage in past m_period_threshold time
        if (fim->IsOverLoad(static_cast<int>(GetPeriod()*60),
                            static_cast<double>(GetValue())/100,
                            m_proportion)) {
            LOG(WARNING) << "cpu trigger triggered";
            SetTriggerState(true);
            m_trigger_time = time(0);
            return true;
        } else {
            return false;
        }
    } else {
        // if triggered then hold on 30s
        if (time(0) - m_trigger_time > 30 && fim->Size() < Pool::Instance()->Size())
            SetTriggerState(false);
        return false;
    }
}
示例#12
0
/**
 * Get the current rate of the encoder.
 * Units are distance per second as scaled by the value from SetDistancePerPulse().
 * 
 * @return The current rate of the encoder.
 */
double Encoder::GetRate()
{
	return (m_distancePerPulse / GetPeriod());
}
示例#13
0
int DTime::GetDistance(const DTime &t) const {
	assert(IsValid());
	assert(t.IsValid());

	if (GetPeriod() != t.GetPeriod()) {
		wxLogError(_T("our period: %d, his period: %d"), GetPeriod(), t.GetPeriod());
		assert(false);
	}

	const wxDateTime& _t0 = GetTime();
	const wxDateTime& _t = t.GetTime();

	int ret = -1;

	switch (GetPeriod()) {
		case PERIOD_T_DECADE:
			ret = _t.GetYear() - _t0.GetYear();
			break;
		case PERIOD_T_YEAR:
			ret = _t.GetYear() * 12 + _t.GetMonth()
				- _t0.GetYear() * 12 - _t0.GetMonth();
			break;
		case PERIOD_T_MONTH: 
			ret = (_t - _t0).GetHours();
			//acount for daylight saving time
			switch (ret % 24) {
				case 1:
					ret -= 1;
					break;
				case 23:
					ret += 1;
					break;
				case -1:
					ret += 1;
					break;
				case -23:
					ret -= 1;
					break;
			}
			ret /= 24;
			break;
		case PERIOD_T_DAY:
			ret = (_t - _t0).GetMinutes() / 10;
			break;
		case PERIOD_T_30MINUTE:
			ret = ((_t - _t0).GetSeconds() / 10).ToLong();
			break;
		case PERIOD_T_5MINUTE:
			ret = ((_t - _t0).GetSeconds()).ToLong();
			break;
		case PERIOD_T_MINUTE:
			ret = ((_t - _t0).GetMilliseconds() / 500).ToLong();
			break;
		case PERIOD_T_30SEC:
			ret = ((_t - _t0).GetMilliseconds() / 100).ToLong();
			break;
		case PERIOD_T_WEEK:
			ret = (_t - _t0).GetHours() / 8;
			if (_t0.IsDST() != _t.IsDST()) {
				if (_t0 < _t && _t.IsDST())
					ret += 1;
				else if (_t < _t0 && _t0.IsDST())
					ret -= 1;
			}
			break;
		case PERIOD_T_SEASON: 
			ret = (_t - _t0).GetDays() / 7;
			if (_t0.IsDST() != _t.IsDST()) {
				if (_t0 < _t && _t.IsDST())
					ret += 1;
				else if (_t < _t0 && _t0.IsDST())
					ret -= 1;
			}
			break;
		default:
			assert(false);
	}

	return ret;
}
示例#14
0
void Transport::Update(uint32 diff)
{
    uint32 const positionUpdateDelay = 200;

    if (AI())
        AI()->UpdateAI(diff);
    else if (!AIM_Initialize())
        TC_LOG_ERROR("entities.transport", "Could not initialize GameObjectAI for Transport");

    if (GetKeyFrames().size() <= 1)
        return;

    if (IsMoving() || !_pendingStop)
        m_goValue.Transport.PathProgress += diff;

    uint32 timer = m_goValue.Transport.PathProgress % GetPeriod();

    // Set current waypoint
    // Desired outcome: _currentFrame->DepartureTime < timer < _nextFrame->ArriveTime
    // ... arrive | ... delay ... | departure
    //      event /         event /
    for (;;)
    {
        if (timer >= _currentFrame->ArriveTime)
        {
            if (!_triggeredArrivalEvent)
            {
                DoEventIfAny(*_currentFrame, false);
                _triggeredArrivalEvent = true;
            }

            if (timer < _currentFrame->DepartureTime)
            {
                SetMoving(false);
                if (_pendingStop && GetGoState() != GO_STATE_READY)
                {
                    SetGoState(GO_STATE_READY);
                    m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetPeriod());
                    m_goValue.Transport.PathProgress *= GetPeriod();
                    m_goValue.Transport.PathProgress += _currentFrame->ArriveTime;
                }
                break;  // its a stop frame and we are waiting
            }
        }

        if (timer >= _currentFrame->DepartureTime && !_triggeredDepartureEvent)
        {
            DoEventIfAny(*_currentFrame, true); // departure event
            _triggeredDepartureEvent = true;
        }

        // not waiting anymore
        SetMoving(true);

        // Enable movement
        if (GetGOInfo()->moTransport.canBeStopped)
            SetGoState(GO_STATE_ACTIVE);

        if (timer >= _currentFrame->DepartureTime && timer < _currentFrame->NextArriveTime)
            break;  // found current waypoint

        MoveToNextWaypoint();

        sScriptMgr->OnRelocate(this, _currentFrame->Node->index, _currentFrame->Node->mapid, _currentFrame->Node->x, _currentFrame->Node->y, _currentFrame->Node->z);

        TC_LOG_DEBUG("entities.transport", "Transport %u (%s) moved to node %u %u %f %f %f", GetEntry(), GetName().c_str(), _currentFrame->Node->index, _currentFrame->Node->mapid, _currentFrame->Node->x, _currentFrame->Node->y, _currentFrame->Node->z);

        // Departure event
        if (_currentFrame->IsTeleportFrame())
            if (TeleportTransport(_nextFrame->Node->mapid, _nextFrame->Node->x, _nextFrame->Node->y, _nextFrame->Node->z, _nextFrame->InitialOrientation))
                return; // Update more in new map thread
    }

    // Set position
    _positionChangeTimer.Update(diff);
    if (_positionChangeTimer.Passed())
    {
        _positionChangeTimer.Reset(positionUpdateDelay);
        if (IsMoving())
        {
            float t = CalculateSegmentPos(float(timer) * 0.001f);
            G3D::Vector3 pos, dir;
            _currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);
            _currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
            UpdatePosition(pos.x, pos.y, pos.z, atan2(dir.y, dir.x) + M_PI);
        }
        else
        {
            /* There are four possible scenarios that trigger loading/unloading passengers:
              1. transport moves from inactive to active grid
              2. the grid that transport is currently in becomes active
              3. transport moves from active to inactive grid
              4. the grid that transport is currently in unloads
            */
            if (_staticPassengers.empty() && GetMap()->IsGridLoaded(GetPositionX(), GetPositionY())) // 2.
                LoadStaticPassengers();
        }
    }

    sScriptMgr->OnTransportUpdate(this, diff);
}
/**
 * Get the current rate of the encoder.
 * Units are distance per second as scaled by the value from SetDistancePerPulse().
 * 
 * @return The current rate of the encoder.
 */
double Encoder::GetRate()
{
	return m_distancePerPulse / GetPeriod() * (GetDirection() ? 1.0 : -1.0);
}
示例#16
0
double GearToothEncoder::GetRate() {
	return 1 / GetPeriod();
}
示例#17
0
void Transport::Update(uint32 diff)
{
    uint32 const positionUpdateDelay = 200;

    if (AI())
        AI()->UpdateAI(diff);
    else if (!AIM_Initialize())
        TC_LOG_ERROR("entities.transport", "Could not initialize GameObjectAI for Transport");

    if (GetKeyFrames().size() <= 1)
        return;

    m_goValue.Transport.PathProgress += diff;

    uint32 timer = m_goValue.Transport.PathProgress % GetPeriod();

    // Set current waypoint
    // Desired outcome: _currentFrame->DepartureTime < timer < _nextFrame->ArriveTime
    // ... arrive | ... delay ... | departure
    //      event /         event /
    for (;;)
    {
        if (timer >= _currentFrame->ArriveTime)
        {
            if (!_triggeredArrivalEvent)
            {
                DoEventIfAny(*_currentFrame, false);
                _triggeredArrivalEvent = true;
            }

            if (timer < _currentFrame->DepartureTime)
            {
                SetMoving(false);
                if (_pendingStop)
                    SetGoState(GO_STATE_READY);
                break;  // its a stop frame and we are waiting
            }
        }

        if (_pendingStop && timer >= _currentFrame->DepartureTime && GetGoState() == GO_STATE_READY)
        {
            m_goValue.Transport.PathProgress = (m_goValue.Transport.PathProgress / GetPeriod());
            m_goValue.Transport.PathProgress *= GetPeriod();
            m_goValue.Transport.PathProgress += _currentFrame->ArriveTime;
            break;
        }

        if (timer >= _currentFrame->DepartureTime && !_triggeredDepartureEvent)
        {
            DoEventIfAny(*_currentFrame, true); // departure event
            _triggeredDepartureEvent = true;
        }

        if (timer >= _currentFrame->DepartureTime && timer < _currentFrame->NextArriveTime)
            break;  // found current waypoint

        MoveToNextWaypoint();

        // not waiting anymore
        SetMoving(true);

        // Enable movement
        if (GetGOInfo()->moTransport.canBeStopped)
            SetGoState(GO_STATE_ACTIVE);

        sScriptMgr->OnRelocate(this, _currentFrame->Node->index, _currentFrame->Node->mapid, _currentFrame->Node->x, _currentFrame->Node->y, _currentFrame->Node->z);

        TC_LOG_DEBUG("entities.transport", "Transport %u (%s) moved to node %u %u %f %f %f", GetEntry(), GetName().c_str(), _currentFrame->Node->index, _currentFrame->Node->mapid, _currentFrame->Node->x, _currentFrame->Node->y, _currentFrame->Node->z);

        // Departure event
        if (_currentFrame->IsTeleportFrame())
            if (TeleportTransport(_nextFrame->Node->mapid, _nextFrame->Node->x, _nextFrame->Node->y, _nextFrame->Node->z))
                return; // Update more in new map thread
    }

	// Add model to map after we are fully done with moving maps
    if (_delayedAddModel)
    {
        _delayedAddModel = false;
        if (m_model)
            GetMap()->InsertGameObjectModel(*m_model);
    }

    // Set position
    _positionChangeTimer.Update(diff);
    if (_positionChangeTimer.Passed())
    {
        _positionChangeTimer.Reset(positionUpdateDelay);
        if (IsMoving())
        {
            float t = CalculateSegmentPos(float(timer) * 0.001f);
            G3D::Vector3 pos, dir;
            _currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);
            _currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
            UpdatePosition(pos.x, pos.y, pos.z, atan2(dir.x, dir.y));
        }
    }

    sScriptMgr->OnTransportUpdate(this, diff);
}
示例#18
0
/**
 * Get the current rate of the encoder.
 *
 * Units are distance per second as scaled by the value from
 * SetDistancePerPulse().
 *
 * @return The current rate of the encoder.
 */
double Encoder::GetRate() const {
  if (StatusIsFatal()) return 0.0;
  return (m_distancePerPulse / GetPeriod());
}
示例#19
0
void CProject::CalculateAmpVarPeriod(int freqpnt, int *freqdat, 
				     int what, CalcMode mode)
{
  UpdatePEData();
  // check if weights should be used
  if (!Period.GetUseWeight())
    {
      if (Timestring.GetSelectedPoints()!=Timestring.GetWeightSum())
	{
	  if (Confirm(DIALOG_PERIOD_USE_WEIGHTS)==1)
	    { Period.SetUseWeight(1); }
	}
    }

  // Set Frequencies for Amplitude Variations
  int i;
  for (i=0;i<freqpnt;i++)
    {
      Period[freqdat[i]].SetAmpVar(mode);
    }
  // what names should be used ?
  Period.SetUseID(what);

  // PROTOCOL

  // Write Calculation-header
  char tempprot[AMPVARMSGBUFFER];
  for (i=0;i<AMPVARMSGBUFFER;i++) { tempprot[i]=0; }
  char txt[1024];
  ostrstream pro(tempprot,AMPVARMSGBUFFER);
  pro<<PROTOCOL_AMPVAR_CALCULATE_HEADER<<endl;
  //WriteFrequenciesTabulated(pro,1);
  //sprintf(txt,PROTOCOL_ZEROPOINT,Period.GetZeropoint());
  //pro<<txt<<endl;
  if (Period.GetUseWeight())
    { pro<<PROTOCOL_PERIOD_USE_WEIGHTS<<endl; }
  pro<<PROTOCOL_AMPVAR_NAMES_SELECTED<<NameSet(what)<<endl;
  pro<<PROTOCOL_PERIOD_CALCULATION_STARTED<<Date()<<endl;
  pro<<char(0)<<flush;  
  Waiting(1,1);
  // Calculate
  switch (Period.Calc(Timestring))
    {
    case 0:
      {
	// Write Calculation-footer
	ostream &tmp=Write();
	tmp<<pro.str();
	tmp<<PROTOCOL_PERIOD_OUTPUT<<endl;
	// now write the protocol
	char txt1[AMPVARMSGBUFFER];
	for (i=0;i<AMPVARMSGBUFFER;i++) { txt1[i]=0; }
	ostrstream pro1(txt1,AMPVARMSGBUFFER);
	
	// general data..
	CTimeString &Timestring=GetTimeString();
	CPeriod const &Period=GetPeriod();
	
	int freqs=Period.GetFrequencies();
	
	// now fill in the data...
	for (int fre=0;fre<freqs;fre++)
	  {
	    int fr=fre;
	    if (Period[fr].GetActive())
	      {
		switch (Period[fr].GetAmpVariation())
		  {
		  case NoVar:
		    {
		      sprintf(txt,PROTOCOL_AMPVAR_NOVAR,
			      GetNumber(fr).chars(),
			      GetFrequency(fr).chars(),
			      Period[fr].GetAmplitude(-1),
			      Period[fr].GetPhase(-1)
			      );
		      // write out
		      pro1<<txt<<endl;
		      tmp<<txt<<endl;
		      break;
		    }
		  case AmpVar:
		    {
		      // first write out the header
		      sprintf(txt,PROTOCOL_AMPVAR_AMPVAR_HEAD,
			      GetNumber(fr).chars(),
			      GetFrequency(fr).chars(),
			      Period[fr].GetPhase(-1)
			      );
		      // write out
		      pro1<<txt<<endl;
		      tmp<<txt<<endl;
		      // now write out the relevant data
		      for (int na=0;na<Timestring.NumberOfNames(what);na++)
			{
			  int id=
			    Timestring.GetIndexName(what,na).GetID();
			  int points=
			    Timestring.GetIndexName(what,na).GetPoints();
			  myString name=
			    Timestring.GetIndexName(what,na).GetName();
			  if (points!=0)
			    {
			      sprintf(txt,PROTOCOL_AMPVAR_AMPVAR,
				      name.chars(),
				      Period[fr].GetAmplitude(id)
				      );
			      // write out
			      pro1<<txt<<endl;
			      tmp<<txt<<endl;
			    }
			}
		      break;  
		    }
		  case PhaseVar:
		    {
		      // first write out the header
		      sprintf(txt,PROTOCOL_AMPVAR_PHASEVAR_HEAD,
			      GetNumber(fr).chars(),
			      GetFrequency(fr).chars(),
			      Period[fr].GetAmplitude(-1)
			      );
		      // write out
		      pro1<<txt<<endl;
		      tmp<<txt<<endl;
		      // now write out the relevant data
		      for (int na=0;na<Timestring.NumberOfNames(what);na++)
			{
			  int id=
			    Timestring.GetIndexName(what,na).GetID();
			  int points=
			    Timestring.GetIndexName(what,na).GetPoints();
			  myString name=
			    Timestring.GetIndexName(what,na).GetName();
			  if (points!=0)
			    {
			      sprintf(txt,PROTOCOL_AMPVAR_PHASEVAR,
				      name.chars(),
				      Period[fr].GetPhase(id)
				      );
			      // write out
			      pro1<<txt<<endl;
			      tmp<<txt<<endl;
			    }
			}
		      break;  
		    }
		  case AllVar:
		    {
		      // first write out the header
		      sprintf(txt,PROTOCOL_AMPVAR_ALLVAR_HEAD,
			      GetNumber(fr).chars(),
			      GetFrequency(fr).chars()
			      );
		      // write out
		      pro1<<txt<<endl;
		      tmp<<txt<<endl;
		      // now write out the relevant data
		      for (int na=0;na<Timestring.NumberOfNames(what);na++)
			{
			  int id=
			    Timestring.GetIndexName(what,na).GetID();
			  int points=
			    Timestring.GetIndexName(what,na).GetPoints();
			  myString name=
			    Timestring.GetIndexName(what,na).GetName();
			  if (points!=0)
			    {
			      sprintf(txt,PROTOCOL_AMPVAR_ALLVAR,
				      name.chars(),
				      Period[fr].GetAmplitude(id),
				      Period[fr].GetPhase(id)
				      );
			      // write out
			      pro1<<txt<<endl;
			      tmp<<txt<<endl;
			    }
			}
		      break;  
		    }
		  }
	      }
	  }
	
	// now write the rest..
	sprintf(txt,PROTOCOL_PERIOD_RESULT,
		Period.GetZeropoint(),
		Period.GetResiduals(),
		Period.GetIterations());
	pro1<<txt<<flush;
	tmp<<txt<<flush;
	// Have we reached Maximum Number Iterations?
	if (Period.GetIterations()>=Period.MaxIterations())
	  {
	    InformUser(DIALOG_PERIOD_MAXIMUM_ITERATIONS);	  
	  }
	// now display the data...
	DisplayAmpVarData(pro1.str());
	break;
      }
    case 1:// Matrix cannot be inverted
      {
	InformUser(DIALOG_PERIOD_MATRIX_INVERSION);
	break;
      }
    case 2:// cancel pressed, may not be a stable solution
      {
	InformUser(DIALOG_PERIOD_CALCULATION_INTERRUPTED);
	break;
      }
    }
  
  Waiting(0);
  // Cleans Frequencies of Amplitude Variations
  for (i=0;i<freqpnt;i++)
    {
      Period[freqdat[i]].SetAmpVar(NoVar);
    }
  UpdatePEDisplays();
}