8 #include <boost/make_shared.hpp>
10 #if defined(SOCI_HEADERS_BURIED)
11 #include <soci/core/soci.h>
12 #else // SOCI_HEADERS_BURIED
13 #include <soci/soci.h>
14 #endif // SOCI_HEADERS_BURIED
16 #include <stdair/stdair_json.hpp>
17 #include <stdair/stdair_file.hpp>
18 #include <stdair/basic/BasConst_General.hpp>
19 #include <stdair/basic/BasChronometer.hpp>
20 #include <stdair/basic/JSonCommand.hpp>
21 #include <stdair/bom/BomManager.hpp>
22 #include <stdair/bom/BomRoot.hpp>
23 #include <stdair/bom/AirlineStruct.hpp>
24 #include <stdair/bom/BookingRequestStruct.hpp>
25 #include <stdair/bom/BomJSONImport.hpp>
26 #include <stdair/command/DBManagerForAirlines.hpp>
27 #include <stdair/service/FacSupervisor.hpp>
28 #include <stdair/service/Logger.hpp>
29 #include <stdair/service/DBSessionManager.hpp>
30 #include <stdair/STDAIR_Service.hpp>
32 #include <sevmgr/SEVMGR_Service.hpp>
34 #include <simcrs/SIMCRS_Service.hpp>
36 #include <trademgen/TRADEMGEN_Service.hpp>
38 #include <travelccm/TRAVELCCM_Service.hpp>
53 TVLSIM_Service::TVLSIM_Service () : _tvlsimServiceContext (NULL) {
58 TVLSIM_Service::TVLSIM_Service (
const TVLSIM_Service& iService) {
63 TVLSIM_Service::TVLSIM_Service
64 (
const stdair::BasLogParams& iLogParams,
65 const stdair::Date_T& iStartDate,
66 const stdair::Date_T& iEndDate,
67 const stdair::RandomSeed_T& iRandomSeed,
68 const stdair::DemandGenerationMethod& iDemandGenerationMethod,
70 : _tvlsimServiceContext (NULL) {
73 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
74 initStdAirService (iLogParams);
77 initServiceContext ();
81 const bool ownStdairService =
true;
82 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
85 initConfig (iStartDate, iEndDate, iRandomSeed,
86 iDemandGenerationMethod, iNbOfRuns);
92 initTRADEMGENService ();
95 initTRAVELCCMService();
106 TVLSIM_Service::TVLSIM_Service
107 (
const stdair::BasLogParams& iLogParams,
108 const stdair::BasDBParams& iDBParams,
109 const stdair::Date_T& iStartDate,
110 const stdair::Date_T& iEndDate,
111 const stdair::RandomSeed_T& iRandomSeed,
112 const stdair::DemandGenerationMethod& iDemandGenerationMethod,
114 : _tvlsimServiceContext (NULL) {
117 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
118 initStdAirService (iLogParams, iDBParams);
121 initServiceContext ();
125 const bool ownStdairService =
true;
126 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
129 initConfig (iStartDate, iEndDate, iRandomSeed,
130 iDemandGenerationMethod, iNbOfRuns);
136 initTRADEMGENService ();
139 initTRAVELCCMService();
150 TVLSIM_Service::TVLSIM_Service
151 (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
152 const stdair::Date_T& iStartDate,
153 const stdair::Date_T& iEndDate,
154 const stdair::RandomSeed_T& iRandomSeed,
155 const stdair::DemandGenerationMethod& iDemandGenerationMethod,
157 : _tvlsimServiceContext (NULL) {
160 initServiceContext ();
164 const bool doesNotOwnStdairService =
false;
165 addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService);
168 initConfig (iStartDate, iEndDate, iRandomSeed,
169 iDemandGenerationMethod, iNbOfRuns);
175 initTRADEMGENService ();
178 initTRAVELCCMService();
195 void TVLSIM_Service::finalise() {
196 assert (_tvlsimServiceContext != NULL);
198 _tvlsimServiceContext->reset();
202 void TVLSIM_Service::initServiceContext () {
205 TVLSIM_ServiceContext& lTVLSIM_ServiceContext =
207 _tvlsimServiceContext = &lTVLSIM_ServiceContext;
211 void TVLSIM_Service::
212 addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
213 const bool iOwnStdairService) {
216 assert (_tvlsimServiceContext != NULL);
217 TVLSIM_ServiceContext& lTVLSIM_ServiceContext = *_tvlsimServiceContext;
220 lTVLSIM_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
225 stdair::STDAIR_ServicePtr_T TVLSIM_Service::
226 initStdAirService (
const stdair::BasLogParams& iLogParams) {
235 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
236 boost::make_shared<stdair::STDAIR_Service> (iLogParams);
238 return lSTDAIR_Service_ptr;
242 stdair::STDAIR_ServicePtr_T TVLSIM_Service::
243 initStdAirService (
const stdair::BasLogParams& iLogParams,
244 const stdair::BasDBParams& iDBParams) {
253 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
254 boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams);
256 return lSTDAIR_Service_ptr;
260 void TVLSIM_Service::initSEVMGRService() {
263 assert (_tvlsimServiceContext != NULL);
264 TVLSIM_ServiceContext& lTVLSIM_ServiceContext = *_tvlsimServiceContext;
267 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
268 lTVLSIM_ServiceContext.getSTDAIR_ServicePtr();
277 SEVMGR::SEVMGR_ServicePtr_T lSEVMGR_Service_ptr =
278 boost::make_shared<SEVMGR::SEVMGR_Service> (lSTDAIR_Service_ptr);
281 lTVLSIM_ServiceContext.setSEVMGR_Service (lSEVMGR_Service_ptr);
286 void TVLSIM_Service::initSIMCRSService() {
289 assert (_tvlsimServiceContext != NULL);
290 TVLSIM_ServiceContext& lTVLSIM_ServiceContext = *_tvlsimServiceContext;
293 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
294 lTVLSIM_ServiceContext.getSTDAIR_ServicePtr();
297 SEVMGR::SEVMGR_ServicePtr_T lSEVMGR_Service_ptr =
298 lTVLSIM_ServiceContext.getSEVMGR_ServicePtr();
301 SIMCRS::CRSCode_T lCRSCode (
"1S");
302 lSTDAIR_Service_ptr->exportConfigValue<SIMCRS::CRSCode_T> (lCRSCode,
312 SIMCRS::SIMCRS_ServicePtr_T lSIMCRS_Service_ptr =
313 boost::make_shared<SIMCRS::SIMCRS_Service> (lSTDAIR_Service_ptr,
318 lTVLSIM_ServiceContext.setSIMCRS_Service (lSIMCRS_Service_ptr);
322 void TVLSIM_Service::initTRADEMGENService () {
325 assert (_tvlsimServiceContext != NULL);
326 TVLSIM_ServiceContext& lTVLSIM_ServiceContext = *_tvlsimServiceContext;
329 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
330 lTVLSIM_ServiceContext.getSTDAIR_ServicePtr();
333 SEVMGR::SEVMGR_ServicePtr_T lSEVMGR_Service_ptr =
334 lTVLSIM_ServiceContext.getSEVMGR_ServicePtr();
337 stdair::RandomSeed_T lRandomSeed (stdair::DEFAULT_RANDOM_SEED);
338 const bool hasSeedBeenRetrieved =
339 lSTDAIR_Service_ptr->exportConfigValue<stdair::RandomSeed_T> (lRandomSeed,
341 assert (hasSeedBeenRetrieved ==
true);
350 TRADEMGEN::TRADEMGEN_ServicePtr_T lTRADEMGEN_Service_ptr =
351 boost::make_shared<TRADEMGEN::TRADEMGEN_Service> (lSTDAIR_Service_ptr,
356 lTVLSIM_ServiceContext.setTRADEMGEN_Service (lTRADEMGEN_Service_ptr);
360 void TVLSIM_Service::initTRAVELCCMService() {
363 assert (_tvlsimServiceContext != NULL);
364 TVLSIM_ServiceContext& lTVLSIM_ServiceContext = *_tvlsimServiceContext;
367 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
368 lTVLSIM_ServiceContext.getSTDAIR_ServicePtr();
377 TRAVELCCM::TRAVELCCM_ServicePtr_T lTRAVELCCM_Service_ptr =
378 boost::make_shared<TRAVELCCM::TRAVELCCM_Service> (lSTDAIR_Service_ptr);
381 lTVLSIM_ServiceContext.setTRAVELCCM_Service (lTRAVELCCM_Service_ptr);
385 void TVLSIM_Service::initDsimService() {
391 void TVLSIM_Service::
392 initConfig (
const stdair::Date_T& iStartDate,
393 const stdair::Date_T& iEndDate,
394 const stdair::RandomSeed_T& iRandomSeed,
395 const stdair::DemandGenerationMethod& iDemandGenerationMethod,
399 if (_tvlsimServiceContext == NULL) {
400 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
401 "has not been initialised");
403 assert (_tvlsimServiceContext != NULL);
404 TVLSIM_ServiceContext& lTVLSIM_ServiceContext = *_tvlsimServiceContext;
407 stdair::STDAIR_Service& lSTDAIR_Service =
408 lTVLSIM_ServiceContext.getSTDAIR_Service();
413 iRandomSeed, iDemandGenerationMethod, iNbOfRuns);
416 SimulationStatus& lSimulationStatus =
417 lTVLSIM_ServiceContext.getSimulationStatus();
422 iStartDate, iEndDate, iNbOfRuns);
430 if (_tvlsimServiceContext == NULL) {
431 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
432 "has not been initialised");
434 assert (_tvlsimServiceContext != NULL);
439 const bool doesOwnStdairService =
440 lTVLSIM_ServiceContext.getOwnStdairServiceFlag();
448 if (doesOwnStdairService ==
true) {
481 const stdair::ODFilePath& iODInputFilename,
482 const stdair::FRAT5FilePath& iFRAT5InputFilename,
483 const stdair::FFDisutilityFilePath& iFFDisutilityInputFilename,
484 const AIRRAC::YieldFilePath& iYieldInputFilepath,
485 const SIMFQT::FareFilePath& iFareInputFilepath,
486 const TRADEMGEN::DemandFilePath& iDemandFilepath) {
489 if (_tvlsimServiceContext == NULL) {
490 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
491 "has not been initialised");
493 assert (_tvlsimServiceContext != NULL);
500 stdair::STDAIR_Service& lSTDAIR_Service =
501 lTVLSIM_ServiceContext.getSTDAIR_Service();
505 iODInputFilename, iFRAT5InputFilename,
506 iFFDisutilityInputFilename, iYieldInputFilepath,
507 iFareInputFilepath, iDemandFilepath);
516 if (_tvlsimServiceContext == NULL) {
517 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
518 "has not been initialised");
520 assert (_tvlsimServiceContext != NULL);
525 const bool doesOwnStdairService =
526 lTVLSIM_ServiceContext.getOwnStdairServiceFlag();
529 stdair::STDAIR_Service& lSTDAIR_Service =
530 lTVLSIM_ServiceContext.getSTDAIR_Service();
533 stdair::Filename_T lFilename (
"");
534 const bool hasScheduleFileBeenRetrieved =
535 lSTDAIR_Service.exportConfigValue<stdair::Filename_T> (lFilename,
537 assert (hasScheduleFileBeenRetrieved ==
true);
538 const stdair::ScheduleFilePath lScheduleInputFilename (lFilename);
539 const bool hasODFileBeenRetrieved =
540 lSTDAIR_Service.exportConfigValue<stdair::Filename_T> (lFilename,
542 assert (hasODFileBeenRetrieved ==
true);
543 const stdair::ODFilePath lODInputFilename (lFilename);
544 const bool hasFrat5FileBeenRetrieved =
545 lSTDAIR_Service.exportConfigValue<stdair::Filename_T> (lFilename,
547 assert (hasFrat5FileBeenRetrieved ==
true);
548 const stdair::FRAT5FilePath lFRAT5InputFilename (lFilename);
549 const bool hasFFdisutilityFileBeenRetrieved =
550 lSTDAIR_Service.exportConfigValue<stdair::Filename_T> (lFilename,
551 "input.ffdisutility");
552 assert (hasFFdisutilityFileBeenRetrieved ==
true);
553 const stdair::FFDisutilityFilePath lFFDisutilityInputFilename (lFilename);
554 const bool hasYieldFileBeenRetrieved =
555 lSTDAIR_Service.exportConfigValue<stdair::Filename_T> (lFilename,
557 assert (hasYieldFileBeenRetrieved ==
true);
558 const AIRRAC::YieldFilePath lYieldInputFilepath (lFilename);
559 const bool hasFareFileBeenRetrieved =
560 lSTDAIR_Service.exportConfigValue<stdair::Filename_T> (lFilename,
562 assert (hasFareFileBeenRetrieved ==
true);
563 const SIMFQT::FareFilePath lFareInputFilepath (lFilename);
564 const bool hasDemandFileBeenRetrieved =
565 lSTDAIR_Service.exportConfigValue<stdair::Filename_T> (lFilename,
567 assert (hasDemandFileBeenRetrieved ==
true);
568 const TRADEMGEN::DemandFilePath lDemandFilepath (lFilename);
577 SIMCRS::SIMCRS_Service& lSIMCRS_Service =
578 lTVLSIM_ServiceContext.getSIMCRS_Service();
579 lSIMCRS_Service.parseAndLoad (lScheduleInputFilename, lODInputFilename,
581 lFFDisutilityInputFilename,
582 lYieldInputFilepath, lFareInputFilepath);
587 TRADEMGEN::TRADEMGEN_Service& lTRADEMGEN_Service =
588 lTVLSIM_ServiceContext.getTRADEMGEN_Service();
589 lTRADEMGEN_Service.parseAndLoad (lDemandFilepath);
596 stdair::BomRoot& lPersistentBomRoot =
597 lSTDAIR_Service.getPersistentBomRoot();
598 buildComplementaryLinks (lPersistentBomRoot);
604 if (doesOwnStdairService ==
true) {
606 clonePersistentBom ();
613 lTVLSIM_ServiceContext.getSimulationStatus();
614 Simulator::updateStatus(lTRADEMGEN_Service, stdair::EventType::BKG_REQ,
622 if (_tvlsimServiceContext == NULL) {
623 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
624 "has not been initialised");
626 assert (_tvlsimServiceContext != NULL);
631 const bool doesOwnStdairService =
632 lTVLSIM_ServiceContext.getOwnStdairServiceFlag();
635 stdair::STDAIR_Service& lSTDAIR_Service =
636 lTVLSIM_ServiceContext.getSTDAIR_Service();
639 stdair::BomRoot& lPersistentBomRoot =
640 lSTDAIR_Service.getPersistentBomRoot();
646 if (doesOwnStdairService ==
true) {
648 lSTDAIR_Service.buildSampleBom();
659 SIMCRS::SIMCRS_Service& lSIMCRS_Service =
660 lTVLSIM_ServiceContext.getSIMCRS_Service();
661 lSIMCRS_Service.buildSampleBom();
667 TRADEMGEN::TRADEMGEN_Service& lTRADEMGEN_Service =
668 lTVLSIM_ServiceContext.getTRADEMGEN_Service();
669 lTRADEMGEN_Service.buildSampleBom();
673 lTVLSIM_ServiceContext.getSimulationStatus();
674 Simulator::updateStatus(lTRADEMGEN_Service, stdair::EventType::BKG_REQ,
681 TRAVELCCM::TRAVELCCM_Service& lTRAVELCCM_Service =
682 lTVLSIM_ServiceContext.getTRAVELCCM_Service();
683 lTRAVELCCM_Service.buildSampleBom();
689 buildComplementaryLinks (lPersistentBomRoot);
695 if (doesOwnStdairService ==
true) {
697 clonePersistentBom ();
702 void TVLSIM_Service::clonePersistentBom () {
705 if (_tvlsimServiceContext == NULL) {
706 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
707 "has not been initialised");
709 assert (_tvlsimServiceContext != NULL);
713 TVLSIM_ServiceContext& lTVLSIM_ServiceContext = *_tvlsimServiceContext;
714 const bool doesOwnStdairService =
715 lTVLSIM_ServiceContext.getOwnStdairServiceFlag();
718 stdair::STDAIR_Service& lSTDAIR_Service =
719 lTVLSIM_ServiceContext.getSTDAIR_Service();
725 if (doesOwnStdairService ==
true) {
727 lSTDAIR_Service.clonePersistentBom ();
738 SIMCRS::SIMCRS_Service& lSIMCRS_Service =
739 lTVLSIM_ServiceContext.getSIMCRS_Service();
740 lSIMCRS_Service.clonePersistentBom ();
746 TRADEMGEN::TRADEMGEN_Service& lTRADEMGEN_Service =
747 lTVLSIM_ServiceContext.getTRADEMGEN_Service();
748 lTRADEMGEN_Service.clonePersistentBom ();
754 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
755 buildComplementaryLinks (lBomRoot);
760 void TVLSIM_Service::buildComplementaryLinks (stdair::BomRoot& ioBomRoot) {
769 if (_tvlsimServiceContext == NULL) {
770 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
771 "has not been initialised");
773 assert (_tvlsimServiceContext != NULL);
777 stdair::STDAIR_Service& lSTDAIR_Service =
778 lTVLSIM_ServiceContext.getSTDAIR_Service();
781 lSTDAIR_Service.buildSampleTravelSolutions (ioTravelSolutionList);
789 if (_tvlsimServiceContext == NULL) {
790 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
791 "has not been initialised");
793 assert (_tvlsimServiceContext != NULL);
797 stdair::STDAIR_Service& lSTDAIR_Service =
798 lTVLSIM_ServiceContext.getSTDAIR_Service();
801 return lSTDAIR_Service.buildSampleBookingRequest (isForCRS);
806 const stdair::ClassCode_T& iClassCode,
807 const stdair::PartySize_T& iPartySize) {
810 if (_tvlsimServiceContext == NULL) {
811 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
812 "has not been initialised");
814 assert (_tvlsimServiceContext != NULL);
818 SIMCRS::SIMCRS_Service& lSIMCRS_Service =
819 lTVLSIM_ServiceContext.getSIMCRS_Service();
822 return lSIMCRS_Service.sell (iSegmentDateKey, iClassCode,
831 if (_tvlsimServiceContext == NULL) {
832 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
833 "has not been initialised");
835 assert (_tvlsimServiceContext != NULL);
841 stdair::JSonCommand::EN_JSonCommand lEN_JSonCommand;
842 const bool hasCommandBeenRetrieved =
843 stdair::BomJSONImport::jsonImportCommand (iJSONString,
846 if (hasCommandBeenRetrieved ==
false) {
848 std::ostringstream oErrorStream;
849 oErrorStream <<
"{\"error\": \"Wrong JSON-ified string: "
850 <<
"the command is not understood.\"}";
851 return oErrorStream.str();
853 assert (hasCommandBeenRetrieved ==
true);
858 switch (lEN_JSonCommand) {
859 case stdair::JSonCommand::FLIGHT_DATE:
860 case stdair::JSonCommand::LIST:{
863 SIMCRS::SIMCRS_Service& lSIMCRS_Service =
864 lTVLSIM_ServiceContext.getSIMCRS_Service();
866 return lSIMCRS_Service.jsonHandler (iJSONString);
868 case stdair::JSonCommand::EVENT_LIST:{
871 TRADEMGEN::TRADEMGEN_Service& lTRADEMGEN_Service =
872 lTVLSIM_ServiceContext.getTRADEMGEN_Service();
874 return lTRADEMGEN_Service.jsonHandler (iJSONString);
876 case stdair::JSonCommand::BREAK_POINT:{
877 return jsonBreakPointHandler (iJSONString);
879 case stdair::JSonCommand::RUN:{
880 return jsonRunHandler (iJSONString);
882 case stdair::JSonCommand::RESET:{
885 std::ostringstream oStream;
886 oStream <<
"{\"done\": \"1\"}";
887 return oStream.str();
889 case stdair::JSonCommand::STATUS:{
892 lTVLSIM_ServiceContext.getSimulationStatus();
893 std::ostringstream oStream;
895 return oStream.str();
897 case stdair::JSonCommand::CONFIG:{
899 stdair::STDAIR_Service& lSTDAIR_Service =
900 lTVLSIM_ServiceContext.getSTDAIR_Service();
902 lSTDAIR_Service.jsonImportConfiguration (iJSONString);
904 return lSTDAIR_Service.jsonExportConfiguration();
908 std::ostringstream lErrorCmdMessage;
909 const std::string& lCommandStr =
910 stdair::JSonCommand::getLabel(lEN_JSonCommand);
911 lErrorCmdMessage <<
"{\"error\": \"The command '" << lCommandStr
912 <<
"' is not handled by the TvlSim service.\"}";
913 return lErrorCmdMessage.str();
920 std::string lJSONDump (
"{\"error\": \"Wrong JSON-ified string\"}");
925 std::string TVLSIM_Service::
926 jsonBreakPointHandler (
const stdair::JSONString& iJSONString) {
928 stdair::BreakPointList_T lBreakPointList;
930 const bool hasBreakPointListBeenRetrieved =
931 stdair::BomJSONImport::jsonImportBreakPoints(iJSONString,
934 if (hasBreakPointListBeenRetrieved ==
false) {
936 std::ostringstream oErrorStream;
937 oErrorStream <<
"{\"error\": \"Wrong JSON-ified string: "
938 <<
"the break point list is not understood.\"}";
939 return oErrorStream.str();
941 assert (hasBreakPointListBeenRetrieved ==
true);
943 const stdair::Count_T lBreakPointsListSize =
944 lBreakPointList.size();
945 const stdair::Count_T lNumberOfBreakPointsAdded =
949 std::ostringstream oStream;
950 if (lNumberOfBreakPointsAdded != lBreakPointsListSize) {
951 oStream <<
"{\"failed: \"" << lNumberOfBreakPointsAdded <<
"\"}";
953 oStream <<
"{\"done\": \"" << lBreakPointList.size() <<
"\"}";
955 return oStream.str();
959 std::string TVLSIM_Service::
960 jsonRunHandler (
const stdair::JSONString& iJSONString) {
963 if (_tvlsimServiceContext == NULL) {
964 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
965 "has not been initialised");
967 assert (_tvlsimServiceContext != NULL);
968 TVLSIM_ServiceContext& lTVLSIM_ServiceContext = *_tvlsimServiceContext;
974 SimulationStatus& lSimulationStatus =
975 lTVLSIM_ServiceContext.getSimulationStatus();
978 std::ostringstream oStream;
979 oStream <<
"{\"done\": \""
980 << lSimulationStatus.getCurrentDate() <<
"\"}";
981 return oStream.str();
988 if (_tvlsimServiceContext == NULL) {
989 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
990 "has not been initialised");
992 assert (_tvlsimServiceContext != NULL);
996 const TRADEMGEN::TRADEMGEN_Service& lTRADEMGEN_Service =
997 lTVLSIM_ServiceContext.getTRADEMGEN_Service();
1000 SEVMGR::SEVMGR_Service& lSEVMGR_Service =
1001 lTVLSIM_ServiceContext.getSEVMGR_Service();
1005 lTVLSIM_ServiceContext.getSimulationStatus();
1007 return Simulator::initialiseBreakPoint (lTRADEMGEN_Service,
1017 if (_tvlsimServiceContext == NULL) {
1018 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
1019 "has not been initialised");
1021 assert (_tvlsimServiceContext != NULL);
1026 lTVLSIM_ServiceContext.getSimulationStatus();
1029 const stdair::Date_T& lStartDate = lSimulationStatus.
getStartDate();
1030 const stdair::Date_T& lEndDate = lSimulationStatus.
getEndDate();
1033 SIMCRS::SIMCRS_Service& lSIMCRS_Service =
1034 lTVLSIM_ServiceContext.getSIMCRS_Service();
1036 lSIMCRS_Service.initSnapshotAndRMEvents (lStartDate, lEndDate);
1039 TRADEMGEN::TRADEMGEN_Service& lTRADEMGEN_Service =
1040 lTVLSIM_ServiceContext.getTRADEMGEN_Service();
1043 Simulator::updateStatus(lTRADEMGEN_Service, stdair::EventType::RM,
1045 Simulator::updateStatus(lTRADEMGEN_Service, stdair::EventType::SNAPSHOT,
1054 if (_tvlsimServiceContext == NULL) {
1055 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
1056 "has not been initialised");
1058 assert (_tvlsimServiceContext != NULL);
1062 stdair::STDAIR_Service& lSTDAIR_Service =
1063 lTVLSIM_ServiceContext.getSTDAIR_Service();
1064 const stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
1067 return lSTDAIR_Service.csvDisplay(lBomRoot);
1074 if (_tvlsimServiceContext == NULL) {
1075 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
1076 "has not been initialised");
1078 assert (_tvlsimServiceContext != NULL);
1084 TRADEMGEN::TRADEMGEN_Service& lTRADEMGEN_Service =
1085 lTVLSIM_ServiceContext.getTRADEMGEN_Service();
1088 return lTRADEMGEN_Service.list ();
1094 listEvents (
const stdair::EventType::EN_EventType& iEventType)
const {
1097 if (_tvlsimServiceContext == NULL) {
1098 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
1099 "has not been initialised");
1101 assert (_tvlsimServiceContext != NULL);
1107 TRADEMGEN::TRADEMGEN_Service& lTRADEMGEN_Service =
1108 lTVLSIM_ServiceContext.getTRADEMGEN_Service();
1111 return lTRADEMGEN_Service.list (iEventType);
1117 list (
const stdair::AirlineCode_T& iAirlineCode,
1118 const stdair::FlightNumber_T& iFlightNumber)
const {
1121 if (_tvlsimServiceContext == NULL) {
1122 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
1123 "has not been initialised");
1125 assert (_tvlsimServiceContext != NULL);
1129 SIMCRS::SIMCRS_Service& lSIMCRS_Service =
1130 lTVLSIM_ServiceContext.getSIMCRS_Service();
1133 return lSIMCRS_Service.list (iAirlineCode, iFlightNumber);
1139 const stdair::FlightNumber_T& iFlightNumber,
1140 const stdair::Date_T& iDepartureDate)
const {
1143 if (_tvlsimServiceContext == NULL) {
1144 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
1145 "has not been initialised");
1147 assert (_tvlsimServiceContext != NULL);
1151 SIMCRS::SIMCRS_Service& lSIMCRS_Service =
1152 lTVLSIM_ServiceContext.getSIMCRS_Service();
1155 return lSIMCRS_Service.csvDisplay (iAirlineCode, iFlightNumber,
1163 if (_tvlsimServiceContext == NULL) {
1164 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
1165 "has not been initialised");
1167 assert (_tvlsimServiceContext != NULL);
1175 TRADEMGEN::TRADEMGEN_Service& lTRADEMGEN_Service =
1176 lTVLSIM_ServiceContext.getTRADEMGEN_Service();
1178 lTRADEMGEN_Service.reset();
1196 lTVLSIM_ServiceContext.getSimulationStatus();
1197 lSimulationStatus.
reset();
1203 clonePersistentBom ();
1208 void TVLSIM_Service::prepareNewRun() {
1211 if (_tvlsimServiceContext == NULL) {
1212 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
1213 "has not been initialised");
1215 assert (_tvlsimServiceContext != NULL);
1218 TVLSIM_ServiceContext& lTVLSIM_ServiceContext = *_tvlsimServiceContext;
1221 TRADEMGEN::TRADEMGEN_Service& lTRADEMGEN_Service =
1222 lTVLSIM_ServiceContext.getTRADEMGEN_Service();
1224 lTRADEMGEN_Service.reset();
1241 SimulationStatus& lSimulationStatus =
1242 lTVLSIM_ServiceContext.getSimulationStatus();
1243 lSimulationStatus.prepareNewRun();
1254 if (_tvlsimServiceContext == NULL) {
1255 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
1256 "has not been initialised");
1258 assert (_tvlsimServiceContext != NULL);
1265 lTVLSIM_ServiceContext.getSimulationStatus();
1267 return lSimulationStatus.
describe();
1275 if (_tvlsimServiceContext == NULL) {
1276 throw stdair::NonInitialisedServiceException (
"The TvlSim service has not "
1277 "been initialised");
1279 assert (_tvlsimServiceContext != NULL);
1284 lTVLSIM_ServiceContext.getSimulationStatus();
1287 SIMCRS::SIMCRS_Service& lSIMCRS_Service =
1288 lTVLSIM_ServiceContext.getSIMCRS_Service();
1291 TRADEMGEN::TRADEMGEN_Service& lTRADEMGEN_Service =
1292 lTVLSIM_ServiceContext.getTRADEMGEN_Service();
1295 TRAVELCCM::TRAVELCCM_Service& lTRAVELCCM_Service =
1296 lTVLSIM_ServiceContext.getTRAVELCCM_Service();
1299 stdair::STDAIR_Service& lSTDAIR_Service =
1300 lTVLSIM_ServiceContext.getSTDAIR_Service();
1304 const bool hasDemandGenMethodBeenRetrieved =
1305 lSTDAIR_Service.exportConfigValue<
char> (lChar,
1306 "demand generation.method");
1307 assert (hasDemandGenMethodBeenRetrieved ==
true);
1308 const stdair::DemandGenerationMethod lDemandGenerationMethod (lChar);
1321 STDAIR_LOG_DEBUG (
"Simulation[" << lCurrentRun <<
"] begins"
1322 <<
" - " << lTVLSIM_ServiceContext.display());
1325 stdair::BasChronometer lSimulationChronometer;
1326 lSimulationChronometer.start();
1328 lTRAVELCCM_Service, lSTDAIR_Service,
1329 lSimulationStatus, lDemandGenerationMethod);
1330 const double lSimulationMeasure = lSimulationChronometer.elapsed();
1334 STDAIR_LOG_DEBUG (
"Simulation[" << lCurrentRun <<
"] ends: " << lSimulationMeasure
1335 <<
" - " << lTVLSIM_ServiceContext.display());
1347 if (_tvlsimServiceContext == NULL) {
1348 throw stdair::NonInitialisedServiceException (
"The TvlSim service has not "
1349 "been initialised");
1351 assert (_tvlsimServiceContext != NULL);
1355 boost::posix_time::ptime lNowDateTime =
1356 boost::posix_time::second_clock::local_time();
1360 STDAIR_LOG_DEBUG (std::endl
1361 <<
"==================================================="
1366 stdair::BasChronometer lDsimChronometer;
1367 lDsimChronometer.start();
1370 stdair::DBSession_T& lDBSession =
1371 stdair::DBSessionManager::instance().getDBSession();
1374 stdair::AirlineStruct lAirline;
1375 stdair::DBRequestStatement_T lSelectStatement (lDBSession);
1376 stdair::DBManagerForAirlines::prepareSelectStatement (lDBSession,
1381 bool hasStillData =
true;
1382 unsigned int idx = 0;
1383 while (hasStillData ==
true) {
1385 stdair::DBManagerForAirlines::iterateOnStatement (lSelectStatement,
1389 STDAIR_LOG_DEBUG (
"[" << idx <<
"]: " << lAirline);
1395 const double lDsimMeasure = lDsimChronometer.elapsed();
1398 STDAIR_LOG_DEBUG (
"Sample service for Dsim: " << lDsimMeasure);
1405 if (_tvlsimServiceContext == NULL) {
1406 throw stdair::NonInitialisedServiceException (
"The TvlSim service "
1407 "has not been initialised");
1409 assert (_tvlsimServiceContext != NULL);
1413 stdair::STDAIR_Service& lSTDAIR_Service =
1414 lTVLSIM_ServiceContext.getSTDAIR_Service();
1417 return lSTDAIR_Service.configDisplay ();
1425 if (_tvlsimServiceContext == NULL) {
1426 throw stdair::NonInitialisedServiceException (
"The TvlSim service has not "
1427 "been initialised");
1429 assert (_tvlsimServiceContext != NULL);
1433 SIMCRS::SIMCRS_Service& lSIMCRS_Service =
1434 lTVLSIM_ServiceContext.getSIMCRS_Service();
1437 lSIMCRS_Service.optimise (iRMEvent);
1444 if (_tvlsimServiceContext == NULL) {
1445 throw stdair::NonInitialisedServiceException (
"The TvlSim service has not "
1446 "been initialised");
1448 assert (_tvlsimServiceContext != NULL);
1451 return lTVLSIM_ServiceContext.getSimulationStatus();