ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
Scheduler.h
1/******************************************************************************
2* Copyright (c) ATTX LLC 2024. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, LLC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX, LLC.
15******************************************************************************/
16/*
17Scheduler header file
18
19Author: Alex Reynolds
20*/
21#ifndef SCHEDULER_H
22#define SCHEDULER_H
23
24#include "data_management/GraphTreeObject.h"
25#include "architecture/EventLogger.h"
26#include "architecture/TimeManager.h"
27#include "core/clockwerkerrors.h"
28
29namespace clockwerk {
30
31 class Executive;
32 class Model;
33 class Event;
34 class Monitor;
35 class Task;
36 class Construct;
37
38 /// @brief Base class implementation of the scheduler
39 ///
40 /// This class is a base implementation of scheduler. It is an empty
41 /// base class and cannot be used without implementation in a derived
42 /// child class.
43 ///
44 /// The scheduler is the engine that runs simulations and software. It
45 /// defines the sequence and method of execution for models, tasks,
46 /// monitors, and events and is tasked with their actual execution.
47 /// It also manages faults and errors arising from them.
48 class Scheduler : public GraphTreeObject {
49 public:
50 /// @brief Constructor for the scheduler.
51 /// @note Does note resolve all dependencies - executive needs to be set
52 Scheduler(Executive &executive) : exc(&executive) {create();}
53
54 /// @brief Function to set up our scheduler
55 void create();
56
57 /// @brief Function to start and configure the scheduler
58 /// @return Error code corresponding to success/failure
59 virtual int startup() {return NO_ERROR;}
60
61 /// @brief Function to step the scheduler by a single step
62 /// @return Error code corresponding to success/failure
63 virtual int step(const clockwerk::Time &step_size = clockwerk::Time(0, NSEC_MAX + 1)) {return NO_ERROR;}
64
65 /// @brief Function to run the scheduler until pre-determined end conditions
66 /// identified/calculated by the scheduler
67 /// @return Error code corresponding to success/failure
68 /// @note The scheduler MUST define stopping conditions. Otherwise, will run indefinitely
69 virtual int run() {return NO_ERROR;}
70
71 /// @brief Function to register tasks with the scheduler. Depending
72 /// on the scheduler implementation these may be unused
73 /// @param task The task to register
74 /// @param schedule_slot The slot to register the task to
75 /// @return Error code corresponding to success/failure
76 virtual int registerTask(Task* task) {return NO_ERROR;}
77
78 /// @brief Function to set the scheduler for termination
79 /// @note Does nothing by default (we don't necessarily want this)
80 /// behavior execpt in certain cases, but always want the handle
81 virtual void terminate() {}
82
83 /// @brief Function to indicate whether the scheduler is terminated
84 /// @return The termination flag status
85 /// @note Does nothing by default (we don't necessarily want this)
86 /// behavior execpt in certain cases, but always want the handle
87 virtual bool isTerminated() {return false;}
88
89 /// Event logger for debugging and key events
91 protected:
92 // Our local logging level
93 log_level_e _local_log_level = NONE;
94 };
95
96}
97
98#endif
#define NSEC_MAX
Definition Time.h:35
Base event class.
Definition Tasks.h:278
Central control mechanism to run simulations and software.
Definition Executive.h:43
Base class for object organization.
Definition GraphTreeObject.h:87
Base class implementation of the monitor.
Definition Tasks.h:212
Base class implementation of the scheduler.
Definition Scheduler.h:48
virtual int startup()
Function to start and configure the scheduler.
Definition Scheduler.h:59
virtual bool isTerminated()
Function to indicate whether the scheduler is terminated.
Definition Scheduler.h:87
void create()
Function to set up our scheduler.
Definition Scheduler.cpp:21
Executive * exc
Event logger for debugging and key events.
Definition Scheduler.h:90
virtual int run()
Function to run the scheduler until pre-determined end conditions identified/calculated by the schedu...
Definition Scheduler.h:69
Scheduler(Executive &executive)
Constructor for the scheduler.
Definition Scheduler.h:52
virtual void terminate()
Function to set the scheduler for termination.
Definition Scheduler.h:81
virtual int step(const clockwerk::Time &step_size=clockwerk::Time(0, 999999999+1))
Function to step the scheduler by a single step.
Definition Scheduler.h:63
virtual int registerTask(Task *task)
Function to register tasks with the scheduler. Depending on the scheduler implementation these may be...
Definition Scheduler.h:76
This is the base implementation of the task class.
Definition Tasks.h:68
Wrapper to manage and convert time as timespce.
Definition Time.h:45
#define NO_ERROR
Definition clockwerkerrors.h:31