summaryrefslogtreecommitdiffstats
path: root/src/electronics/components/piccomponent.h
blob: d5e668de2967a0edf53e2b3afbf5ea14a96e38eb (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
87
88
89
90
91
92
93
94
95
96
97
98
/***************************************************************************
 *   Copyright (C) 2003-2005 by David Saxton                               *
 *   david@bluehaze.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 PICCOMPONENT_H
#define PICCOMPONENT_H

#include "config.h"
#ifndef NO_GPSIM

#include "component.h"

#include <tqguardedptr.h>
#include <tqmap.h>

class Document;
class ECNode;
class GpsimProcessor;
class IOPIN;
class KTechlab;
class MicroInfo;
class MicroPackage;
class PIC_IOPORT;
class PICComponent;
class PICComponentPin;
class PicPin;
class TextDocument;

typedef TQMap< int, PICComponentPin * > PICComponentPinMap;

/**
@short Electronic PIC device
@author David Saxton
*/
class PICComponent : public Component
{
	Q_OBJECT
  TQ_OBJECT
	public:
		PICComponent( ICNDocument * icnDocument, bool newItem, const char *id = 0L );
		~PICComponent();
	
		virtual bool canFlip() const { return true; }
		static Item * construct( ItemDocument *itemDocument, bool newItem, const char *id );
		static LibraryItem * libraryItem();
	
		virtual void buttonStateChanged( const TQString &id, bool state );
		virtual bool mouseDoubleClickEvent( const EventInfo &eventInfo );
	
		void programReload();
		/**
		 * Sets up the pins, text, etc for the given PIC type. If info is null,
		 * then a generic rectangle is displayed (used when no file has been
		 * loaded yet).
		 */
		void initPackage( MicroInfo * info );
	
	public slots:
		void slotUpdateFileList();
		void slotUpdateBtns();
	
	protected slots:
		void slotCODCreationSucceeded();
		void slotCODCreationFailed();
	
	protected:
		/**
		 * Attaches all PICComponentPins to the current instance of gpsim.
		 */
		void attachPICComponentPins();
		void deletePICComponentPins();
		/**
		 * Attempts to compile the program to a symbol file, and connects the assembly
		 * finish signal to loadGpsim
		 */
		TQString createSymbolFile();
		virtual void dataChanged();
		/**
		 * Initializes the PIC from the options the user has selected.
		 */
		void initPIC( bool forceReload );
	
		TQGuardedPtr<GpsimProcessor> m_pGpsim;
		TQString m_picFile; ///< The input program that the user selected
		TQString m_symbolFile; ///< The symbol file that was generated from m_picFile
		bool m_bLoadingProgram; ///< True between createSymbolFile being called and the file being created
		PICComponentPinMap m_picComponentPinMap;
		bool m_bCreatedInitialPackage; ///< Set true once the initial package is loaded; until then, will load a package from the lastPackage data
};

#endif
#endif