This commit is contained in:
高云鹏 2024-12-27 13:42:22 +08:00
commit 4eba6e48d1
8 changed files with 161 additions and 20 deletions

View File

@ -967,6 +967,7 @@ BOOLEAN CHostADSBFProcess::OnTimer(void)
last_sec = system32.timers;
sec_changed = TRUE;
}
FeedDog();
if (sec_changed)
{
if (m_turbine == NULL)
@ -1021,7 +1022,6 @@ BOOLEAN CHostADSBFProcess::OnTimer(void)
}
}
readRealData();
FeedDog();
}
return TRUE;
}
@ -1032,6 +1032,7 @@ BOOLEAN CHostADSBFProcess::readFileID()
if (uid < 0 || uid >= UNIT_NUM) return TRUE;
vLog(LOG_DEBUG, "%s here read file info\n", m_pidName.c_str());
#if 0
AdsVariable <WORD> wPathInfoInvalid {*m_turbine, ".gwPathInfoInvalid"};
//vLog(LOG_DEBUG, "Read back with first value %d\n", (WORD)wPathInfoInvalid);
AdsVariable <DWORD> wCurrentFolderNo {*m_turbine, ".gwCurrentFolderNo"};
@ -1046,6 +1047,76 @@ BOOLEAN CHostADSBFProcess::readFileID()
//vLog(LOG_DEBUG, "Read back with first value %d\n", (DWORD)wFirstFolderNoRecoverable);
AdsVariable <DWORD> wFirstFileNoRecoverable {*m_turbine, ".gwFirstFileNoRecoverable"};
//vLog(LOG_DEBUG, "Read back with first value %d\n", (DWORD)wFirstFileNoRecoverable);
#else
WORD wPathInfoInvalid;
myAdsVariable myPathInfoInvalid {*m_turbine, ".gwPathInfoInvalid"};
if (!myPathInfoInvalid.Read(2, &wPathInfoInvalid))
{
delete m_turbine;
m_turbine = NULL;
return TRUE;
}
DWORD wCurrentFolderNo;
myAdsVariable myCurrentFolderNo {*m_turbine, ".gwCurrentFolderNo"};
if (!myCurrentFolderNo.Read(4, &wCurrentFolderNo))
{
vLog(LOG_ERROR, "Read .gwCurrentFolderNo error.\n");
delete m_turbine;
m_turbine = NULL;
return TRUE;
}
DWORD wCurrentFileNo;
myAdsVariable myCurrentFileNo {*m_turbine, ".gwCurrentFileNo"};
if (!myCurrentFileNo.Read(4, &wCurrentFileNo))
{
vLog(LOG_ERROR, "Read .gwCurrentFileNo error.\n");
delete m_turbine;
m_turbine = NULL;
return TRUE;
}
DWORD wFirstFileNoInFolder;
myAdsVariable myFirstFileNoInFolder {*m_turbine, ".gwFirstFileNoInFolder"};
if (!myFirstFileNoInFolder.Read(4, &wFirstFileNoInFolder))
{
vLog(LOG_ERROR, "Read .gwFirstFileNoInFolder error.\n");
delete m_turbine;
m_turbine = NULL;
return TRUE;
}
DWORD wFileCountInFolder;
myAdsVariable myFileCountInFolder {*m_turbine, ".gwFileCountInFolder"};
if (!myFileCountInFolder.Read(4, &wFileCountInFolder))
{
vLog(LOG_ERROR, "Read .gwFileCountInFolder error.\n");
delete m_turbine;
m_turbine = NULL;
return TRUE;
}
DWORD wFirstFolderNoRecoverable;
myAdsVariable myFirstFolderNoRecoverable {*m_turbine, ".gwFirstFolderNoRecoverable"};
if (!myFirstFolderNoRecoverable.Read(4, &wFirstFolderNoRecoverable))
{
vLog(LOG_ERROR, "Read .gwFirstFolderNoRecoverable error.\n");
delete m_turbine;
m_turbine = NULL;
return TRUE;
}
DWORD wFirstFileNoRecoverable;
myAdsVariable myse {*m_turbine, ".gwFirstFileNoRecoverable"};
if (!myFirstFolderNoRecoverable.Read(4, &wFirstFileNoRecoverable))
{
vLog(LOG_ERROR, "Read .gwFirstFileNoRecoverable error.\n");
delete m_turbine;
m_turbine = NULL;
return TRUE;
}
#endif
m_iv = (WORD)wPathInfoInvalid;
if (m_iv) {
@ -1099,11 +1170,14 @@ BOOLEAN CHostADSBFProcess::readRealData()
BYTE params[MAX_UNIT_POINT_PARAM_SIZE];
BYTE* pParam = params;
AdsVariable<std::array<BYTE, MAX_BLOCKF_SIZE>> turbineData {*m_turbine, ADSIGRP_IOIMAGE_RWOB, m_adsOverviewDataMemAddr};
pData = ((std::array<BYTE, MAX_BLOCKF_SIZE>)turbineData).data();
if (!m_turbine->IsConnected())
// AdsVariable<std::array<BYTE, MAX_BLOCKF_SIZE>> turbineData {*m_turbine, ADSIGRP_IOIMAGE_RWOB, m_adsOverviewDataMemAddr};
// pData = ((std::array<BYTE, MAX_BLOCKF_SIZE>)turbineData).data();
myAdsVariable turbineData {*m_turbine, ADSIGRP_IOIMAGE_RWOB, m_adsOverviewDataMemAddr};
if (!turbineData.Read(1024, buffer))
{
vLog(LOG_ERROR, "%s Read data error\n", m_pidName.c_str());
delete m_turbine;
m_turbine = NULL;
return TRUE;
}

View File

@ -9,7 +9,52 @@
#include "AdsVariable.h"
#include "RouterAccess.h"
using namespace Beckhoff::Ads;
//using namespace bhf::ads;
#include "AdsDevice.h"
namespace Beckhoff
{
namespace Ads
{
struct myAdsVariable {
myAdsVariable(const AdsDevice& route, const std::string& symbolName)
: m_Route(route),
m_IndexGroup(ADSIGRP_SYM_VALBYHND),
m_Handle(route.GetHandle(symbolName))
{}
myAdsVariable(const AdsDevice& route, const uint32_t group, const uint32_t offset)
: m_Route(route),
m_IndexGroup(group),
m_Handle(route.GetHandle(offset))
{}
BOOLEAN Read(const size_t size, void* data) const
{
if (!m_Route.IsConnected()) return FALSE;
uint32_t bytesRead = 0;
auto error = m_Route.ReadReqEx2(m_IndexGroup,
*m_Handle,
size,
data,
&bytesRead);
if (error || (size != bytesRead)) {
vLog(LOG_ERROR, "AdsVariable read failed: %d,%s\n", error, strerror(errno));
return FALSE;
}
return TRUE;
}
private:
const AdsDevice& m_Route;
const uint32_t m_IndexGroup;
const AdsHandle m_Handle;
};
}
}
typedef std::unordered_map<short, short> register2typemap;

View File

@ -44,9 +44,17 @@
<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 使用log4j2代替logback-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<!-- web 容器使用 undertow 代替 tomcat-->
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -58,8 +58,8 @@ public class TDEngineService {
config.setUsername(username);
config.setPassword(password);
config.setConnectionTestQuery("select server_status()");
config.setMinimumIdle(10); //minimum number of idle connection
config.setMaximumPoolSize(20); //maximum number of connection in the pool
config.setMinimumIdle(30); //minimum number of idle connection
config.setMaximumPoolSize(30); //maximum number of connection in the pool
config.setMaxLifetime(0); // maximum life time for each connection
// config.setIdleTimeout(0); // max idle time for recycle idle connection
log.info("=======>TDEngineUrl:" + config.getJdbcUrl());
@ -89,7 +89,7 @@ public class TDEngineService {
}
sb.append(") TAGS (`deviceid` BIGINT);");
try {
log.info(sb.toString());
log.debug(sb.toString());
pstmt.executeUpdate(sb.toString());
} catch (Exception e) {
log.error("创建超级表失败", e);
@ -111,7 +111,7 @@ public class TDEngineService {
sb.append(dataType);
sb.append(") TAGS (`deviceid` BIGINT);");
try {
log.info(sb.toString());
log.debug(sb.toString());
pstmt.executeUpdate(sb.toString());
} catch (Exception e) {
log.error("创建[计算量]超级表失败", e);
@ -426,7 +426,7 @@ public class TDEngineService {
}
try {
pstmt.executeUpdate(sb.toString());
log.info("告警信息入库:{}",sb.toString());
log.debug("告警信息入库:{}",sb.toString());
} catch (SQLException ex) {
log.error("save deviceEvent error", ex);
}

View File

@ -529,8 +529,10 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
minioViewsServcie.uploadTemFile(minioAutoProperties.getPublicBucket(), scale, scaleParent);
SysEquipmentDocs sysEquipmentDocs = new SysEquipmentDocs();
sysEquipmentDocs.setUrl(parent);
sysEquipmentDocs.setName(file.getOriginalFilename());
SysEquipmentDocs sysEquipmentDocsScale = new SysEquipmentDocs();
sysEquipmentDocsScale.setUrl(scaleParent);
sysEquipmentDocsScale.setName(file.getOriginalFilename());
result.add(sysEquipmentDocs);
result.add(sysEquipmentDocsScale);
} catch (Exception e) {

View File

@ -94,7 +94,10 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
@PostConstruct
public void init() {
//初始化高性能队列
int cpu = Runtime.getRuntime().availableProcessors();
int cpu = Runtime.getRuntime().availableProcessors() / 2;
if (cpu < 2) {
cpu = 2;
}
int bufferSize = 1024 * 4;
disruptor = new Disruptor<>(TerminalMessage::new, bufferSize, DaemonThreadFactory.INSTANCE, ProducerType.MULTI, new BlockingWaitStrategy());
//
@ -355,7 +358,7 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
// 使用 TypeReference 来指定转换目标类型
List<DeviceEventVo> list = objectMapper.convertValue(dataEvent, new TypeReference<List<DeviceEventVo>>() {
});
log.info("消息data转化deviceVo,{}", list);
log.debug("消息data转化deviceVo,{}", list);
for (DeviceEventVo item : list) {
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(Long.valueOf(item.getDeviceId()));
Integer firstTriggeredCode = adminRedisTemplate.get(String.format("RT:%s:%s", item.getDeviceId(), "FirstTriggeredCode".toLowerCase()));
@ -394,8 +397,8 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
deviceEventInfo.setEventText(item.getAttrCode() + fieldName + descList.get(1));
}
Integer level = dataService.eventLevelMap.get(model).get(item.getAttrCode());
log.info("level:{}", level);
log.info("fieldname{}", fieldName);
log.debug("level:{}", level);
log.debug("fieldname{}", fieldName);
deviceEventInfo.setEventLevel(level == null ? 0 : level);
}
} else {
@ -445,7 +448,7 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
}
ConcurrentWebSocketSessionDecorator concurrentWebSocketSessionDecorator = new ConcurrentWebSocketSessionDecorator(session, 5 * 1000, 2 * 1024 * 1024);
onlineWSSessions.put(nodeId, concurrentWebSocketSessionDecorator);
log.info("节点:{}已连接, IP: {}", nodeId, remoteIp);
//如果采集程序的版本是0则直接下发当前配置
if (version == 0) {
sendTerminalConfig(nodeId);
@ -482,7 +485,7 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
@Override
protected void handlePongMessage(WebSocketSession session, PongMessage message) throws Exception {
Long nodeId = (Long) session.getAttributes().get(NodeConstant.NODE_ID);
log.info("收到 Node:{} Pong Message", nodeId);
log.debug("收到 Node:{} Pong Message", nodeId);
session.getAttributes().put(NodeConstant.LAST_PONG_TIME, System.currentTimeMillis());
}

View File

@ -96,11 +96,18 @@ calc:
task-name:
logging:
file:
name: /das/logs/das.log
level:
com:
das: DEBUG
das: INFO
tdengine:
password: taosdata
url: jdbc:TAOS-RS://192.168.109.187:6041/das
username: root
minio:
url: http://192.168.109.187:9000
bucket: das
accessKey: das
secretKey: zaq12WSX

View File

@ -96,6 +96,8 @@ das:
key: b6967ee87b86d85a
logging:
file:
name: /das/logs/das.log
level:
root: ERROR
com: