diff --git a/.gitignore b/.gitignore index 89dd61e..87cc0a3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ /.vs/SimulationCore2/FileContentIndex /.vs/SimulationCore2/v17 /.vs +/x64 +*.rar diff --git a/Equipments/Pumps.rar b/Equipments/Pumps.rar deleted file mode 100644 index a26a968..0000000 Binary files a/Equipments/Pumps.rar and /dev/null differ diff --git a/Equipments/Pumps/PumpsMain.f90 b/Equipments/Pumps/PumpsMain.f90 index 3c63fc9..c9be5fb 100644 --- a/Equipments/Pumps/PumpsMain.f90 +++ b/Equipments/Pumps/PumpsMain.f90 @@ -29,7 +29,7 @@ module PumpsMain end subroutine subroutine Pump1_Init - implicit none + Call Pump_StartUp end subroutine Pump1_Init subroutine Pump1_Step @@ -51,7 +51,6 @@ module PumpsMain integer,dimension(8) :: MP_START_TIME, MP_END_TIME INTEGER :: MP_SolDuration - Call Pump_StartUp loop1 : do diff --git a/Equipments/RotaryTable/RTable_OffMode.f90 b/Equipments/RotaryTable/RTable_OffMode.f90 index 8618e7e..f14cc46 100644 --- a/Equipments/RotaryTable/RTable_OffMode.f90 +++ b/Equipments/RotaryTable/RTable_OffMode.f90 @@ -13,7 +13,7 @@ subroutine RTable_OffMode !================================================================== ! Rate limit for off Mode - Do while (((RTable%N_old-0.0d0)/RTable%time_step)>386.0d0) + if (((RTable%N_old-0.0d0)/RTable%time_step)>386.0d0) then RTable%N_ref = (-386.0d0*RTable%time_step)+RTable%N_old !else ! RTable%N_ref=0.0d0 @@ -31,51 +31,41 @@ subroutine RTable_OffMode Call SetSoundRtGearCrash(RTable%SoundGearCrash) end if RT_OldTransMode = RTTransmissionLever - if (IsPortable) then - RTable%AssignmentSwitch = 1 - else - RTable%AssignmentSwitch = AssignmentSwitch - end if - if ((any(RTable%AssignmentSwitch==(/6,7,12/))) .or. (RTSwitch==0) .or. (IsStopped == .true.)) then - RTBLWR = 0 - end if - - Call sleepqq (80) !????????????????? - End Do + !================================================================== + else + RTable%N_ref = 0. + RTable%N_new = 0. + RTable%N_old = 0. - RTable%N_ref = 0. - RTable%N_new = 0. - RTable%N_old = 0. - - - RTable%ia = 0. - RTable%ia_old = 0. - RTable%ia_new = 0. - RTable%x = 0. - RTable%x_old = 0. - RTable%x_new = 0. - RTable%y = 0. - RTable%y_old = 0. - RTable%y_new = 0. - RTable%w = 0. - RTable%w_old = 0. - RTable%w_new = 0. - RTable%Speed = 0. - RT_wOld = 0. - Call Set_RotaryRPMGauge(sngl(1-RTable%RpmGaugeMalf)*real(RTable%Speed,8)) - RTable%SoundRPM = INT(RTable%Speed) - Call SetSoundRT( RTable%SoundRPM ) - !RotaryRPMGauge=RTable%Speed - !RPM=RotaryRPMGauge - RTable%Output_Current = 0. - RotaryTorqueGauge = ( ((RTable%J_coef+RTable%String_JCoef)*(((RTable%w_new/RTable%Conv_Ratio)-RT_wOld)/RTable%time_step))+(RTable%String_Torque) )*0.73756215 ![N.m]*0.73756215 = [ft.lbf] - RTable%Torque = ( ((RTable%J_coef+RTable%String_JCoef)*(((RTable%w_new/RTable%Conv_Ratio)-RT_wOld)/RTable%time_step))+(RTable%String_Torque) )*0.73756215 ![N.m]*0.73756215 = [ft.lbf] - Call Set_RotaryTorque(sngl(1-RTable%TorqueGaugeMalf)*real(RTable%Torque,8)) - !RotaryTorqueGauge=(RTable%String_Torque)/12. + RTable%ia = 0. + RTable%ia_old = 0. + RTable%ia_new = 0. + RTable%x = 0. + RTable%x_old = 0. + RTable%x_new = 0. + RTable%y = 0. + RTable%y_old = 0. + RTable%y_new = 0. + RTable%w = 0. + RTable%w_old = 0. + RTable%w_new = 0. + RTable%Speed = 0. + RT_wOld = 0. + Call Set_RotaryRPMGauge(sngl(1-RTable%RpmGaugeMalf)*real(RTable%Speed,8)) + RTable%SoundRPM = INT(RTable%Speed) + Call SetSoundRT( RTable%SoundRPM ) + !RotaryRPMGauge=RTable%Speed + !RPM=RotaryRPMGauge + RTable%Output_Current = 0. + RotaryTorqueGauge = ( ((RTable%J_coef+RTable%String_JCoef)*(((RTable%w_new/RTable%Conv_Ratio)-RT_wOld)/RTable%time_step))+(RTable%String_Torque) )*0.73756215 ![N.m]*0.73756215 = [ft.lbf] + RTable%Torque = ( ((RTable%J_coef+RTable%String_JCoef)*(((RTable%w_new/RTable%Conv_Ratio)-RT_wOld)/RTable%time_step))+(RTable%String_Torque) )*0.73756215 ![N.m]*0.73756215 = [ft.lbf] + Call Set_RotaryTorque(sngl(1-RTable%TorqueGaugeMalf)*real(RTable%Torque,8)) + !RotaryTorqueGauge=(RTable%String_Torque)/12. + end if end subroutine RTable_OffMode \ No newline at end of file diff --git a/Equipments/RotaryTable/RTable_StartUp.f90 b/Equipments/RotaryTable/RTable_StartUp.f90 index d25e788..7a02998 100644 --- a/Equipments/RotaryTable/RTable_StartUp.f90 +++ b/Equipments/RotaryTable/RTable_StartUp.f90 @@ -9,23 +9,24 @@ subroutine RTable_StartUp !RTable%=0. - RTable%Inertia_Moment = 23.261341 ! 23.261341 [kg.m^2] = 552 [lb.ft^2] - RTable%J_coef = RTable%Inertia_Moment+(1.*(RTable%Inertia_Moment)) ! [kg.m^2]??????????? - RTable%String_JCoef = 0. !??????????????? - RTable%Mech_Efficiency = 0.930 - RTable%ConstLoad = 2000. ![lb.in] - RTable%ConstLoad = 0.112984829*RTable%ConstLoad ![N.m] - RTable%Torque = 0.0 + RTable%Inertia_Moment = 23.261341e0 ! 23.261341 [kg.m^2] = 552 [lb.ft^2] + RTable%J_coef = RTable%Inertia_Moment+(1.e0*(RTable%Inertia_Moment)) ! [kg.m^2]??????????? + RTable%String_JCoef = 0.e0 !??????????????? + RTable%Mech_Efficiency = 0.93e0 + !RTable%ConstLoad = 2000.e0 ![lb.in] + !RTable%ConstLoad = 0.112984829e0*RTable%ConstLoad ![N.m] + RTable%Torque = 0.0e0 - RTable%High_Conv_Ratio = 4.8250 - RTable%Low_Conv_Ratio = 7.310 + RTable%High_Conv_Ratio = 4.825e0 + RTable%Low_Conv_Ratio = 7.31e0 RTable%Conv_Ratio = RTable%Low_Conv_Ratio - RTable%time_step = .10 + RTable%time_step = 0.1e0 - RTable%w = 0.0 - RTable%w_new = 0.0 + RTable%w = 0.e0 + RTable%w_new = 0.e0 + RTable%K_throttle = 0 diff --git a/Equipments/RotaryTable/RTable_VARIABLES.f90 b/Equipments/RotaryTable/RTable_VARIABLES.f90 index dfd507f..008b801 100644 --- a/Equipments/RotaryTable/RTable_VARIABLES.f90 +++ b/Equipments/RotaryTable/RTable_VARIABLES.f90 @@ -17,7 +17,7 @@ MODULE RTable_VARIABLES TYPE, PUBLIC :: RTable_Var !***** RTable_VARIABLES ************************* - INTEGER :: j , AssignmentSwitch + INTEGER :: j , AssignmentSwitch , K_throttle INTEGER :: MotorFaileMalf , OverideTorqueLimitMalf , RpmGaugeMalf , TorqueGaugeMalf , TorqueLimitGaugeMalf REAL :: Horsepower, Speed, Output_Current, Inertia_Moment, Mech_Efficiency, Torque diff --git a/Equipments/RotaryTable/RotaryTableMain.f90 b/Equipments/RotaryTable/RotaryTableMain.f90 index f83c8e2..f7b49c8 100644 --- a/Equipments/RotaryTable/RotaryTableMain.f90 +++ b/Equipments/RotaryTable/RotaryTableMain.f90 @@ -3,31 +3,30 @@ module RotaryTableMain public contains - ! subroutine RotaryTable_Setup() - ! use CSimulationVariables - ! implicit none - ! call OnSimulationInitialization%Add(RotaryTable_Init) - ! call OnSimulationStop%Add(RotaryTable_Init) - ! call OnRotaryTableStep%Add(RotaryTable_Step) - ! call OnRotaryTableOutput%Add(RotaryTable_Output) - ! call OnRotaryTableMain%Add(RotaryTableMainBody) - ! end subroutine + subroutine RotaryTable_Setup() + !use CSimulationVariables + !call OnSimulationInitialization%Add(RotaryTable_Init) + !call OnSimulationStop%Add(RotaryTable_Init) + !call OnRotaryTableStep%Add(RotaryTable_Step) + !call OnRotaryTableOutput%Add(RotaryTable_Output) + !call OnRotaryTableMain%Add(RotaryTableMainBody) + end subroutine subroutine RotaryTable_Init - implicit none + Call RTable_StartUp end subroutine RotaryTable_Init - subroutine RotaryTable_Step + subroutine RotaryTable_Step implicit none + Call Rtable_MainSolver end subroutine RotaryTable_Step - + subroutine RotaryTable_Output implicit none end subroutine RotaryTable_Output subroutine RotaryTableMainBody - use CDataDisplayConsoleVariables use CDrillingConsoleVariables use CSimulationVariables @@ -44,161 +43,27 @@ module RotaryTableMain Call RTable_StartUp loopRtablestart : do - - call sleepqq(10) - - if (IsPortable) then - RTable%AssignmentSwitch = 1 - else - RTable%AssignmentSwitch = AssignmentSwitch - end if - if ( (any(RTable%AssignmentSwitch==(/1,2,3,4,5,8,9,10,11/))) .and. (RTSwitch == -1) ) then - - RTable%SoundBlower = .true. - Call SetSoundBlowerRT(RTable%SoundBlower) - RTBLWR = 1 - - loopRtableswitch: do - - CALL DATE_AND_TIME(values=RT_START_TIME) - - IF ( RTTransmissionLever /=0 .and. RotaryGearsAbuse==0 ) THEN !be in clutch mode ?????? - RTable%N_new = RTThrottle - - !===> Rotary Table Malfunction ----> Drive Motor Failure - call RTMalfunction_MotorFailure - - if (((RTable%N_new-RTable%N_old)/RTable%time_step)>193.) then - RTable%N_ref = (193.*RTable%time_step)+RTable%N_old - else if (((RTable%N_old-RTable%N_new)/RTable%time_step)>193.) then - RTable%N_ref = (-193.*RTable%time_step)+RTable%N_old - else - RTable%N_ref = RTable%N_new - end if - CALL RTable_INPUTS - CALL RTable_Solver - RT_RPMUnityOutput = RotaryRPMGauge - RTable%N_old = RTable%N_ref - Else IF ( RTTransmissionLever==0) THEN !be in brake mode ?????? - Call RTable_OffMode - RT_RPMUnityOutput = RotaryRPMGauge - End IF - RT_OldTransMode = RTTransmissionLever - - CALL DATE_AND_TIME(values=RT_END_TIME) - RT_SolDuration = 100-(RT_END_TIME(5)*3600000+RT_END_TIME(6)*60000+RT_END_TIME(7)*1000+RT_END_TIME(8)-RT_START_TIME(5)*3600000-RT_START_TIME(6)*60000-RT_START_TIME(7)*1000-RT_START_TIME(8)) - !print*, 'RTtime=', RT_SolDuration - if(RT_SolDuration > 0.0) then - CALL sleepqq(RT_SolDuration) - end if - - if (IsPortable) then - RTable%AssignmentSwitch = 1 - else - RTable%AssignmentSwitch = AssignmentSwitch - end if - if ((any(RTable%AssignmentSwitch==(/6,7,12/))) .or. (RTSwitch/=-1) .or. (IsStopped == .true.)) then - RTable%SoundBlower = .false. - Call SetSoundBlowerRT(RTable%SoundBlower) - RTBLWR = 0 - Call RTable_OffMode - RT_RPMUnityOutput = RotaryRPMGauge - exit loopRtableswitch - end if - - end do loopRtableswitch - - - else if ( (any(RTable%AssignmentSwitch==(/1,2,3,4,5,8,9,10,11/))) .and. (RTSwitch == 1) .and. (RTThrottle==0.) ) then - - RTable%SoundBlower = .true. - Call SetSoundBlowerRT(RTable%SoundBlower) - RTBLWR = 1 - - loopRtableswitchREV: do - - CALL DATE_AND_TIME(values=RT_START_TIME) - - IF ( RTTransmissionLever /=0 .and. RotaryGearsAbuse==0 ) THEN !be in clutch mode ?????? - RTable%N_new = RTThrottle - - !===> Rotary Table Malfunction ----> Drive Motor Failure - call RTMalfunction_MotorFailure - - if (((RTable%N_new-RTable%N_old)/RTable%time_step)>193.) then - RTable%N_ref = (193.*RTable%time_step)+RTable%N_old - else if (((RTable%N_old-RTable%N_new)/RTable%time_step)>193.) then - RTable%N_ref = (-193.*RTable%time_step)+RTable%N_old - else - RTable%N_ref = RTable%N_new - end if - CALL RTable_INPUTS - CALL RTable_Solver - RT_RPMUnityOutput = -RotaryRPMGauge - RTable%N_old = RTable%N_ref - Else IF ( RTTransmissionLever==0) THEN !be in brake mode ?????? - Call RTable_OffMode - RT_RPMUnityOutput = -RotaryRPMGauge - End IF - RT_OldTransMode = RTTransmissionLever - - CALL DATE_AND_TIME(values=RT_END_TIME) - RT_SolDuration = 100-(RT_END_TIME(5)*3600000+RT_END_TIME(6)*60000+RT_END_TIME(7)*1000+RT_END_TIME(8)-RT_START_TIME(5)*3600000-RT_START_TIME(6)*60000-RT_START_TIME(7)*1000-RT_START_TIME(8)) - !print*, 'RTtime=', RT_SolDuration - if(RT_SolDuration > 0.0) then - CALL sleepqq(RT_SolDuration) - end if - - if (IsPortable) then - RTable%AssignmentSwitch = 1 - else - RTable%AssignmentSwitch = AssignmentSwitch - end if - if ((any(RTable%AssignmentSwitch==(/6,7,12/))) .or. (RTSwitch/=1) .or. (IsStopped == .true.)) then - RTable%SoundBlower = .false. - Call SetSoundBlowerRT(RTable%SoundBlower) - RTBLWR = 0 - Call RTable_OffMode - RT_RPMUnityOutput = -RotaryRPMGauge - exit loopRtableswitchREV - end if + CALL DATE_AND_TIME(values=RT_START_TIME) + + Call Rtable_MainSolver - end do loopRtableswitchREV - - - else - - - if (IsPortable) then - RTable%AssignmentSwitch = 1 - else - RTable%AssignmentSwitch = AssignmentSwitch + if (IsStopped == .true.) then + exit loopRtablestart end if - if((any(RTable%AssignmentSwitch==(/1,2,3,4,5,8,9,10,11/))) .and. (RTSwitch /= 0)) then - RTable%SoundBlower = .true. - Call SetSoundBlowerRT(RTable%SoundBlower) - RTBLWR = 1 - else - RTable%SoundBlower = .false. - Call SetSoundBlowerRT(RTable%SoundBlower) - RTBLWR = 0 + + CALL DATE_AND_TIME(values=RT_END_TIME) + RT_SolDuration = 100-(RT_END_TIME(5)*3600000+RT_END_TIME(6)*60000+RT_END_TIME(7)*1000+RT_END_TIME(8)-RT_START_TIME(5)*3600000-RT_START_TIME(6)*60000-RT_START_TIME(7)*1000-RT_START_TIME(8)) + if(RT_SolDuration > 0.0) then + CALL sleepqq(RT_SolDuration) end if - Call RTable_OffMode - RT_RPMUnityOutput = RotaryRPMGauge - !exit loopRtableswitch - RT_OldTransMode = RTTransmissionLever - - - end if - if (IsStopped == .true.) then - exit loopRtablestart - end if end do loopRtablestart end subroutine RotaryTableMainBody + + end module RotaryTableMain \ No newline at end of file diff --git a/Equipments/RotaryTable/Rtable_MainSolver.f90 b/Equipments/RotaryTable/Rtable_MainSolver.f90 new file mode 100644 index 0000000..523c4b7 --- /dev/null +++ b/Equipments/RotaryTable/Rtable_MainSolver.f90 @@ -0,0 +1,107 @@ +subroutine Rtable_MainSolver + + use CDataDisplayConsoleVariables + use CDrillingConsoleVariables + use CSimulationVariables + use RTable_VARIABLES + use CDrillWatchVariables + use CWarningsVariables + use CSounds + + IMPLICIT NONE + + + if (IsPortable) then + RTable%AssignmentSwitch = 1 + else + RTable%AssignmentSwitch = AssignmentSwitch + end if + + if (RTThrottle<=0.e0) then + RTable%K_throttle = 1 + end if + + if ( (any(RTable%AssignmentSwitch==(/1,2,3,4,5,8,9,10,11/))) .and. (RTSwitch == -1) .and. (IsStopped == .false.) ) then + + RTable%SoundBlower = .true. + Call SetSoundBlowerRT(RTable%SoundBlower) + RTBLWR = 1 + + + IF ( RTTransmissionLever /=0 .and. RotaryGearsAbuse==0 ) THEN !be in clutch mode ?????? + RTable%N_new = RTThrottle + + !===> Rotary Table Malfunction ----> Drive Motor Failure + call RTMalfunction_MotorFailure + + if (((RTable%N_new-RTable%N_old)/RTable%time_step)>193.) then + RTable%N_ref = (193.*RTable%time_step)+RTable%N_old + else if (((RTable%N_old-RTable%N_new)/RTable%time_step)>193.) then + RTable%N_ref = (-193.*RTable%time_step)+RTable%N_old + else + RTable%N_ref = RTable%N_new + end if + CALL RTable_INPUTS + CALL RTable_Solver + RT_RPMUnityOutput = RotaryRPMGauge + RTable%N_old = RTable%N_ref + Else IF ( RTTransmissionLever==0) THEN !be in brake mode ?????? + Call RTable_OffMode + RT_RPMUnityOutput = RotaryRPMGauge + End IF + RT_OldTransMode = RTTransmissionLever + + + else if ( (any(RTable%AssignmentSwitch==(/1,2,3,4,5,8,9,10,11/))) .and. (RTSwitch == 1) .and. (RTable%K_throttle==1) .and. (IsStopped == .false.) ) then + + RTable%SoundBlower = .true. + Call SetSoundBlowerRT(RTable%SoundBlower) + RTBLWR = 1 + + + IF ( RTTransmissionLever /=0 .and. RotaryGearsAbuse==0 ) THEN !be in clutch mode ?????? + RTable%N_new = RTThrottle + + !===> Rotary Table Malfunction ----> Drive Motor Failure + call RTMalfunction_MotorFailure + + if (((RTable%N_new-RTable%N_old)/RTable%time_step)>193.) then + RTable%N_ref = (193.*RTable%time_step)+RTable%N_old + else if (((RTable%N_old-RTable%N_new)/RTable%time_step)>193.) then + RTable%N_ref = (-193.*RTable%time_step)+RTable%N_old + else + RTable%N_ref = RTable%N_new + end if + CALL RTable_INPUTS + CALL RTable_Solver + RT_RPMUnityOutput = -RotaryRPMGauge + RTable%N_old = RTable%N_ref + Else IF ( RTTransmissionLever==0) THEN !be in brake mode ?????? + Call RTable_OffMode + RT_RPMUnityOutput = -RotaryRPMGauge + End IF + RT_OldTransMode = RTTransmissionLever + + + else + + + if((any(RTable%AssignmentSwitch==(/1,2,3,4,5,8,9,10,11/))) .and. (RTSwitch /= 0) .and. (IsStopped == .false.) ) then + RTable%SoundBlower = .true. + Call SetSoundBlowerRT(RTable%SoundBlower) + RTBLWR = 1 + else + RTable%SoundBlower = .false. + Call SetSoundBlowerRT(RTable%SoundBlower) + RTBLWR = 0 + end if + + Call RTable_OffMode + RT_RPMUnityOutput = RotaryRPMGauge + RT_OldTransMode = RTTransmissionLever + RTable%K_throttle = 0 + + + end if + +END subroutine Rtable_MainSolver \ No newline at end of file diff --git a/Equipments/TopDrive/TopDriveMain.f90 b/Equipments/TopDrive/TopDriveMain.f90 index 390df53..6c42c0f 100644 --- a/Equipments/TopDrive/TopDriveMain.f90 +++ b/Equipments/TopDrive/TopDriveMain.f90 @@ -4,13 +4,14 @@ module TopDriveMain public contains - subroutine TopDrive_Setup() - use CSimulationVariables - implicit none - call OnSimulationStop%Add(TopDrive_Stop) - call OnTopDriveStart%Add(TopDrive_Start) - call OnTopDriveStep%Add(TopDrive_Step) - call OnTopDriveMain%Add(TopDriveMainBody) + subroutine TopDrive_Init() + !use CSimulationVariables + !implicit none + !call OnSimulationStop%Add(TopDrive_Stop) + !call OnTopDriveStart%Add(TopDrive_Start) + !call OnTopDriveStep%Add(TopDrive_Step) + !call OnTopDriveMain%Add(TopDriveMainBody) + Call TopDrive_StartUp end subroutine subroutine TopDrive_Stop @@ -26,15 +27,11 @@ module TopDriveMain subroutine TopDrive_Step implicit none call Log_4('TopDrive_Step') - end subroutine TopDrive_Step - - + Call Rtable_MainSolver + end subroutine TopDrive_Step subroutine TopDriveMainBody - - !use CDataDisplayConsoleVariables - !use CDrillingConsoleVariables use CSimulationVariables use TopDrive_VARIABLES use CDrillWatchVariables @@ -50,125 +47,24 @@ module TopDriveMain call Log_4('TopDriveMainBody') Call TopDrive_StartUp - loopTopDrivestart : do - - call sleepqq(10) - !if ( (TopDriveTdsPowerState==-1) .and. (RpmKnob==0.) ) then !FWD - if ( (TopDriveTdsPowerState==-1) ) then !FWD - - - TDS%SoundBlower = .true. - !Call SetSoundBlowerRT(TDS%SoundBlower) - TopDriveTdsPowerLed = 1 - - loopTopDriveswitchFWD: do - - CALL DATE_AND_TIME(values=TDS_START_TIME) - - !IF ( RTTransmissionLever /=0 .and. RotaryGearsAbuse==0 ) THEN !be in clutch mode ???? - TDS%N_new = (RpmKnob/250.d0)*965.d0 ! 0