summaryrefslogtreecommitdiffstats
path: root/src/progs/gpsim/base/gpsim.h
blob: 4a618c808311f7cf5bd1c21232923277663dc934 (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/***************************************************************************
 *   Copyright (C) 2006 Nicolas Hadacek <[email protected]>                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/
#ifndef GPSIM_H
#define GPSIM_H

#include "common/common/version_data.h"
#include "progs/base/prog_specific.h"
#include "common/global/process.h"
#include "common/global/purl.h"

namespace GPSim
{
//-----------------------------------------------------------------------------
class Process : public ::Process::LineOutput, public Log::Base
{
TQ_OBJECT
  
public:
  Process(Log::Base *base);

private slots:
  void stdoutDataReceivedSlot();

private:
  bool _ready;

  virtual void addStdoutLine(const TQString &line);

  friend class ProcessManager;
};

//-----------------------------------------------------------------------------
class ProcessManager : public Log::Base
{
public:
  ProcessManager(Log::Base *base);
  Process &process() { return _process; }
  bool isReady() const { return _process._ready; }
  bool start();
  bool runSynchronously();
  bool sendCommand(const TQString &cmd, bool synchronous);
  bool sendSignal(uint n, bool synchronous);
  bool getVersion(VersionData &version);

private:
  Process _process;
};

//-----------------------------------------------------------------------------
class Hardware : public Programmer::Hardware
{
public:
  Hardware(::Programmer::Base &base) : Programmer::Hardware(base, 0, TQString()), _manager(0) {}
  virtual ~Hardware();
  bool isReady() const { return _manager->isReady(); }
  bool execute(const TQString &command, bool synchronous, TQStringList *output = 0);
  bool signal(uint n, bool synchronous, TQStringList *output = 0);
  const VersionData &version() const { return _version; }

private:
  ProcessManager *_manager;
  VersionData _version;

  virtual bool internalConnectHardware();
  virtual void internalDisconnectHardware();
};

//-----------------------------------------------------------------------------
class DeviceSpecific : public ::Programmer::DeviceSpecific
{
public:
  DeviceSpecific(::Programmer::Base &base) : ::Programmer::DeviceSpecific(base) {}
  virtual bool setPowerOff() { return false; }
  virtual bool setPowerOn() { return false; }
  virtual bool setTargetPowerOn(bool) { return true; }
};

} // namespace

#endif