summaryrefslogtreecommitdiffstats
path: root/src/progs/manager/prog_manager.h
blob: 11f7401570a5a0c06697dba1559a190f4cef56f9 (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
/***************************************************************************
 *   Copyright (C) 2005-2006 Nicolas Hadacek <hadacek@kde.org>             *
 *   Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr>           *
 *                                                                         *
 *   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 PROG_MANAGER_H
#define PROG_MANAGER_H

#include <qobject.h>

#include "common/global/log.h"
namespace Device { class Data; class Memory; class MemoryRange; }
namespace Port { class Description; }

namespace Programmer
{
class Base;
class Group;
class HardwareDescription;

class Manager : public QObject, public Log::Base
{
Q_OBJECT
public:
  Manager(QObject *parent);
  virtual ~Manager();
  ::Programmer::Base *programmer() { return _programmer; }
  virtual void createProgrammer(const Device::Data *data) = 0;
  bool initProgramming(bool debugging);
  void endProgramming();
  void clear();
  void stop();
  bool program(const Device::Memory &memory, const Device::MemoryRange &range);
  bool verify(const Device::Memory &memory, const Device::MemoryRange &range);
  bool read(Device::Memory &memory, const Device::MemoryRange &range);
  bool erase(const Device::MemoryRange &range);
  bool blankCheck(const Device::MemoryRange &range);
  bool setDevicePower(bool on);
  enum State { Idle, Programming };
  virtual void setState(State state) = 0;

public slots:
  bool connectDevice();
  bool disconnectDevice();
  bool run();
  bool halt();
  bool restart();
  bool step();

signals:
  void actionMessage(const QString &message);
  void showProgress(bool show);
  void setTotalProgress(uint steps);
  void setProgress(uint steps);

protected:
  ::Programmer::Base *_programmer;

  virtual const Group &group() const = 0;
  virtual bool internalInitProgramming(bool debugging);
  virtual const Device::Data *device() const = 0;
  virtual bool isTargetSelfPowered() const;
  virtual void createProgrammer(const Device::Data *data, const HardwareDescription &hd);
};

extern Manager *manager;

} // namespace

#endif