-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSWITCH.cpp
More file actions
74 lines (63 loc) · 1.37 KB
/
Copy pathSWITCH.cpp
File metadata and controls
74 lines (63 loc) · 1.37 KB
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
#include "SWITCH.h"
#include <fstream>
SWT::SWT(const GraphicsInfo& r_GfxInfo, int r_FanOut) :Gate(0, r_FanOut)
{
m_GfxInfo.x1 = r_GfxInfo.x1;
m_GfxInfo.y1 = r_GfxInfo.y1;
m_GfxInfo.x2 = r_GfxInfo.x2;
m_GfxInfo.y2 = r_GfxInfo.y2;
m_Label = "ignore";
}
void SWT::Operate()
{
//caclulate the output status as the ANDing of the two input pins
if (this->GetSelected() == true)
{
m_OutputPin.setStatus(HIGH);
}
else
m_OutputPin.setStatus(LOW);
//Add you code here
}
// Function Draw
// Draws 2-input AND gate
void SWT::Draw(Output* pOut)
{
//Call output class and pass gate drawing info to it.
pOut->DrawSWITCH(m_GfxInfo ,m_Selected);
}
void SWT::Draw(GraphicsInfo GInfo ,bool m_selected ,Output *pOut)
{
pOut->DrawSWITCH(GInfo ,m_Selected);
}
OutputPin& SWT::Get_OutputPin()
{
return m_OutputPin;
}
InputPin *SWT::Get_InputPin()
{
return 0;
}
int SWT::GetInputs()
{
return 0;
}
//returns status of outputpin
int SWT::GetOutPinStatus()
{
return m_OutputPin.getStatus();
}
//returns status of Inputpin #n
int SWT::GetInputPinStatus(int n)
{
return -1; //n starts from 1 but array index starts from 0.
}
//Set status of an input pin ot HIGH or LOW
void SWT::setInputPinStatus(int n ,STATUS s)
{
0.0;
}
void SWT::save(ofstream &file)
{
file << "Switch" << " " << ( m_GfxInfo.x1 + m_GfxInfo.x2 ) / 2 << " " << ( m_GfxInfo.y1 + m_GfxInfo.y2 ) / 2 << endl << m_Label << endl;
}