Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
job.h
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21#ifndef __STUDY_JOB_AGGREGATOR_JOB_H__
22#define __STUDY_JOB_AGGREGATOR_JOB_H__
23
24#include <memory>
25
26#include <yuni/yuni.h>
27#include <yuni/core/string.h>
28#include <yuni/io/file.h>
29#include <yuni/job/job.h>
30#include <yuni/job/queue/service.h>
31
32#include "antares/solver/ts-generator/xcast/studydata.h"
33
34#include "datafile.h"
35#include "output.h"
36
37class JobFileReader final: public Yuni::Job::IJob
38{
39public:
41 using Ptr = std::shared_ptr<JobFileReader>;
42
43 enum
44 {
45 maxRows = 8800,
46 };
47
49 static bool RemainJobsToExecute();
50
51public:
53
54
59 virtual ~JobFileReader();
61
62public:
64 uint year;
72 Yuni::String path;
73
74protected:
82 virtual void onExecute() override;
83
84private:
88 bool openCSVFile();
92 bool prepareJumpTable();
93
97 bool readRawData();
98
99 void readLine(const AnyString& line, uint y);
100
101 bool storeResults();
102
104 void resizeJumpTable(uint newsize);
105
106private:
108 using TemporaryColumnData = CellData*;
110 using BufferType = Yuni::CString<65536>;
112 using JumpTable = std::vector<uint>;
113
114private:
116 BufferType buffer;
118 Yuni::IO::File::Stream pFile;
120 Yuni::String pFilename;
122 JumpTable pJumpTable;
124 bool* pVariablesOn;
126 uint pDataOffset;
128 TemporaryColumnData* pTmpResults;
130 uint pLineCount;
131
132}; // class JobFileReader
133
135extern Yuni::Job::QueueService queueService;
136
137#include "job.hxx"
138
139#endif // __STUDY_JOB_AGGREGATOR_JOB_H__
std::shared_ptr< DataFile > Ptr
The most suitable smart pointer.
Definition datafile.h:34
Definition job.h:38
uint year
The current year (zero-based)
Definition job.h:64
std::shared_ptr< JobFileReader > Ptr
The most suitable smart pointer.
Definition job.h:41
JobFileReader()
Default constructor.
Definition job.cpp:45
static bool RemainJobsToExecute()
Get if some jobs remain.
Definition job.cpp:40
StudyData::Ptr studydata
Study data.
Definition job.h:70
virtual void onExecute() override
Execute the job.
Definition job.cpp:73
Output::Ptr output
Output.
Definition job.h:68
Yuni::String path
Path.
Definition job.h:72
DataFile::Ptr datafile
Data file.
Definition job.h:66
virtual ~JobFileReader()
Destructor.
Definition job.cpp:54
std::shared_ptr< Output > Ptr
The most suitable smart pointer.
Definition output.h:36
std::shared_ptr< StudyData > Ptr
The most suitable smart pointer.
Definition studydata.h:34