Simulation Core
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

812 рядки
28 KiB

  1. module Simulator
  2. use IFPORT
  3. use RedisInterface
  4. use Bop
  5. use PumpsMain
  6. use RopMain
  7. use RotaryTableMain
  8. use DrawworksMain
  9. use FluidFlowMain
  10. use TorqueDragMain
  11. use MudSystemMain
  12. use PipeRams1Main
  13. use PipeRams2Main
  14. use KillLineMain
  15. use ChokeLineMain
  16. use BlindRamsMain
  17. use AnnularMain
  18. use TopDriveMain
  19. use CManifolds
  20. use GeoMain
  21. use ChokeControlMain
  22. use COperationScenariosMain
  23. ! For Json read and write
  24. use CStringConfiguration
  25. use CFormation
  26. use CReservoir
  27. use CShoe
  28. use CAccumulator
  29. use CBopStack
  30. use CHoisting
  31. use CPower
  32. use CPumpsVariables
  33. use CRigSize
  34. use CCasingLinerChoke
  35. use CPathGeneration
  36. use CWellSurveyData
  37. use MudPropertiesModule
  38. use CBitProblems
  39. use CBopProblems
  40. use CChokeProblems
  41. use CDrillStemProblems
  42. use CGaugesProblems
  43. use CHoistingProblems
  44. use CKickProblems
  45. use CLostProblems
  46. use CMudTreatmentProblems
  47. use COtherProblems
  48. use CPumpProblems
  49. use CRotaryProblems
  50. use OperationScenariosModule
  51. use PermissionsModule
  52. use UnitySignalsModule
  53. use CBopControlPanel
  54. use CChokeControlPanel
  55. use CChokeManifold
  56. use CDataDisplayConsole
  57. use CDrillingConsole
  58. use CHook
  59. use CStandPipeManifold
  60. use CTopDrivePanel
  61. use DrillingWatchModule
  62. use CTanks
  63. use UnityModule
  64. implicit none
  65. type(json_file) :: jsonfile
  66. type(json_core):: json
  67. integer :: simulationStatus,simulationSpeed,msPerStep,simulationEnd,simulationStep
  68. real :: stepTime !time for each step
  69. character(len=:),allocatable::redisInput,redisOutput
  70. enum, bind(c)
  71. enumerator :: PLAY = 1
  72. enumerator :: PAUSE = 2
  73. enumerator :: STOP = 3
  74. enumerator :: PLAY_TO_DETERMINED_TIME = 4
  75. end enum
  76. contains
  77. FUNCTION time_ms()
  78. INTEGER(8) :: time_ms
  79. integer,dimension(8)::timearray
  80. call date_and_time(values=timearray)
  81. time_ms = timearray(8)+timearray(7)*1000 + timearray(6)*60000 + timearray(5)*60000*600000 +timearray(4)*24*60000*60000
  82. RETURN
  83. END FUNCTION
  84. subroutine Simulate(redis_host,redis_port,redis_password, sim_id,log_level)
  85. character(len=*) :: redis_host,redis_password, sim_id
  86. integer::t0,t1,t2,t3,t_read=0,t_write=0,t_exec=0,i,status,redis_port,log_level
  87. integer(8),dimension(12)::t,t_modules
  88. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  89. do i=1,size(t_modules)
  90. t_modules(i)=0
  91. end do
  92. logging = log_level
  93. ! call initSimulation(configFilename)
  94. call initConnection(redis_host,redis_port,redis_password, sim_id,status)
  95. if (status<0) then
  96. print *,"Can not init connection to redis."
  97. stop
  98. endif
  99. call read_configuration()
  100. ! call read_variables()
  101. print *,"connection initialized"
  102. call init_modules()
  103. print *,"modules initialized"
  104. ! call cpu_time(T1)
  105. simulationStep = 1
  106. do while (.true.)
  107. ! print *,"simulationStep=",simulationStep
  108. t0 = time_ms()
  109. ! print *,"start reading."
  110. call read_variables()
  111. if(simulationStatus==PLAY_TO_DETERMINED_TIME .and. simulationStep>simulationEnd) exit
  112. if(simulationStatus==STOP) exit
  113. if(simulationStatus==PAUSE) then
  114. print *, "paused"
  115. go to 211
  116. endif
  117. if(logging>4) print *,"end reading"
  118. t1 = time_ms()
  119. t_read = t_read+t1-t0
  120. if(logging>4) print *,"read completed"
  121. !! Rafiee, nothing changed
  122. call BopStack_Step()
  123. t(1) = time_ms()
  124. t_modules(1) = t_modules(1)+t(1)-t1
  125. !! Tarmigh, now is rewritten
  126. call Pump1_Step()
  127. t(2) = time_ms()
  128. t_modules(2) = t_modules(2)+t(2)-t(1)
  129. !call Pump2_Step()
  130. !! Rafiee
  131. call ChokeControl_Step()
  132. t(3) = time_ms()
  133. t_modules(3) = t_modules(3)+t(3)-t(2)
  134. !! Tarmigh, now is rewritten
  135. call RotaryTable_Step()
  136. t(4) = time_ms()
  137. t_modules(4) = t_modules(4)+t(4)-t(3)
  138. !! Tarmigh, now is rewritten
  139. call Drawworks_Step()
  140. t(5) = time_ms()
  141. t_modules(5) = t_modules(5)+t(5)-t(4)
  142. !! Rafiee
  143. call MudSystem_Step()
  144. !! Rafiee
  145. call PipeRams1_Step()
  146. call PipeRams2_Step()
  147. !! Rafiee
  148. call KillLine_Step()
  149. t(6) = time_ms()
  150. t_modules(6) = t_modules(6)+t(6)-t(5)
  151. !! Rafiee
  152. call ChokeLine_Step()
  153. t(7) = time_ms()
  154. t_modules(7) = t_modules(7)+t(7)-t(6)
  155. call BlindRams_Step()
  156. t(8) = time_ms()
  157. t_modules(8) = t_modules(8)+t(8)-t(7)
  158. call Annular_Step()
  159. t(9) = time_ms()
  160. t_modules(9) = t_modules(9)+t(9)-t(8)
  161. !!Tarmigh. Step must rewrittem
  162. call TopDrive_Step()
  163. t(10) = time_ms()
  164. t_modules(10) = t_modules(10)+t(10)-t(9)
  165. ! call Geo_Step()
  166. !!Ahmadi
  167. call PathFinding_Step()
  168. t(11) = time_ms()
  169. t_modules(11) = t_modules(11)+t(11)-t(10)
  170. !! Sheikh
  171. ! call FluidFlow_Step()
  172. !! Ahmadi
  173. call OperationScenarios_Step()
  174. !! Write variables to shared files
  175. t2 = time_ms()
  176. ! stepTime = t2-t1
  177. t_modules(12) = t_modules(12)+t2-t(11)
  178. t_exec = t_exec+t2-t1
  179. ! call date_and_time(values=timearray)
  180. ! t0 = time_ms()
  181. call write_variables()
  182. t3 = time_ms()
  183. if(t3-t0 < 100) then
  184. call sleepqq(t3-t0)
  185. else
  186. print *,"Simulation step can not be complete in 100 ms. step time=",t3-t0
  187. endif
  188. t_write = t_write+t3-t2
  189. ! print *,"write completed"
  190. ! print *,"t=",t
  191. simulationStep = simulationStep + 1
  192. 211 end do
  193. ! call write_variables()
  194. ! call json%print(jsonroot,'test.json')
  195. ! call json%destroy(jsonroot)
  196. do i=1,size(t)
  197. print *,"t_modules(",i,")=",t_modules(i)
  198. end do
  199. print *,"Number of steps =",simulationStep-1
  200. print *,"Read Time (from redis) =",t_read
  201. print *,"Write Time (to redis)=",t_write
  202. print *,"Simulation Time =",t_exec
  203. print *,"Total Time =",t_read+t_write+t_exec
  204. end subroutine Simulate
  205. ! subroutine initSimulation(configFilename)
  206. ! use json_module
  207. ! use iso_c_binding, only: c_null_char,c_char
  208. ! character(len=*) :: configFilename
  209. ! ! type(json_file) :: jsonfile
  210. ! type(json_value),pointer :: jsonvalue
  211. ! type(json_core) :: jsoncore
  212. ! ! logical :: is_found
  213. ! ! character(len=:),allocatable :: password,address,datakey
  214. ! ! character(len=:),allocatable::c_address,c_password,c_datakey
  215. ! call jsonfile%initialize()
  216. ! ! print *,"init simulation with ",configFilename
  217. ! call jsonfile%load_file(configFilename);
  218. ! if (jsonfile%failed()) then
  219. ! print *,"can not open config file: ",configFilename ;
  220. ! stop
  221. ! endif
  222. ! ! print *,"file read"
  223. ! call jsonfile%json_file_get_root(jsonvalue)
  224. ! call jsoncore%get(jsonvalue,'logging',logging)
  225. ! print *,"logging=",logging
  226. ! end subroutine
  227. subroutine write_variables()
  228. use CAccumulator
  229. use json_module
  230. implicit none
  231. type(json_value),pointer :: jsonroot
  232. character(len=20)::fn
  233. ! integer::n_children
  234. call json%initialize()
  235. call json%create_object(jsonroot,'')
  236. ! print *,"status=",simulationStatus
  237. ! call json%add(jsonroot,'status',simulationStatus)
  238. ! call json%add(jsonroot,'speed',simulationSpeed)
  239. ! call json%add(jsonroot,'endstep',simulationEnd)
  240. call json%add(jsonroot,'step',simulationStep)
  241. ! call ConfigurationToJson(jsonroot)
  242. call WarningsToJson(jsonroot)
  243. ! call ProblemsToJson(jsonroot)
  244. call EquipmentsToJson(jsonroot)
  245. ! print *,"write starts"
  246. write (fn,*) "data",simulationStep
  247. ! call json%print(jsonroot,trim(fn)//".json")
  248. call json%serialize(jsonroot,redisInput)
  249. ! call compress_string(redisContent)
  250. if(logging>4) print *,"Writing to redis:",len(redisInput)
  251. call setData(redisInput)
  252. ! nullify(redisContent)
  253. ! deallocate(redisContent)
  254. ! call json%destroy(pval)
  255. call json%destroy(jsonroot)
  256. ! print *,"write ends"
  257. end subroutine
  258. subroutine read_configuration()
  259. type(json_value),pointer :: jsonroot
  260. type(json_value),pointer :: pval
  261. call getData(redisOutput)
  262. ! print *,len(redisOutput)," bytes read from redis"
  263. open(1,file="redisContent.json",status="REPLACE")
  264. write(1,"(A)") redisOutput
  265. close(1)
  266. ! call json%initialize()
  267. call jsonfile%initialize()
  268. ! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
  269. call jsonfile%deserialize(redisOutput)
  270. call jsonfile%json_file_get_root(jsonroot)
  271. ! call json%info(jsonvalue, n_children=n_children)
  272. ! print *,"n_children =",n_children
  273. call json%get(jsonroot,'status',pval)
  274. call json%get(pval,simulationStatus)
  275. call json%get(jsonroot,'speed',pval)
  276. call json%get(pval,simulationSpeed)
  277. if(simulationSpeed==0) simulationSpeed = 1
  278. msPerStep = 100/simulationSpeed
  279. call json%get(jsonroot,'endstep',pval)
  280. call json%get(pval,simulationEnd)
  281. call ConfigurationFromJson(jsonroot)
  282. ! call WarningsFromJson(jsonroot)
  283. ! call ProblemsFromJson(jsonvalue)
  284. ! call EquipmentsFromJson(jsonroot)
  285. ! deallocate(redisContent)
  286. ! call json%destroy(pval)
  287. ! call json%destroy(jsonroot)
  288. end subroutine
  289. subroutine read_variables()
  290. type(json_value),pointer :: jsonroot,pval
  291. call getData(redisOutput)
  292. ! print *,len(redisOutput)," bytes read from redis"
  293. ! open(1,file="redisContent.json",status="REPLACE")
  294. ! write(1,"(A)") redisContent
  295. ! close(1)
  296. call jsonfile%initialize()
  297. call jsonfile%deserialize(redisOutput)
  298. ! call jsonfile%initialize()
  299. ! call jsonfile%load_file('redisContent.json'); if (jsonfile%failed()) stop
  300. call jsonfile%json_file_get_root(jsonroot)
  301. ! call json%info(jsonvalue, n_children=n_children)
  302. ! print *,"n_children =",n_children
  303. call json%get(jsonroot,'status',pval)
  304. call json%get(pval,simulationStatus)
  305. call json%get(jsonroot,'speed',pval)
  306. call json%get(pval,simulationSpeed)
  307. if(simulationSpeed==0) simulationSpeed = 1
  308. msPerStep = 100/simulationSpeed
  309. call json%get(jsonroot,'endstep',pval)
  310. call json%get(pval,simulationEnd)
  311. print *,simulationStep,"/",simulationEnd
  312. ! call ConfigurationFromJson(jsonroot)
  313. ! call WarningsFromJson(jsonroot)
  314. call ProblemsFromJson(jsonroot)
  315. call EquipmentsFromJson(jsonroot)
  316. ! deallocate(redisContent)
  317. ! call json%destroy(pval)
  318. ! call json%destroy(jsonroot)
  319. end subroutine
  320. subroutine init_modules
  321. print *,"initializing modules"
  322. !Tarmigh
  323. call Pump1_Init()
  324. print *,"pump1 initialized"
  325. !call Pump2_Init()
  326. call RotaryTable_Init()
  327. print *,"RT initialized"
  328. call Drawworks_Init()
  329. call TopDrive_Init()
  330. print *,"TD initialized"
  331. !Nothing in init (and step)
  332. ! call Rop_Init()
  333. ! call TorqueDrag_Init()
  334. ! call Geo_Step()
  335. !! Rafiee
  336. call BopStack_Init()
  337. call ChokeControl_Init()
  338. call MudSystem_Init()
  339. print *,"Mudsystem initialized"
  340. !Again calls Bop_Startup
  341. ! call PipeRams1_Init()
  342. ! call PipeRams2_Step()
  343. ! call KillLine_Step()
  344. ! call ChokeLine_Step()
  345. ! call BlindRams_Step()
  346. ! call Annular_Step()
  347. !! Sheikh
  348. ! call FluidFlow_Init()
  349. ! print *,"Mudsystem initialized"
  350. !! Ahmadi
  351. call PathFinding_Init()
  352. ! Calls OSInitialization and that sub only subscribes some notif
  353. ! call OperationScenarios_Init()
  354. end subroutine init_modules
  355. subroutine EquipmentsFromJson(parent)
  356. type(json_value),pointer :: parent
  357. type(json_value),pointer :: p
  358. ! 1. get related root
  359. call json%get(parent,"Equipments",p)
  360. ! 2. add member of data type to new node
  361. call BopControlPanelFromJson(p)
  362. call ChokeControlPanelFromJson(p)
  363. call ChokeManifoldFromJson(p)
  364. call DataDisplayConsoleFromJson(p)
  365. call DrillingConsoleFromJson(p)
  366. ! call HookFromJson(p)
  367. call StandPipeManifoldFromJson(p)
  368. call TopDrivePanelFromJson(p)
  369. ! call DrillingWatchFromJson(p)
  370. call TankFromJson(p)
  371. end subroutine
  372. subroutine EquipmentsToJson(parent)
  373. type(json_value),pointer :: parent
  374. type(json_value),pointer :: p
  375. ! 1. create new node
  376. call json%create_object(p,'Equipments')
  377. ! 2. add member of data type to new node
  378. call BopControlPanelToJson(p)
  379. call ChokeControlPanelToJson(p)
  380. call ChokeManifoldToJson(p)
  381. call DataDisplayConsoleToJson(p)
  382. call DrillingConsoleToJson(p)
  383. call HookToJson(p)
  384. call StandPipeManifoldToJson(p)
  385. call TopDrivePanelToJson(p)
  386. call DrillingWatchToJson(p)
  387. ! call TankToJson(p)
  388. ! 3. add new node to parent
  389. call json%add(parent,p)
  390. end subroutine
  391. subroutine ConfigurationToJson(parent)
  392. type(json_value),pointer :: parent
  393. type(json_value),pointer :: p
  394. ! 1. create new node
  395. call json%create_object(p,'Configuration')
  396. ! 2. add member of data type to new node
  397. call StringConfigurationToJson(p)
  398. call FormationToJson(p)
  399. call ReservoirToJson(p)
  400. call ShoeToJson(p)
  401. call AccumulatorToJson(p)
  402. call BopStackToJson(p)
  403. call HoistingToJson(p)
  404. call PowerToJson(p)
  405. call PumpsToJson(p)
  406. call RigSizeToJson(p)
  407. call CasingLinerChokeToJson(p)
  408. call PathGenerationToJson(p)
  409. ! call WellSurveyDataToJson(p)
  410. call MudPropertiesToJson(p)
  411. call UnityOutputsToJson(p)
  412. ! 3. add new node to parent
  413. call json%add(parent,p)
  414. end subroutine
  415. subroutine WarningsToJson(parent)
  416. type(json_value),pointer :: parent
  417. type(json_value),pointer :: p
  418. ! 1. create new node
  419. call json%create_object(p,'Warnings')
  420. ! 2. add member of data type to new node
  421. call json%add(p,"PumpWithKellyDisconnected",data%Warnings%PumpWithKellyDisconnected)
  422. call json%add(p,"PumpWithTopdriveDisconnected",data%Warnings%PumpWithTopdriveDisconnected)
  423. call json%add(p,"Pump1PopOffValveBlown",data%Warnings%Pump1PopOffValveBlown)
  424. call json%add(p,"Pump1Failure",data%Warnings%Pump1Failure)
  425. call json%add(p,"Pump2PopOffValveBlown",data%Warnings%Pump2PopOffValveBlown)
  426. call json%add(p,"Pump2Failure",data%Warnings%Pump2Failure)
  427. call json%add(p,"Pump3PopOffValveBlown",data%Warnings%Pump3PopOffValveBlown)
  428. call json%add(p,"Pump3Failure",data%Warnings%Pump3Failure)
  429. call json%add(p,"DrawworksGearsAbuse",data%Warnings%DrawworksGearsAbuse)
  430. call json%add(p,"RotaryGearsAbuse",data%Warnings%RotaryGearsAbuse)
  431. call json%add(p,"HoistLineBreak",data%Warnings%HoistLineBreak)
  432. call json%add(p,"PartedDrillString",data%Warnings%PartedDrillString)
  433. call json%add(p,"ActiveTankOverflow",data%Warnings%ActiveTankOverflow)
  434. call json%add(p,"ActiveTankUnderVolume",data%Warnings%ActiveTankUnderVolume)
  435. call json%add(p,"TripTankOverflow",data%Warnings%TripTankOverflow)
  436. call json%add(p,"DrillPipeTwistOff",data%Warnings%DrillPipeTwistOff)
  437. call json%add(p,"DrillPipeParted",data%Warnings%DrillPipeParted)
  438. call json%add(p,"TripWithSlipsSet",data%Warnings%TripWithSlipsSet)
  439. call json%add(p,"Blowout",data%Warnings%Blowout)
  440. call json%add(p,"UndergroundBlowout",data%Warnings%UndergroundBlowout)
  441. call json%add(p,"MaximumWellDepthExceeded",data%Warnings%MaximumWellDepthExceeded)
  442. call json%add(p,"CrownCollision",data%Warnings%CrownCollision)
  443. call json%add(p,"FloorCollision",data%Warnings%FloorCollision)
  444. call json%add(p,"TopdriveRotaryTableConfilict",data%Warnings%TopdriveRotaryTableConfilict)
  445. ! 3. add new node to parent
  446. call json%add(parent,p)
  447. end subroutine
  448. subroutine ProblemsToJson(parent)
  449. type(json_value),pointer :: parent
  450. type(json_value),pointer :: p
  451. ! 1. create new node
  452. call json%create_object(p,'Problems')
  453. ! 2. add member of data type to new node
  454. call BitProblemsToJson(p)
  455. call BopProblemsToJson(p)
  456. call ChokeProblemsToJson(p)
  457. call DrillStemProblemsToJson(p)
  458. call GaugesProblemsToJson(p)
  459. call HoistingProblemsToJson(p)
  460. call KickProblemsToJson(p)
  461. call LostProblemsToJson(p)
  462. call MudTreatmentProblemsToJson(p)
  463. call OtherProblemsToJson(p)
  464. call PumpProblemsToJson(p)
  465. call RotaryProblemsToJson(p)
  466. ! 3. add new node to parent
  467. call json%add(parent,p)
  468. end subroutine
  469. subroutine StateToJson(parent)
  470. type(json_value),pointer :: parent
  471. type(json_value),pointer :: p
  472. ! 1. create new node
  473. call json%create_object(p,'State')
  474. ! call OperationScenarioToJson(p)
  475. call notificationsToJson(p)
  476. ! call permissionsToJson(p)
  477. ! call unitySignalsToJson(p)
  478. ! call StudentStationToJson(p)
  479. ! call BopStackInputToJson(p)
  480. ! call BopStackAccToJson(p)
  481. ! call RamLineToJson(p)
  482. ! call AnnularComputationalToJson(p)
  483. ! call AnnularToJson(p)
  484. ! call PipeRam1ToJson(p)
  485. ! call ShearRamToJson(p)
  486. ! call PipeRam2ToJson(p)
  487. ! call ChokeLineToJson(p)
  488. ! call KillLineToJson(p)
  489. ! call PumpsToJson(p)
  490. ! call RAMToJson(p)
  491. ! call RAMSToJson(p)
  492. ! call ChokeToJson(p)
  493. ! call AirDrivenPumpToJson(p)
  494. ! call AirPumpLineToJson(p)
  495. ! call CHOOKEToJson(p)
  496. ! call DrawworksToJson(p)
  497. ! call MudSystemToJson(p)
  498. ! call MUDToJson(p)
  499. ! call MPumpsToJson(p)
  500. ! call PUMPToJson(p)
  501. ! call RTableToJson(p)
  502. ! call TDSToJson(p)
  503. ! call GasType(3)ToJson(p)
  504. ! call PressureDisplayToJson(p)
  505. ! call FricPressDropToJson(p)
  506. ! call ROP_SpecToJson(p)
  507. ! call ROP_BitToJson(p)
  508. ! call TDGeoToJson(p)
  509. ! call F_String(:)ToJson(p)
  510. ! call F_CountsToJson(p)
  511. ! call F_Interval(:)ToJson(p)
  512. ! call OD_Annulus(4)ToJson(p)
  513. ! call TD_DrillStemToJson(p)
  514. ! call TD_DrillStemsToJson(p)
  515. ! call TD_StringToJson(p)
  516. ! call TD_CountToJson(p)
  517. ! call G_StringElementToJson(p)
  518. ! call TD_VolToJson(p)
  519. ! call TD_GeneralToJson(p)
  520. ! call TD_BOPToJson(p)
  521. ! call TD_BOPElement(4)ToJson(p)
  522. ! call TD_StConnToJson(p)
  523. ! call TD_LoadToJson(p)
  524. ! call TD_WellElToJson(p)
  525. ! call TD_CasingToJson(p)
  526. ! call TD_LinerToJson(p)
  527. ! call TD_OpenHoleToJson(p)
  528. ! call TD_ROPHoleToJson(p)
  529. ! call TD_WellGeneralToJson(p)
  530. ! call TD_WellGeo(:)ToJson(p)
  531. ! 2. add member of data type to new node
  532. ! 3. add new node to parent
  533. call json%add(parent,p)
  534. end subroutine
  535. !use this as a template
  536. subroutine notificationsToJson(parent)
  537. type(json_value),pointer :: parent
  538. type(json_value),pointer :: p
  539. ! 1. create new node
  540. call json%create_object(p,'Notifications')
  541. ! 2. add member of data type to new node
  542. ! 3. add new node to parent
  543. call json%add(parent,p)
  544. end subroutine
  545. subroutine ConfigurationFromJson(parent)
  546. type(json_value),pointer :: parent
  547. type(json_value),pointer :: p
  548. ! 1. get related root
  549. call json%get(parent,"Configuration",p)
  550. call StringConfigurationFromJson(p)
  551. call FormationFromJson(p)
  552. call ReservoirFromJson(p)
  553. call ShoeFromJson(p)
  554. call AccumulatorFromJson(p)
  555. call BopStackFromJson(p)
  556. call HoistingFromJson(p)
  557. call PowerFromJson(p)
  558. call PumpsFromJson(p)
  559. call RigSizeFromJson(p)
  560. call CasingLinerChokeFromJson(p)
  561. call PathGenerationFromJson(p)
  562. call MudPropertiesFromJson(p)
  563. call UnityInputsFromJson(p)
  564. ! 3. add new node to parent
  565. call json%add(parent,p)
  566. end subroutine
  567. subroutine WarningsFromJson(parent)
  568. type(json_value),pointer :: parent
  569. type(json_value),pointer :: p
  570. type(json_value),pointer :: pval
  571. ! 1. get node
  572. call json%get(parent,'Warnings',p)
  573. ! ! 2. add member of data type to new node
  574. call json%get(p,'PumpWithKellyDisconnected',pval)
  575. call json%get(pval,data%Warnings%PumpWithKellyDisconnected)
  576. call json%get(p,'PumpWithTopdriveDisconnected',pval)
  577. call json%get(pval,data%Warnings%PumpWithTopdriveDisconnected)
  578. call json%get(p,'Pump1PopOffValveBlown',pval)
  579. call json%get(pval,data%Warnings%Pump1PopOffValveBlown)
  580. call json%get(p,'Pump1Failure',pval)
  581. call json%get(pval,data%Warnings%Pump1Failure)
  582. call json%get(p,'Pump2PopOffValveBlown',pval)
  583. call json%get(pval,data%Warnings%Pump2PopOffValveBlown)
  584. call json%get(p,'Pump2Failure',pval)
  585. call json%get(pval,data%Warnings%Pump2Failure)
  586. call json%get(p,'Pump3PopOffValveBlown',pval)
  587. call json%get(pval,data%Warnings%Pump3PopOffValveBlown)
  588. call json%get(p,'Pump3Failure',pval)
  589. call json%get(pval,data%Warnings%Pump3Failure)
  590. call json%get(p,'DrawworksGearsAbuse',pval)
  591. call json%get(pval,data%Warnings%DrawworksGearsAbuse)
  592. call json%get(p,'RotaryGearsAbuse',pval)
  593. call json%get(pval,data%Warnings%RotaryGearsAbuse)
  594. call json%get(p,'HoistLineBreak',pval)
  595. call json%get(pval,data%Warnings%HoistLineBreak)
  596. call json%get(p,'PartedDrillString',pval)
  597. call json%get(pval,data%Warnings%PartedDrillString)
  598. call json%get(p,'ActiveTankOverflow',pval)
  599. call json%get(pval,data%Warnings%ActiveTankOverflow)
  600. call json%get(p,'ActiveTankUnderVolume',pval)
  601. call json%get(pval,data%Warnings%ActiveTankUnderVolume)
  602. call json%get(p,'TripTankOverflow',pval)
  603. call json%get(pval,data%Warnings%TripTankOverflow)
  604. call json%get(p,'DrillPipeTwistOff',pval)
  605. call json%get(pval,data%Warnings%DrillPipeTwistOff)
  606. call json%get(p,'DrillPipeParted',pval)
  607. call json%get(pval,data%Warnings%DrillPipeParted)
  608. call json%get(p,'TripWithSlipsSet',pval)
  609. call json%get(pval,data%Warnings%TripWithSlipsSet)
  610. call json%get(p,'Blowout',pval)
  611. call json%get(pval,data%Warnings%Blowout)
  612. call json%get(p,'UndergroundBlowout',pval)
  613. call json%get(pval,data%Warnings%UndergroundBlowout)
  614. call json%get(p,'MaximumWellDepthExceeded',pval)
  615. call json%get(pval,data%Warnings%MaximumWellDepthExceeded)
  616. call json%get(p,'CrownCollision',pval)
  617. call json%get(pval,data%Warnings%CrownCollision)
  618. call json%get(p,'FloorCollision',pval)
  619. call json%get(pval,data%Warnings%FloorCollision)
  620. call json%get(p,'TopdriveRotaryTableConfilict',pval)
  621. call json%get(pval,data%Warnings%TopdriveRotaryTableConfilict)
  622. end subroutine
  623. subroutine ProblemsFromJson(parent)
  624. type(json_value),pointer :: parent
  625. type(json_value),pointer :: p
  626. call json%get(parent,'Warnings',p)
  627. call BitProblemsToJson(p)
  628. call BopProblemsFromJson(p)
  629. call ChokeProblemsFromJson(p)
  630. call DrillStemProblemsFromJson(p)
  631. call GaugesProblemsFromJson(p)
  632. call HoistingProblemsFromJson(p)
  633. call KickProblemsFromJson(p)
  634. call LostProblemsFromJson(p)
  635. call MudTreatmentProblemsFromJson(p)
  636. call OtherProblemsFromJson(p)
  637. call PumpProblemsFromJson(p)
  638. call RotaryProblemsFromJson(p)
  639. end subroutine
  640. subroutine StateFromJson(parent)
  641. type(json_value),pointer :: parent
  642. type(json_value),pointer :: p
  643. ! 1. create new node
  644. ! call json%create_object(p,'State')
  645. ! ! call OperationScenarioFromJson(p)
  646. ! call notificationsFromJson(p)
  647. ! call permissionsFromJson(p)
  648. ! call unitySignalsFromJson(p)
  649. ! call StudentStationFromJson(p)
  650. ! call BopStackInputFromJson(p)
  651. ! call BopStackAccFromJson(p)
  652. ! call RamLineFromJson(p)
  653. ! call AnnularComputationalFromJson(p)
  654. ! call AnnularFromJson(p)
  655. ! call PipeRam1FromJson(p)
  656. ! call ShearRamFromJson(p)
  657. ! call PipeRam2FromJson(p)
  658. ! call ChokeLineFromJson(p)
  659. ! call KillLineFromJson(p)
  660. ! call PumpsFromJson(p)
  661. ! call RAMFromJson(p)
  662. ! call RAMSFromJson(p)
  663. ! call ChokeFromJson(p)
  664. ! call AirDrivenPumpFromJson(p)
  665. ! call AirPumpLineFromJson(p)
  666. ! call CHOOKEFromJson(p)
  667. ! call DrawworksFromJson(p)
  668. ! call MudSystemFromJson(p)
  669. ! call MUDFromJson(p)
  670. ! call MPumpsFromJson(p)
  671. ! call PUMPFromJson(p)
  672. ! call RTableFromJson(p)
  673. ! call TDSFromJson(p)
  674. ! call GasType(3)FromJson(p)
  675. ! call PressureDisplayFromJson(p)
  676. ! call FricPressDropFromJson(p)
  677. ! call ROP_SpecFromJson(p)
  678. ! call ROP_BitFromJson(p)
  679. ! call TDGeoFromJson(p)
  680. ! call F_String(:)FromJson(p)
  681. ! call F_CountsFromJson(p)
  682. ! call F_Interval(:)FromJson(p)
  683. ! call OD_Annulus(4)FromJson(p)
  684. ! call TD_DrillStemFromJson(p)
  685. ! call TD_DrillStemsFromJson(p)
  686. ! call TD_StringFromJson(p)
  687. ! call TD_CountFromJson(p)
  688. ! call G_StringElementFromJson(p)
  689. ! call TD_VolFromJson(p)
  690. ! call TD_GeneralFromJson(p)
  691. ! call TD_BOPFromJson(p)
  692. ! call TD_BOPElement(4)FromJson(p)
  693. ! call TD_StConnFromJson(p)
  694. ! call TD_LoadFromJson(p)
  695. ! call TD_WellElFromJson(p)
  696. ! call TD_CasingFromJson(p)
  697. ! call TD_LinerFromJson(p)
  698. ! call TD_OpenHoleFromJson(p)
  699. ! call TD_ROPHoleFromJson(p)
  700. ! call TD_WellGeneralFromJson(p)
  701. ! call TD_WellGeo(:)FromJson(p)
  702. ! 2. add member of data type to new node
  703. ! 3. add new node to parent
  704. call json%add(parent,p)
  705. end subroutine
  706. !use this as a template
  707. subroutine notificationsFromJson(parent)
  708. type(json_value),pointer :: parent
  709. !
  710. ! type(json_value),pointer :: p
  711. ! 1. create new node
  712. ! call json%create_object(p,'Notifications')
  713. ! ! 2. add member of data type to new node
  714. ! ! 3. add new node to parent
  715. ! call json%add(parent,p)
  716. end subroutine
  717. end module Simulator