LAPTOP-SNT8I5JK\Boounion
2025-06-13 f6e82f09bb6fb4727da61366c195cb99f3474e49
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "stdafx.h"
#include "Common.h"
#include "Component.h"
#include "Log.h"
#include "BoounionPLC.h"
 
CComponent::CComponent()
{
    m_pChannel1 = NULL;
    m_nIndex = 0;
    m_bRunning = FALSE;
    m_pPlc = nullptr;
    InitializeCriticalSection(&m_criticalSection);
}
 
CComponent::~CComponent()
{
    DeleteCriticalSection(&m_criticalSection);
}
 
void CComponent::setPlc(CPLC* pPlc)
{
    m_pPlc = pPlc;
}
 
void CComponent::init()
{
 
}
 
void CComponent::term()
{
 
}
 
int CComponent::run()
{
    m_bRunning = TRUE;
    return 0;
}
 
int CComponent::stop()
{
    m_bRunning = FALSE;
    return 0;
}
 
void CComponent::setName(const char* pszName)
{
    m_strName = pszName;
}
 
std::string& CComponent::getName()
{
    return m_strName;
}
 
void CComponent::setDescription(const char* pszDescription)
{
    m_strDescription = pszDescription;
}
 
std::string& CComponent::getDescription()
{
    return m_strDescription;
}
 
void CComponent::setIndex(int index)
{
    m_nIndex = index;
}
 
int CComponent::getIndex()
{
    return m_nIndex;
}
 
void CComponent::onRecvBroadcast(void* pSender, CIntent* pIntent)
{
 
}
 
void CComponent::onData(int id, const void* pData, int size)
{
 
}
 
void CComponent::SendBroadcast(CIntent* pIntent)
{
    m_pPlc->sendBroadcast(this, pIntent);
}
 
int CComponent::WriteInt(int unitId, int addr, int value)
{
    return 0;// m_pBonder->writeInt(unitId, addr, value);
}
 
int CComponent::WriteData(MC::SOFT_COMPONENT softComponent, unsigned int addr,
    const char* pszData, unsigned int length, ONWRITE funOnWrite)
{
    return 0;// m_pBonder->writeData(softComponent, addr, pszData, length, funOnWrite);
}
 
void CComponent::OnTimer(UINT nTimerid)
{
 
}
 
void CComponent::Serialize(CArchive& ar)
{
 
}
 
float CComponent::toFloat(const char* pszAddr)
{
    BYTE szBuffer[4];
    szBuffer[0] = pszAddr[0];
    szBuffer[1] = pszAddr[1];
    szBuffer[2] = pszAddr[2];
    szBuffer[3] = pszAddr[3];
    float f = 0.0;
    memcpy(&f, szBuffer, 4);
 
    return f;
}