summaryrefslogtreecommitdiffstats
path: root/src/progs/gpsim/base/gpsim.h
blob: fcdababa91706d0c515ed62ea3d2ab671c056698 (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 <hadacek@kde.org>                  *
 *                                                                         *
 *   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
{
Q_OBJECT
  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