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

0001 /***************************************************************************
0002  *   Copyright (C) 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 ADDAC_H
0012 #define ADDAC_H
0013 
0014 #include "component.h"
0015 
0016 const int max_ADDAC_bits = 32;
0017 
0018 /**
0019 @author David Saxton
0020 */
0021 class ADDAC : public Component
0022 {
0023 public:
0024 public:
0025     ADDAC(ICNDocument *icnDocument, bool newItem, const char *id = nullptr);
0026     ~ADDAC() override;
0027 
0028 protected:
0029     void dataChanged() override;
0030     /**
0031      * Add / remove pins according to the number of outputs the user has requested
0032      */
0033     virtual void initPins() = 0;
0034 
0035     int m_numBits;
0036     double m_range;
0037 };
0038 
0039 /**
0040 @author David Saxton
0041  */
0042 class ADC : public ADDAC
0043 {
0044 public:
0045     ADC(ICNDocument *icnDocument, bool newItem, const char *id = nullptr);
0046     ~ADC() override;
0047 
0048     static Item *construct(ItemDocument *itemDocument, bool newItem, const char *id);
0049     static LibraryItem *libraryItem();
0050 
0051     void stepNonLogic() override;
0052     bool doesStepNonLogic() const override
0053     {
0054         return true;
0055     }
0056 
0057 protected:
0058     /**
0059      * Add / remove pins according to the number of outputs the user has requested
0060      */
0061     void initPins() override;
0062 
0063     LogicOut *m_logic[max_ADDAC_bits];
0064     ECNode *m_realNode;
0065 };
0066 
0067 /**
0068 @author David Saxton
0069  */
0070 class DAC : public ADDAC
0071 {
0072 public:
0073     DAC(ICNDocument *icnDocument, bool newItem, const char *id = nullptr);
0074     ~DAC() override;
0075 
0076     static Item *construct(ItemDocument *itemDocument, bool newItem, const char *id);
0077     static LibraryItem *libraryItem();
0078 
0079     void stepNonLogic() override;
0080     bool doesStepNonLogic() const override
0081     {
0082         return true;
0083     }
0084 
0085 protected:
0086     /**
0087      * Add / remove pins according to the number of outputs the user has requested
0088      */
0089     void initPins() override;
0090 
0091     LogicIn *m_logic[max_ADDAC_bits];
0092     VoltagePoint *m_voltagePoint;
0093 };
0094 
0095 #endif