File indexing completed on 2024-05-05 05:46:08

0001 /***************************************************************************
0002  *   Copyright (C) 2003-2005 by David Saxton                               *
0003  *   david@bluehaze.org                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #ifndef PICCOMPONENT_H
0012 #define PICCOMPONENT_H
0013 
0014 #include "config.h"
0015 #ifndef NO_GPSIM
0016 
0017 #include "component.h"
0018 
0019 #include <QMap>
0020 #include <QPointer>
0021 
0022 class Document;
0023 class ECNode;
0024 class GpsimProcessor;
0025 class IOPIN;
0026 class KTechlab;
0027 class MicroInfo;
0028 class MicroPackage;
0029 class PIC_IOPORT;
0030 class PICComponent;
0031 class PICComponentPin;
0032 class PicPin;
0033 class TextDocument;
0034 
0035 typedef QMap<int, PICComponentPin *> PICComponentPinMap;
0036 
0037 /**
0038 @short Electronic PIC device
0039 @author David Saxton
0040 */
0041 class PICComponent : public Component
0042 {
0043     Q_OBJECT
0044 public:
0045     PICComponent(ICNDocument *icnDocument, bool newItem, const char *id = nullptr);
0046     ~PICComponent() override;
0047 
0048     static Item *construct(ItemDocument *itemDocument, bool newItem, const char *id);
0049     static LibraryItem *libraryItem();
0050 
0051     void buttonStateChanged(const QString &id, bool state) override;
0052     bool mouseDoubleClickEvent(const EventInfo &eventInfo) override;
0053 
0054     void programReload();
0055     /**
0056      * Sets up the pins, text, etc for the given PIC type. If info is null,
0057      * then a generic rectangle is displayed (used when no file has been
0058      * loaded yet).
0059      */
0060     void initPackage(MicroInfo *info);
0061 
0062 public slots:
0063     void slotUpdateFileList();
0064     void slotUpdateBtns();
0065 
0066 protected slots:
0067     void slotCODCreationSucceeded();
0068     void slotCODCreationFailed();
0069 
0070 protected:
0071     /**
0072      * Attaches all PICComponentPins to the current instance of gpsim.
0073      */
0074     void attachPICComponentPins();
0075     void deletePICComponentPins();
0076     /**
0077      * Attempts to compile the program to a symbol file, and connects the assembly
0078      * finish signal to loadGpsim
0079      */
0080     QString createSymbolFile();
0081     void dataChanged() override;
0082     /**
0083      * Initializes the PIC from the options the user has selected.
0084      */
0085     void initPIC(bool forceReload);
0086 
0087     QPointer<GpsimProcessor> m_pGpsim;
0088     QString m_picFile;      ///< The input program that the user selected
0089     QString m_symbolFile;   ///< The symbol file that was generated from m_picFile
0090     bool m_bLoadingProgram; ///< True between createSymbolFile being called and the file being created
0091     PICComponentPinMap m_picComponentPinMap;
0092     bool m_bCreatedInitialPackage; ///< Set true once the initial package is loaded; until then, will load a package from the lastPackage data
0093     static QString _def_PICComponent_fileName;
0094 };
0095 
0096 #endif
0097 #endif