PLCnext API Documentation  22.9.0.33
ProgramBase.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include "Arp/Plc/Commons/Esm/IProgram.hpp"
9 namespace Arp { namespace Plc { namespace Commons { namespace Esm
10 {
11 
14 class ProgramBase : public IProgram
15 {
16 private: // typedefs
17 
18 public: // construction/destruction
21  ProgramBase(const String& programName);
23  virtual ~ProgramBase(void) = default;
24 
25 public: // IProgram implementation
28  const String& GetFullName(void)const override;
31  const String& GetTaskName(void)const override;
34  void SetTaskName(const String& taskNameArg)override;
36  void SetInitialValues(void)override;
38  void AbortRequest(void)override;
40  bool IsAbortRequested(void)const override;
41 
42 public: // abstract IProgram operations
45  virtual void Execute(void) = 0;
46 
47 private: // deleted methods
48  ProgramBase(const ProgramBase& arg) = delete;
49  ProgramBase& operator=(const ProgramBase& arg) = delete;
50 
51 private: // fields
52  String programName;
53  String taskName;
54  bool abortRequested = false;
55 };
56 
58 // inline methods of class ProgramBase
59 inline ProgramBase::ProgramBase(const String& programNameArg)
60  : programName(programNameArg)
61 {
62 }
63 
64 inline const String& ProgramBase::GetFullName()const
65 {
66  return this->programName;
67 }
68 
70 {
71  // Default implementation is empty.
72  // Implement this function to set initialize values of program variables.
73 }
74 
75 inline const String& ProgramBase::GetTaskName()const
76 {
77  return this->taskName;
78 }
79 
80 inline void ProgramBase::SetTaskName(const String& value)
81 {
82  this->taskName = value;
83 }
84 
86 {
87  this->abortRequested = true;
88 }
89 
91 {
92  return this->abortRequested;
93 }
94 
95 }}}} // end of namespace Arp::Plc::Commons::Esm
Interface to implement PLC program to be executed in realtime context.
Definition: IProgram.hpp:19
This class implements the base functionality of a program.
Definition: ProgramBase.hpp:15
void SetTaskName(const String &taskNameArg) override
Set the task name in which is this program will be executed.
Definition: ProgramBase.hpp:80
bool IsAbortRequested(void) const override
Determines if this program is requested to abort.
Definition: ProgramBase.hpp:90
virtual void Execute(void)=0
Executes this program.
virtual ~ProgramBase(void)=default
Destructs this instance and frees all resouces.
ProgramBase(const String &programName)
Constructs an ProgramBase instance.
Definition: ProgramBase.hpp:59
const String & GetFullName(void) const override
Returns the program name with full namespace.
Definition: ProgramBase.hpp:64
void AbortRequest(void) override
Request a abort of program execution.
Definition: ProgramBase.hpp:85
const String & GetTaskName(void) const override
Returns the task name in which is this program will be executed.
Definition: ProgramBase.hpp:75
void SetInitialValues(void) override
Set the initial values of all containing variables of this program.
Definition: ProgramBase.hpp:69
Root namespace for the PLCnext API