phaser-server  0.0.3
rfPhaser.h
Go to the documentation of this file.
1 #ifndef RF_PHASER_H
2 #define RF_PHASER_H
8 #include "phaseInterface.h"
9 #include "jobSet.h"
10 #include <thread.h>
11 #include <eventq.h>
12 class ResultsDb;
13 namespace LOCK { class EnergyLocks; }
14 
19 class RfPhaser : public PhaseInterface, public thrlib::Thread
20 { public:
21  RfPhaser(void);
22  virtual void Halt(bool) override;
23 
24  public: // PhaseInterface implementation
25  virtual void SetJob(Session &, PhaseJob *) override;
26  virtual void StopJob(Session &) override;
27  virtual void PauseJob(Session &) override;
28  virtual void ResumeJob(Session &) override;
29  virtual void SkipCavity(Session &) override;
30  virtual void GetState(Session &) override;
31  virtual std::vector<std::string> GetCavityNames(void) override;
32  virtual void PostProgress(unsigned, const std::string &) override;
33  virtual bool Peek(bool = false) override;
34  virtual void ApplyCorrections(Session &, const DbIds *) override;
35 
36  private:
38  enum class Cmd_t { C_set, C_stop, C_pause, C_resume, C_skip, C_halt, C_state,
39  C_apply };
40 
42  struct Command
43  {
46  Command(Session *client, Cmd_t type) : m_client(client), m_type(type)
47  {
48  }
49  Session *m_client;
50  const Cmd_t m_type;
51  };
52 
54  struct JobCommand : public Command
55  {
58  JobCommand(Session *client, PhaseJob *job) :
59  Command(client, Cmd_t::C_set), m_job(job)
60  {
61  }
62  PhaseJob * const m_job;
63  };
64 
66  struct ApplyCommand : public Command
67  {
70  ApplyCommand(Session *client, const DbIds *ids)
71  : Command(client, Cmd_t::C_apply), m_ids(ids)
72  {
73  }
74  const DbIds *m_ids;
75  };
76 
77  virtual void ThreadMain(void) override;
78  void MeasurePhaseError(void);
79  bool ProcessCommand(Command *);
80  std::string RemovalMessage(bool);
81  void Handle(std::exception &);
82  void PauseMeasurements(PhaseJob *);
83 
84  private:
85  JobSet m_ps;
86  thrlib::EventQueue<Command *> m_queue;
87 };
88 
89 #endif
Manage objects related the RF cavity phasing job.
Definition: jobSet.h:18
Abstract interface to RF cavity phasing.
Definition: phaseInterface.h:16
A job for processing RF cavities.
Definition: phaseJob.h:17
Log phasing job results to a database.
Definition: resultsDb.h:16
Manage phasing operations.
Definition: rfPhaser.h:20
virtual void StopJob(Session &) override
Destroy any existing RF phasing job.
Definition: rfPhaser.cpp:76
RfPhaser(void)
Construct an instance.
Definition: rfPhaser.cpp:23
virtual void SetJob(Session &, PhaseJob *) override
Set a new RF phasing job.
Definition: rfPhaser.cpp:66
virtual bool Peek(bool=false) override
Peek for client commands during phasing.
Definition: phaserThread.cpp:297
virtual void Halt(bool) override
Halt phasing operations.
Definition: rfPhaser.cpp:131
virtual void SkipCavity(Session &) override
Skip the current cavity in the RF phasing job.
Definition: rfPhaser.cpp:109
virtual void GetState(Session &) override
Get the current state of the server.
Definition: rfPhaser.cpp:119
virtual void PostProgress(unsigned, const std::string &) override
Post progress of an activity to clients.
Definition: phaserThread.cpp:320
virtual void PauseJob(Session &) override
Pause execution of the RF phasing job.
Definition: rfPhaser.cpp:87
virtual void ApplyCorrections(Session &, const DbIds *) override
Request phase corrections be applied.
Definition: rfPhaser.cpp:143
virtual void ResumeJob(Session &) override
Resume execution of the RF phasing job.
Definition: rfPhaser.cpp:98
virtual std::vector< std::string > GetCavityNames(void) override
Get the names of eligible RF cavities.
Definition: rfPhaser.cpp:48
Manage one connection session with a client.
Definition: session.h:23
Define the 'JobSet' class.
Define the RF Cavity phase job interface.