Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
4eba6e48d1
@ -967,6 +967,7 @@ BOOLEAN CHostADSBFProcess::OnTimer(void)
|
|||||||
last_sec = system32.timers;
|
last_sec = system32.timers;
|
||||||
sec_changed = TRUE;
|
sec_changed = TRUE;
|
||||||
}
|
}
|
||||||
|
FeedDog();
|
||||||
if (sec_changed)
|
if (sec_changed)
|
||||||
{
|
{
|
||||||
if (m_turbine == NULL)
|
if (m_turbine == NULL)
|
||||||
@ -1021,7 +1022,6 @@ BOOLEAN CHostADSBFProcess::OnTimer(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
readRealData();
|
readRealData();
|
||||||
FeedDog();
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1032,6 +1032,7 @@ BOOLEAN CHostADSBFProcess::readFileID()
|
|||||||
if (uid < 0 || uid >= UNIT_NUM) return TRUE;
|
if (uid < 0 || uid >= UNIT_NUM) return TRUE;
|
||||||
|
|
||||||
vLog(LOG_DEBUG, "%s here read file info\n", m_pidName.c_str());
|
vLog(LOG_DEBUG, "%s here read file info\n", m_pidName.c_str());
|
||||||
|
#if 0
|
||||||
AdsVariable <WORD> wPathInfoInvalid {*m_turbine, ".gwPathInfoInvalid"};
|
AdsVariable <WORD> wPathInfoInvalid {*m_turbine, ".gwPathInfoInvalid"};
|
||||||
//vLog(LOG_DEBUG, "Read back with first value %d\n", (WORD)wPathInfoInvalid);
|
//vLog(LOG_DEBUG, "Read back with first value %d\n", (WORD)wPathInfoInvalid);
|
||||||
AdsVariable <DWORD> wCurrentFolderNo {*m_turbine, ".gwCurrentFolderNo"};
|
AdsVariable <DWORD> wCurrentFolderNo {*m_turbine, ".gwCurrentFolderNo"};
|
||||||
@ -1046,7 +1047,77 @@ BOOLEAN CHostADSBFProcess::readFileID()
|
|||||||
//vLog(LOG_DEBUG, "Read back with first value %d\n", (DWORD)wFirstFolderNoRecoverable);
|
//vLog(LOG_DEBUG, "Read back with first value %d\n", (DWORD)wFirstFolderNoRecoverable);
|
||||||
AdsVariable <DWORD> wFirstFileNoRecoverable {*m_turbine, ".gwFirstFileNoRecoverable"};
|
AdsVariable <DWORD> wFirstFileNoRecoverable {*m_turbine, ".gwFirstFileNoRecoverable"};
|
||||||
//vLog(LOG_DEBUG, "Read back with first value %d\n", (DWORD)wFirstFileNoRecoverable);
|
//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;
|
m_iv = (WORD)wPathInfoInvalid;
|
||||||
if (m_iv) {
|
if (m_iv) {
|
||||||
vLog(LOG_DEBUG, "路径信息无效\n");
|
vLog(LOG_DEBUG, "路径信息无效\n");
|
||||||
@ -1099,11 +1170,14 @@ BOOLEAN CHostADSBFProcess::readRealData()
|
|||||||
BYTE params[MAX_UNIT_POINT_PARAM_SIZE];
|
BYTE params[MAX_UNIT_POINT_PARAM_SIZE];
|
||||||
BYTE* pParam = params;
|
BYTE* pParam = params;
|
||||||
|
|
||||||
AdsVariable<std::array<BYTE, MAX_BLOCKF_SIZE>> turbineData {*m_turbine, ADSIGRP_IOIMAGE_RWOB, m_adsOverviewDataMemAddr};
|
// AdsVariable<std::array<BYTE, MAX_BLOCKF_SIZE>> turbineData {*m_turbine, ADSIGRP_IOIMAGE_RWOB, m_adsOverviewDataMemAddr};
|
||||||
pData = ((std::array<BYTE, MAX_BLOCKF_SIZE>)turbineData).data();
|
// pData = ((std::array<BYTE, MAX_BLOCKF_SIZE>)turbineData).data();
|
||||||
if (!m_turbine->IsConnected())
|
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());
|
vLog(LOG_ERROR, "%s Read data error\n", m_pidName.c_str());
|
||||||
|
delete m_turbine;
|
||||||
|
m_turbine = NULL;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,52 @@
|
|||||||
#include "AdsVariable.h"
|
#include "AdsVariable.h"
|
||||||
#include "RouterAccess.h"
|
#include "RouterAccess.h"
|
||||||
using namespace Beckhoff::Ads;
|
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;
|
typedef std::unordered_map<short, short> register2typemap;
|
||||||
|
|
||||||
|
10
das/pom.xml
10
das/pom.xml
@ -44,9 +44,17 @@
|
|||||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-logging</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- 使用log4j2代替logback-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||||
|
</dependency>
|
||||||
<!-- web 容器使用 undertow 代替 tomcat-->
|
<!-- web 容器使用 undertow 代替 tomcat-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -58,8 +58,8 @@ public class TDEngineService {
|
|||||||
config.setUsername(username);
|
config.setUsername(username);
|
||||||
config.setPassword(password);
|
config.setPassword(password);
|
||||||
config.setConnectionTestQuery("select server_status()");
|
config.setConnectionTestQuery("select server_status()");
|
||||||
config.setMinimumIdle(10); //minimum number of idle connection
|
config.setMinimumIdle(30); //minimum number of idle connection
|
||||||
config.setMaximumPoolSize(20); //maximum number of connection in the pool
|
config.setMaximumPoolSize(30); //maximum number of connection in the pool
|
||||||
config.setMaxLifetime(0); // maximum life time for each connection
|
config.setMaxLifetime(0); // maximum life time for each connection
|
||||||
// config.setIdleTimeout(0); // max idle time for recycle idle connection
|
// config.setIdleTimeout(0); // max idle time for recycle idle connection
|
||||||
log.info("=======>TDEngineUrl:" + config.getJdbcUrl());
|
log.info("=======>TDEngineUrl:" + config.getJdbcUrl());
|
||||||
@ -89,7 +89,7 @@ public class TDEngineService {
|
|||||||
}
|
}
|
||||||
sb.append(") TAGS (`deviceid` BIGINT);");
|
sb.append(") TAGS (`deviceid` BIGINT);");
|
||||||
try {
|
try {
|
||||||
log.info(sb.toString());
|
log.debug(sb.toString());
|
||||||
pstmt.executeUpdate(sb.toString());
|
pstmt.executeUpdate(sb.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("创建超级表失败", e);
|
log.error("创建超级表失败", e);
|
||||||
@ -111,7 +111,7 @@ public class TDEngineService {
|
|||||||
sb.append(dataType);
|
sb.append(dataType);
|
||||||
sb.append(") TAGS (`deviceid` BIGINT);");
|
sb.append(") TAGS (`deviceid` BIGINT);");
|
||||||
try {
|
try {
|
||||||
log.info(sb.toString());
|
log.debug(sb.toString());
|
||||||
pstmt.executeUpdate(sb.toString());
|
pstmt.executeUpdate(sb.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("创建[计算量]超级表失败", e);
|
log.error("创建[计算量]超级表失败", e);
|
||||||
@ -426,7 +426,7 @@ public class TDEngineService {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
pstmt.executeUpdate(sb.toString());
|
pstmt.executeUpdate(sb.toString());
|
||||||
log.info("告警信息入库:{}",sb.toString());
|
log.debug("告警信息入库:{}",sb.toString());
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
log.error("save deviceEvent error", ex);
|
log.error("save deviceEvent error", ex);
|
||||||
}
|
}
|
||||||
|
@ -529,8 +529,10 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
minioViewsServcie.uploadTemFile(minioAutoProperties.getPublicBucket(), scale, scaleParent);
|
minioViewsServcie.uploadTemFile(minioAutoProperties.getPublicBucket(), scale, scaleParent);
|
||||||
SysEquipmentDocs sysEquipmentDocs = new SysEquipmentDocs();
|
SysEquipmentDocs sysEquipmentDocs = new SysEquipmentDocs();
|
||||||
sysEquipmentDocs.setUrl(parent);
|
sysEquipmentDocs.setUrl(parent);
|
||||||
|
sysEquipmentDocs.setName(file.getOriginalFilename());
|
||||||
SysEquipmentDocs sysEquipmentDocsScale = new SysEquipmentDocs();
|
SysEquipmentDocs sysEquipmentDocsScale = new SysEquipmentDocs();
|
||||||
sysEquipmentDocsScale.setUrl(scaleParent);
|
sysEquipmentDocsScale.setUrl(scaleParent);
|
||||||
|
sysEquipmentDocsScale.setName(file.getOriginalFilename());
|
||||||
result.add(sysEquipmentDocs);
|
result.add(sysEquipmentDocs);
|
||||||
result.add(sysEquipmentDocsScale);
|
result.add(sysEquipmentDocsScale);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -94,7 +94,10 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
|
|||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
//初始化高性能队列
|
//初始化高性能队列
|
||||||
int cpu = Runtime.getRuntime().availableProcessors();
|
int cpu = Runtime.getRuntime().availableProcessors() / 2;
|
||||||
|
if (cpu < 2) {
|
||||||
|
cpu = 2;
|
||||||
|
}
|
||||||
int bufferSize = 1024 * 4;
|
int bufferSize = 1024 * 4;
|
||||||
disruptor = new Disruptor<>(TerminalMessage::new, bufferSize, DaemonThreadFactory.INSTANCE, ProducerType.MULTI, new BlockingWaitStrategy());
|
disruptor = new Disruptor<>(TerminalMessage::new, bufferSize, DaemonThreadFactory.INSTANCE, ProducerType.MULTI, new BlockingWaitStrategy());
|
||||||
//
|
//
|
||||||
@ -355,7 +358,7 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
|
|||||||
// 使用 TypeReference 来指定转换目标类型
|
// 使用 TypeReference 来指定转换目标类型
|
||||||
List<DeviceEventVo> list = objectMapper.convertValue(dataEvent, new TypeReference<List<DeviceEventVo>>() {
|
List<DeviceEventVo> list = objectMapper.convertValue(dataEvent, new TypeReference<List<DeviceEventVo>>() {
|
||||||
});
|
});
|
||||||
log.info("消息data转化deviceVo,{}", list);
|
log.debug("消息data转化deviceVo,{}", list);
|
||||||
for (DeviceEventVo item : list) {
|
for (DeviceEventVo item : list) {
|
||||||
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(Long.valueOf(item.getDeviceId()));
|
DeviceInfoCache deviceInfoCache = cacheService.getEquipmentCache().getDeviceInfoCacheById(Long.valueOf(item.getDeviceId()));
|
||||||
Integer firstTriggeredCode = adminRedisTemplate.get(String.format("RT:%s:%s", item.getDeviceId(), "FirstTriggeredCode".toLowerCase()));
|
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));
|
deviceEventInfo.setEventText(item.getAttrCode() + fieldName + descList.get(1));
|
||||||
}
|
}
|
||||||
Integer level = dataService.eventLevelMap.get(model).get(item.getAttrCode());
|
Integer level = dataService.eventLevelMap.get(model).get(item.getAttrCode());
|
||||||
log.info("level:{}", level);
|
log.debug("level:{}", level);
|
||||||
log.info("fieldname{}", fieldName);
|
log.debug("fieldname{}", fieldName);
|
||||||
deviceEventInfo.setEventLevel(level == null ? 0 : level);
|
deviceEventInfo.setEventLevel(level == null ? 0 : level);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -445,7 +448,7 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
|
|||||||
}
|
}
|
||||||
ConcurrentWebSocketSessionDecorator concurrentWebSocketSessionDecorator = new ConcurrentWebSocketSessionDecorator(session, 5 * 1000, 2 * 1024 * 1024);
|
ConcurrentWebSocketSessionDecorator concurrentWebSocketSessionDecorator = new ConcurrentWebSocketSessionDecorator(session, 5 * 1000, 2 * 1024 * 1024);
|
||||||
onlineWSSessions.put(nodeId, concurrentWebSocketSessionDecorator);
|
onlineWSSessions.put(nodeId, concurrentWebSocketSessionDecorator);
|
||||||
|
log.info("节点:{}已连接, IP: {}", nodeId, remoteIp);
|
||||||
//如果采集程序的版本是0,则直接下发当前配置。
|
//如果采集程序的版本是0,则直接下发当前配置。
|
||||||
if (version == 0) {
|
if (version == 0) {
|
||||||
sendTerminalConfig(nodeId);
|
sendTerminalConfig(nodeId);
|
||||||
@ -482,7 +485,7 @@ public class NodeMessageServiceImpl extends TextWebSocketHandler implements Node
|
|||||||
@Override
|
@Override
|
||||||
protected void handlePongMessage(WebSocketSession session, PongMessage message) throws Exception {
|
protected void handlePongMessage(WebSocketSession session, PongMessage message) throws Exception {
|
||||||
Long nodeId = (Long) session.getAttributes().get(NodeConstant.NODE_ID);
|
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());
|
session.getAttributes().put(NodeConstant.LAST_PONG_TIME, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,11 +96,18 @@ calc:
|
|||||||
task-name:
|
task-name:
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
|
file:
|
||||||
|
name: /das/logs/das.log
|
||||||
level:
|
level:
|
||||||
com:
|
com:
|
||||||
das: DEBUG
|
das: INFO
|
||||||
|
|
||||||
tdengine:
|
tdengine:
|
||||||
password: taosdata
|
password: taosdata
|
||||||
url: jdbc:TAOS-RS://192.168.109.187:6041/das
|
url: jdbc:TAOS-RS://192.168.109.187:6041/das
|
||||||
username: root
|
username: root
|
||||||
|
minio:
|
||||||
|
url: http://192.168.109.187:9000
|
||||||
|
bucket: das
|
||||||
|
accessKey: das
|
||||||
|
secretKey: zaq12WSX
|
@ -96,6 +96,8 @@ das:
|
|||||||
key: b6967ee87b86d85a
|
key: b6967ee87b86d85a
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
|
file:
|
||||||
|
name: /das/logs/das.log
|
||||||
level:
|
level:
|
||||||
root: ERROR
|
root: ERROR
|
||||||
com:
|
com:
|
||||||
|
Loading…
Reference in New Issue
Block a user