forked from PLCnext/CppExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileStreamExampleComponent.hpp
60 lines (48 loc) · 2.02 KB
/
FileStreamExampleComponent.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include "Arp/System/Core/Arp.h"
#include "Arp/System/Acf/ComponentBase.hpp"
#include "Arp/System/Acf/IApplication.hpp"
#include "Arp/Plc/Commons/Esm/ProgramComponentBase.hpp"
#include "FileStreamExampleComponentProgramProvider.hpp"
#include "Arp/Plc/Commons/Meta/MetaLibraryBase.hpp"
#include "Arp/System/Commons/Logging.h"
namespace FileStreamExample {
using namespace Arp;
using namespace Arp::System::Acf;
using namespace Arp::Plc::Commons::Esm;
using namespace Arp::Plc::Commons::Meta;
//#component
class FileStreamExampleComponent: public ComponentBase,
public ProgramComponentBase,
private Loggable<FileStreamExampleComponent> {
public: // typedefs
public: // construction/destruction
FileStreamExampleComponent(IApplication &application, const String &name);
virtual ~FileStreamExampleComponent() = default;
public: // IComponent operations
void Initialize() override;
void LoadConfig() override;
void SetupConfig() override;
void ResetConfig() override;
public: // ProgramComponentBase operations
void RegisterComponentPorts() override;
private: // methods
FileStreamExampleComponent(const FileStreamExampleComponent &arg) = delete;
FileStreamExampleComponent& operator=(const FileStreamExampleComponent &arg) = delete;
void WriteToFile(String textToWrite);
String ReadFromFile();
public: // static factory operations
static IComponent::Ptr Create(Arp::System::Acf::IApplication &application,
const String &name);
private: // fields
FileStreamExampleComponentProgramProvider programProvider;
const Arp::String filePath = "/opt/plcnext/logs/TestFile.txt";
bool newbin{false};
bool nofile{false};
public:
boolean bReset { false };
};
inline IComponent::Ptr FileStreamExampleComponent::Create(Arp::System::Acf::IApplication &application, const String &name) {
return IComponent::Ptr(new FileStreamExampleComponent(application, name));
}
} // end of namespace FileStreamExample