152 lines
2.9 KiB
C++
152 lines
2.9 KiB
C++
|
#include "stdafx.h"
|
|||
|
|
|||
|
#include "BlockIn.h"
|
|||
|
|
|||
|
#include "math.h"
|
|||
|
|
|||
|
#define PIN_RADIUS 8 //Pin<69>b<EFBFBD>|
|
|||
|
|
|||
|
#define GOLD RGB (255, 215, 0) //Pin<69>}<7D>C<EFBFBD><43>
|
|||
|
|
|||
|
#define NO_VALUE -10 //<2F><><EFBFBD>s<EFBFBD>b<EFBFBD><62><EFBFBD>J<EFBFBD>T<EFBFBD><54>
|
|||
|
#define NO_INPUT_FLAG -12 //<2F><><EFBFBD>s<EFBFBD>b<EFBFBD><62><EFBFBD>J<EFBFBD>i<EFBFBD><69>
|
|||
|
|
|||
|
#define ZERO 0 //FALSE flag
|
|||
|
#define ONE 1 //TRUE flag
|
|||
|
#define SIN 2 //Sin flag
|
|||
|
#define COS 3 //Cos flag
|
|||
|
|
|||
|
#define DIGITAL_VALUE 4 //<2F>Ʀ<EFBFBD><C6A6>T<EFBFBD><54>flag
|
|||
|
#define ANALOG_VALUE 5 //<2F><><EFBFBD><EFBFBD><EFBFBD>T<EFBFBD><54>flag
|
|||
|
|
|||
|
#define BLK_IN 1 //Block<63><6B><EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><73>
|
|||
|
|
|||
|
CBlockIn::CBlockIn ()
|
|||
|
{
|
|||
|
m_rcPinOut = CRect ();
|
|||
|
m_iInputFlag = NO_INPUT_FLAG;
|
|||
|
m_dBlkValue = NO_VALUE;
|
|||
|
}
|
|||
|
|
|||
|
CBlockIn::~CBlockIn ()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void CBlockIn::SetBlkRect (CPoint ptCenter, int iWidth, int iHeight)
|
|||
|
{
|
|||
|
CBlockBasis::SetBlkRect (ptCenter, iWidth, iHeight);
|
|||
|
|
|||
|
m_rcPinOut.left = m_rcBlk.CenterPoint ().x - PIN_RADIUS;
|
|||
|
m_rcPinOut.top = m_rcBlk.CenterPoint ().y + int (m_rcBlk.Height () / 2) - PIN_RADIUS;
|
|||
|
m_rcPinOut.right = m_rcBlk.CenterPoint ().x + PIN_RADIUS;
|
|||
|
m_rcPinOut.bottom = m_rcBlk.CenterPoint ().y + int (m_rcBlk.Height () / 2) + PIN_RADIUS;
|
|||
|
}
|
|||
|
|
|||
|
CRect CBlockIn::GetPinOutRect () const
|
|||
|
{
|
|||
|
return m_rcPinOut;
|
|||
|
}
|
|||
|
|
|||
|
int CBlockIn::GetInputFlag() const
|
|||
|
{
|
|||
|
return m_iInputFlag;
|
|||
|
}
|
|||
|
|
|||
|
void CBlockIn::SetInputFlag(int iInputFlag)
|
|||
|
{
|
|||
|
m_iInputFlag = iInputFlag;
|
|||
|
}
|
|||
|
|
|||
|
double CBlockIn::GetBlkValue () const
|
|||
|
{
|
|||
|
return m_dBlkValue;
|
|||
|
}
|
|||
|
|
|||
|
//<2F>ΥH<CEA5>]<5D>w<EFBFBD><77><EFBFBD>w<EFBFBD>ɶ<EFBFBD><C9B6>I<EFBFBD>UBlock<63><6B> (Sin, Cos)
|
|||
|
void CBlockIn::SetBlkValue (double dTime)
|
|||
|
{
|
|||
|
switch (m_iInputFlag)
|
|||
|
{
|
|||
|
case ZERO:
|
|||
|
m_dBlkValue = 0.;
|
|||
|
break;
|
|||
|
case ONE:
|
|||
|
m_dBlkValue = 1.;
|
|||
|
break;
|
|||
|
case SIN:
|
|||
|
m_dBlkValue = sin (dTime);
|
|||
|
break;
|
|||
|
case COS:
|
|||
|
m_dBlkValue = cos (dTime);
|
|||
|
break;
|
|||
|
default:
|
|||
|
m_dBlkValue = NO_VALUE;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//<2F>]<5D>wBlock<63><6B> (TRUE, FALSE)
|
|||
|
void CBlockIn::SetBlkValue ()
|
|||
|
{
|
|||
|
switch (m_iInputFlag)
|
|||
|
{
|
|||
|
case ZERO:
|
|||
|
m_dBlkValue = 0.;
|
|||
|
break;
|
|||
|
case ONE:
|
|||
|
m_dBlkValue = 1.;
|
|||
|
break;
|
|||
|
default:
|
|||
|
m_dBlkValue = NO_VALUE;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
int CBlockIn::GetValueFlag () const
|
|||
|
{
|
|||
|
switch (m_iInputFlag)
|
|||
|
{
|
|||
|
case ZERO: //<2F><><EFBFBD>J<EFBFBD>i<EFBFBD>ά<EFBFBD>TRUE<55>ɡA<C9A1>^<5E>ǼƦ<C7BC><C6A6>T<EFBFBD><54>
|
|||
|
return DIGITAL_VALUE;
|
|||
|
break;
|
|||
|
case ONE: //<2F><><EFBFBD>J<EFBFBD>i<EFBFBD>ά<EFBFBD>FALSE<53>ɡA<C9A1>^<5E>ǼƦ<C7BC><C6A6>T<EFBFBD><54>
|
|||
|
return DIGITAL_VALUE;
|
|||
|
break;
|
|||
|
case SIN: //<2F><><EFBFBD>J<EFBFBD>i<EFBFBD>ά<EFBFBD>SIN<49>ɡA<C9A1>^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>T<EFBFBD><54>
|
|||
|
return ANALOG_VALUE;
|
|||
|
break;
|
|||
|
case COS: //<2F><><EFBFBD>J<EFBFBD>i<EFBFBD>ά<EFBFBD>COS<4F>ɡA<C9A1>^<5E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>T<EFBFBD><54>
|
|||
|
return ANALOG_VALUE;
|
|||
|
break;
|
|||
|
default:
|
|||
|
return NO_VALUE;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void CBlockIn::Move (CPoint ptCursor)
|
|||
|
{
|
|||
|
CBlockBasis::Move (ptCursor);
|
|||
|
|
|||
|
m_rcPinOut.left = m_rcBlk.CenterPoint ().x - PIN_RADIUS;
|
|||
|
m_rcPinOut.top = m_rcBlk.bottom - PIN_RADIUS;
|
|||
|
m_rcPinOut.right = m_rcBlk.CenterPoint ().x + PIN_RADIUS;
|
|||
|
m_rcPinOut.bottom = m_rcBlk.bottom + PIN_RADIUS;
|
|||
|
}
|
|||
|
|
|||
|
void CBlockIn::Draw (CDC* pDC)
|
|||
|
{
|
|||
|
CBrush brushPin (GOLD), * pbrushOld;
|
|||
|
pbrushOld = pDC->SelectObject (&brushPin);
|
|||
|
pDC->Ellipse (m_rcPinOut);
|
|||
|
pDC->SelectObject (pbrushOld);
|
|||
|
|
|||
|
CBlockBasis::Draw (pDC);
|
|||
|
pDC->DrawTextA (_T ("IN"), -1, &m_rcBlk, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
|
|||
|
}
|
|||
|
|
|||
|
int CBlockIn::BlkTypeIs () const
|
|||
|
{
|
|||
|
return BLK_IN;
|
|||
|
}
|