void GOrgueSoundingPipe::Change(unsigned velocity, unsigned last_velocity) { if (!m_Instances && velocity) SetOn(velocity); else if (m_Instances && !velocity) SetOff(); else if (m_Sampler && last_velocity != velocity) m_organfile->UpdateVelocity(m_Sampler, velocity); }
void Rotating::UpdateSpinDown() { CServerDE* pServerDE = BaseClass::GetServerDE(); if (!pServerDE) return; DBOOL bXDone = DFALSE, bYDone = DFALSE, bZDone = DFALSE; DFLOAT fDeltaTime = pServerDE->GetFrameTime(); // Calculate current velocity... m_vSpinTimeLeft.x -= fDeltaTime; if (m_vSaveVelocity.x > 0.0f && m_vSpinTimeLeft.x >= 0.0f) { m_vVelocity.x = m_vSaveVelocity.x - (m_vSaveVelocity.x * (m_vSpinDownTime.x - m_vSpinTimeLeft.x) / m_vSpinDownTime.x); } else { m_vVelocity.x = 0.0f; bXDone = DTRUE; } m_vSpinTimeLeft.y -= fDeltaTime; if (m_vSaveVelocity.y > 0.0f && m_vSpinTimeLeft.y >= 0.0f) { m_vVelocity.y = m_vSaveVelocity.y - (m_vSaveVelocity.y * (m_vSpinDownTime.y - m_vSpinTimeLeft.y) / m_vSpinDownTime.y); } else { m_vVelocity.y = 0.0f; bYDone = DTRUE; } m_vSpinTimeLeft.z -= fDeltaTime; if (m_vSaveVelocity.z > 0.0f && m_vSpinTimeLeft.z >= 0.0f) { m_vVelocity.z = m_vSaveVelocity.z - (m_vSaveVelocity.z * (m_vSpinDownTime.z - m_vSpinTimeLeft.z) / m_vSpinDownTime.z); } else { m_vVelocity.z = 0.0f; bZDone = DTRUE; } // Call normal update to do the work... UpdateNormalRotation(); if (bXDone && bYDone && bZDone) { SetOff(); } }
void RotatingWorldModel::UpdateSpinDown() { LTBOOL bXDone = LTFALSE, bYDone = LTFALSE, bZDone = LTFALSE; LTFLOAT fDeltaTime = g_pLTServer->GetFrameTime(); // Calculate current velocity... m_vSpinTimeLeft.x -= fDeltaTime; if (m_vSaveVelocity.x > 0.0f && m_vSpinTimeLeft.x >= 0.0f) { m_vVelocity.x = m_vSaveVelocity.x - (m_vSaveVelocity.x * (m_vSpinDownTime.x - m_vSpinTimeLeft.x) / m_vSpinDownTime.x); } else { m_vVelocity.x = 0.0f; bXDone = LTTRUE; } m_vSpinTimeLeft.y -= fDeltaTime; if (m_vSaveVelocity.y > 0.0f && m_vSpinTimeLeft.y >= 0.0f) { m_vVelocity.y = m_vSaveVelocity.y - (m_vSaveVelocity.y * (m_vSpinDownTime.y - m_vSpinTimeLeft.y) / m_vSpinDownTime.y); } else { m_vVelocity.y = 0.0f; bYDone = LTTRUE; } m_vSpinTimeLeft.z -= fDeltaTime; if (m_vSaveVelocity.z > 0.0f && m_vSpinTimeLeft.z >= 0.0f) { m_vVelocity.z = m_vSaveVelocity.z - (m_vSaveVelocity.z * (m_vSpinDownTime.z - m_vSpinTimeLeft.z) / m_vSpinDownTime.z); } else { m_vVelocity.z = 0.0f; bZDone = LTTRUE; } // Call normal update to do the work... UpdateNormalRotation(); if (bXDone && bYDone && bZDone) { SetOff(); } }
void SpinningWorldModel::UpdatePowerOff( const LTFLOAT &fCurTime ) { LTBOOL bDoneInX = LTFALSE; LTBOOL bDoneInY = LTFALSE; LTBOOL bDoneInZ = LTFALSE; LTFLOAT fPercent; LTFLOAT fRate; LTFLOAT fFrameTm = g_pLTServer->GetFrameTime(); fPercent = (fCurTime - m_fMoveStartTm) / m_fPowerOffTime; if( fPercent > 1.0f ) { bDoneInX = LTTRUE; bDoneInY = LTTRUE; bDoneInZ = LTTRUE; m_vVelocity = LTVector( 0.0f, 0.0f, 0.0f ); } if( m_bUpdateSpin ) { // Update Pitch PowerDOWN... if( m_vFinalVelocity.x ) { fRate = m_vFinalVelocity.x / m_fPowerOffTime; m_vVelocity.x -= GetWaveformValue( fRate, fPercent ) * fFrameTm * m_vRotateDir.x ; if( m_vVelocity.x < MATH_EPSILON ) { m_vVelocity.x = 0.0f; bDoneInX = LTTRUE; } } else { bDoneInX = LTTRUE; } // Update Yaw PowerDOWN... if( m_vFinalVelocity.y ) { fRate = m_vFinalVelocity.y / m_fPowerOffTime; m_vVelocity.y -= GetWaveformValue( fRate, fPercent ) * fFrameTm * m_vRotateDir.y; if( m_vVelocity.y < MATH_EPSILON ) { m_vVelocity.y = 0.0f; bDoneInY = LTTRUE; } } else { bDoneInY = LTTRUE; } // Update Roll PowerDOWN... if( m_vFinalVelocity.z ) { fRate = m_vFinalVelocity.z / m_fPowerOffTime; m_vVelocity.z -= GetWaveformValue( fRate, fPercent ) * fFrameTm * m_vRotateDir.z; if( m_vVelocity.z < MATH_EPSILON ) { m_vVelocity.z = 0.0f; bDoneInZ = LTTRUE; } } else { bDoneInZ = LTTRUE; } } // Let the "on" update do the actual rotating UpdateOn( fCurTime ); if( bDoneInX && bDoneInY && bDoneInZ ) { SetOff(); } }
void SpinningWorldModel::UpdatePowerOff( const double &fCurTime ) { bool bDoneInX = false; bool bDoneInY = false; bool bDoneInZ = false; float fPercent; float fRate; float fFrameTm = g_pLTServer->GetFrameTime(); fPercent = ((float)(fCurTime - m_fMoveStartTm)) / m_fPowerOffTime; if( fPercent > 1.0f ) { bDoneInX = true; bDoneInY = true; bDoneInZ = true; m_vVelocity = LTVector( 0.0f, 0.0f, 0.0f ); } if( m_bUpdateSpin ) { // Update Pitch PowerDOWN... if( m_vFinalVelocity.x ) { fRate = m_vFinalVelocity.x / m_fPowerOffTime; m_vVelocity.x -= GetWaveformValue( fRate, fPercent ) * fFrameTm * m_vInitRotDir.x ; if( m_vVelocity.x < MATH_EPSILON ) { m_vVelocity.x = 0.0f; bDoneInX = true; } } else { bDoneInX = true; } // Update Yaw PowerDOWN... if( m_vFinalVelocity.y ) { fRate = m_vFinalVelocity.y / m_fPowerOffTime; m_vVelocity.y -= GetWaveformValue( fRate, fPercent ) * fFrameTm * m_vInitRotDir.y; if( m_vVelocity.y < MATH_EPSILON ) { m_vVelocity.y = 0.0f; bDoneInY = true; } } else { bDoneInY = true; } // Update Roll PowerDOWN... if( m_vFinalVelocity.z ) { fRate = m_vFinalVelocity.z / m_fPowerOffTime; m_vVelocity.z -= GetWaveformValue( fRate, fPercent ) * fFrameTm * m_vInitRotDir.z; if( m_vVelocity.z < MATH_EPSILON ) { m_vVelocity.z = 0.0f; bDoneInZ = true; } } else { bDoneInZ = true; } } // Let the "on" update do the actual rotating UpdateOn( fCurTime ); if( bDoneInX && bDoneInY && bDoneInZ ) { SetOff( !AWM_INITIAL_STATE ); } }
void DigitalOutput::SetOff(unsigned long timeInMs) { SetOff(); delay(timeInMs); }
void UpdateDataSector(BYTE n) { BYTE in; if(n>3) return; if(digit(Ndd.PowerOld,n) == 1) // рабочий режим { SetOn(n); switch (Ndd.St1[n]) { case 1: //читаем все { SetRegim(n, REGIM_WORK); if(Ndd.Timer2[n]>10) { GetDataInput(n); Ndd.Timer2[n] = 0; Ndd.Read[n][Ndd.CurStep[n]]=~GetDataBunk(n); Ndd.St1[n]=2; } } break; case 2: // провереям можно ли в данный момент провести тест 0 { if(ReqwestTest0(n) == 1) { Ndd.St1[n]=3; Ndd.Timer2[n] = 0; } }break; case 3: //читаем тест 0 { Ndd.Test0_Last = n; // мы в последними выполнили тест 0 SetRegim(n, REGIM_TEST_0); if(Ndd.Timer2[n]>10) { Ndd.Timer2[n] = 0; Ndd.TestR[n][Ndd.CurStep[n]]=GetDataBunk(n); Ndd.CurStep[n]++; if(Ndd.CurStep[n]>2) { Ndd.CurStep[n]=0; AnalizeTestData(n); } Ndd.St1[n]=1; SetRegim(n, REGIM_WORK); Ndd.Test0_Run[n] =0; } } break; default: Ndd.St1[n] = 1; } }else // тестовый режим { SetOff(n); switch (Ndd.St1[n]) { case 1: // ждем когда можно будет провести тест 0 { if(Ndd.Timer2[n]>StartTimeOut) { StartTimeOut = 10; Ndd.Timer2[n] = 11; }else break; if(ReqwestTest0(n) == 1) { Ndd.St1[n]=2; Ndd.Timer2[n] = 0; } }break; case 2: // тест 0 { SetRegim(n, REGIM_TEST_0); // test 0 if(Ndd.Timer2[n]>StartTimeOut) { StartTimeOut=10; //============================ //in = GetDataBunk(n); //if(n<2) tmp = Ndd.test[0] & MASK_FF[n]; //else tmp = Ndd.test[1] & MASK_FF[n]; Ndd.Test_Bunk[n] = GetDataBunk(n); //if(n<2) Ndd.tmp_test[0] = tmp; //else Ndd.tmp_test[1] = tmp; //============================ Ndd.Timer2[n] = 0; Ndd.St1[n] = 3; SetRegim(n, REGIM_TEST_1); // test 1 Ndd.Test0_Run[n] =0; } } break; case 3: { SetRegim(n, REGIM_TEST_1); // test 1 if(Ndd.Timer2[n]>10) { //============================== in = GetDataBunk(n); //if(n<2) tmp = Ndd.tmp_test[0] & MASK_FF[n]; //else tmp = Ndd.tmp_test[1] & MASK_FF[n]; //if(n<2) tmp = Ndd.tmp_test[0]; //else tmp = Ndd.tmp_test[1]; Ndd.Test_Bunk[n] |= ((~in) & MASK_FF_INV[n]); if(n<2) Ndd.test[0] = (Ndd.test[0]&MASK_FF[n]) | Ndd.Test_Bunk[n]; else Ndd.test[1] = (Ndd.test[1]&MASK_FF[n]) | Ndd.Test_Bunk[n]; //============================== Ndd.Timer2[n] = 0; Ndd.St1[n] = 4; } } break; //------------------------------------------------------- case 4: { SetRegim(n, REGIM_WORK); if(Ndd.Timer2[n]>5000/*60000*/) { Ndd.Timer2[n] = 0; Ndd.St1[n] = 1; } } break; default: Ndd.St1[n] = 1; } } }