修改传输文件图层问题等
This commit is contained in:
parent
79aa69e731
commit
5e3acea558
@ -139,6 +139,7 @@ void BaseClient::InsertMp(void* startPtr, size_t count, const string& suff) {
|
||||
void BaseClient::UpdateData(const ReadData& msg) {
|
||||
|
||||
for (auto start = msg.its.begin(); start != msg.its.end(); ++start) {
|
||||
if (m_baseMp.find(start->nameKey) == m_baseMp.end()) continue;
|
||||
if (start->valueType == iFLOAT) {
|
||||
float val = (float)atof(start->strValue.data());
|
||||
m_baseMp[start->nameKey]->SetValue(val);
|
||||
|
@ -28,6 +28,9 @@ void DataHandle::Init() {
|
||||
m_controller->Init();
|
||||
|
||||
SetPushMsg(VERSIONREQ); //获取版本信息
|
||||
|
||||
stream::ResponseInfo* response = new stream::ResponseInfo(); //获取一层图层的数据
|
||||
m_streamClient->GetLayerByIndex(1, response);
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
if (m_streamClient) {
|
||||
WriteData msg;
|
||||
msg.dataType = dataType;
|
||||
msg.valueType = DATATYPE::UNKNOW;
|
||||
m_streamClient->SetPushMsg(msg);
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,13 @@ enum READTYPE {
|
||||
INITERRORINFOSRSP, //返回初始化错误信息
|
||||
VERSIONRSP, //返回版本信息
|
||||
IOSIGNALRSP, //io信号返回数据
|
||||
SYSPARAMDATA, //系统参数数据
|
||||
SYSPARAMDATA, //
|
||||
LASERCHILLER, //冷水机参数
|
||||
UPSPARAM, //ups参数
|
||||
TEMPCTRLPARAM, //TempCtrl参数
|
||||
OXYGENPARAM, //测氧参数
|
||||
|
||||
POWERMETERPARAM, //
|
||||
|
||||
LASERPARAM1, //激光1参数
|
||||
LASERPARAM2, //激光2参数
|
||||
@ -40,16 +44,11 @@ enum READTYPE {
|
||||
SIMPLESUPPLYPARAM_V22, //供应参数v2.2
|
||||
|
||||
PURIFIERPARAM, //冷水机参数
|
||||
POWERPARAM, //
|
||||
POWERPARAM, //电能参数
|
||||
CHILLERPARAM, //冷却器参数
|
||||
TEMPCTRLPARAM, //温控参数
|
||||
|
||||
OXYGENPARAM, //测氧参数
|
||||
POWDERSUPPLYSIMPLEPARAM, //
|
||||
UPSPARAM, //
|
||||
SCANNERPOWERPARAM, //
|
||||
POWERMETERPARAM, //
|
||||
|
||||
SCANNERPOWERPARAM, //ScannerPower 参数
|
||||
|
||||
};
|
||||
|
||||
|
@ -20,13 +20,13 @@ StreamClient::~StreamClient() {
|
||||
if (m_connectTd.joinable()) {
|
||||
m_connectTd.join();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void StreamClient::Init() {
|
||||
m_localIp = LocalAddr().GetSystemIpAddress();
|
||||
std::string target_str = m_localIp +":"+ std::to_string(m_port);
|
||||
m_stubTwo = Stream::NewStub(grpc::CreateChannel(target_str, grpc::InsecureChannelCredentials()));
|
||||
m_channelTwo = grpc::CreateChannel(target_str, grpc::InsecureChannelCredentials());
|
||||
m_stubTwo = Stream::NewStub(m_channelTwo);
|
||||
|
||||
m_connectTd = std::thread([this]() {
|
||||
this->AllStream();
|
||||
@ -108,3 +108,16 @@ void StreamClient::AllStream() {
|
||||
}
|
||||
|
||||
|
||||
bool StreamClient::GetLayerByIndex(int index, ::stream::ResponseInfo* response){
|
||||
// 初始化 gRPC
|
||||
std::string targetStr = m_localIp + ":" + std::to_string(m_port);
|
||||
std::unique_ptr<Stream::Stub> _stub = Stream::NewStub(grpc::CreateChannel(targetStr, grpc::InsecureChannelCredentials()));
|
||||
|
||||
ClientContext context;
|
||||
::stream::RequestInfo request;
|
||||
request.set_datatype(LAYERDATAREQ);
|
||||
request.set_strvalue(std::to_string(index));
|
||||
request.set_valuetype((stream::TYPE)iINT);
|
||||
Status status = _stub->Simple(&context, request, response);
|
||||
return status.ok();
|
||||
}
|
@ -30,11 +30,14 @@ public:
|
||||
}
|
||||
|
||||
void SetPushMsg(const WriteData& msg);
|
||||
bool GetLayerByIndex(int index, ::stream::ResponseInfo* response);
|
||||
private:
|
||||
bool GetPushMsg(WriteData& msg);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Stream::Stub> m_stubTwo;
|
||||
std::unique_ptr<Stream::Stub> m_stubTwo; //双端流使用
|
||||
std::shared_ptr<grpc::Channel> m_channelTwo;
|
||||
std::unique_ptr<Stream::Stub> m_stub; //请求 回复使用
|
||||
std::string m_localIp;
|
||||
int m_port; //服务端口
|
||||
DataCallBack m_dataCallBack;
|
||||
|
@ -19,6 +19,9 @@ public:
|
||||
|
||||
void Init();
|
||||
|
||||
virtual void InitSignal(SignalStateWrapper* ssw, void* cc) = 0;
|
||||
virtual void InitSysParam(SysParamWrapper* spw, void* cc) = 0;
|
||||
|
||||
void SetAxisAndSignal(SysParamWrapper* sysParamWrapper, AxisRecordWrapper* axisRecordWrapper/*, PLCAxis* axis*/)
|
||||
{
|
||||
m_SysParamWrapper = sysParamWrapper;
|
||||
|
@ -11,7 +11,7 @@ SysParam::SysParam(int addr, int num, void* cc,const string& context, const std:
|
||||
, m_context(context)
|
||||
, m_code(code)
|
||||
{
|
||||
InitializeCriticalSection(&m_ValueCS);
|
||||
|
||||
}
|
||||
|
||||
SysParam::~SysParam()
|
||||
@ -23,7 +23,6 @@ SysParam::~SysParam()
|
||||
}
|
||||
m_sysParamMp.clear();
|
||||
|
||||
DeleteCriticalSection(&m_ValueCS);
|
||||
}
|
||||
|
||||
SysParam::SysParam(SysParam* sp) /*:PLCCommand(sp->m_Receiver)*/
|
||||
|
@ -20,6 +20,14 @@ public:
|
||||
int GetAddr() { return m_Addr; }
|
||||
string GetCode() { return m_code; }
|
||||
|
||||
static void SInit() {
|
||||
InitializeCriticalSection(&m_ValueCS);
|
||||
}
|
||||
|
||||
static void SFini() {
|
||||
DeleteCriticalSection(&m_ValueCS);
|
||||
}
|
||||
|
||||
static void Lck() {
|
||||
EnterCriticalSection(&m_ValueCS);
|
||||
}
|
||||
|
@ -28,17 +28,22 @@ Controller::~Controller() {
|
||||
DELP(m_Machine);
|
||||
DELP(m_MachineCfg);
|
||||
|
||||
|
||||
SysParam::SFini();
|
||||
|
||||
}
|
||||
|
||||
bool Controller::Init() {
|
||||
SysParam::SInit();
|
||||
|
||||
m_StateCtrlWrapper = new StateCtrlWrapper();
|
||||
m_SysParamWrapper = new SysParamWrapper();
|
||||
m_AxisRecordWrapper = new AxisRecordWrapper();
|
||||
m_SignalStateWrapper = new SignalStateWrapper();
|
||||
ConfigManager::Instance()->Init();
|
||||
m_Machine = ConfigManager::Instance()->GetMachine();
|
||||
m_Machine->InitSignal(m_SignalStateWrapper, nullptr);
|
||||
m_Machine->InitSysParam(m_SysParamWrapper, nullptr);
|
||||
|
||||
m_Machine->SetAxisAndSignal(m_SysParamWrapper, m_AxisRecordWrapper);
|
||||
m_MachineCfg = ConfigManager::Instance()->GetMachineCfg();
|
||||
|
||||
|
@ -57,8 +57,6 @@ public:
|
||||
ChartletManager::GetInstance()->Init();
|
||||
g_LngManager->Init();
|
||||
|
||||
|
||||
|
||||
DataHandle::Instance()->Init();
|
||||
|
||||
m_win = new UIWin();
|
||||
|
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
#include "Command.h"
|
||||
#include "snap7/s7_micro_client.h"
|
||||
#include <vector>
|
||||
@ -55,8 +55,10 @@ public:
|
||||
int GetRequestSequence(unsigned char* bseq){return 0;}
|
||||
bool Verify(unsigned char* rseq,int dlength){return true;}
|
||||
|
||||
TS7DataItem* getDataItems(){return m_dataItems;};
|
||||
unsigned int getItemCount(){return m_itemCount;};
|
||||
TS7DataItem* getDataItems(){
|
||||
return m_dataItems;
|
||||
}
|
||||
unsigned int getItemCount(){return m_itemCount;}
|
||||
public:
|
||||
|
||||
//boost::function<void(void*,TS7DataItem* m_dataItems,int itemcount)> m_s7fun;
|
||||
|
@ -113,6 +113,7 @@ void Controller::Init(){
|
||||
}
|
||||
m_Purifier->Init();
|
||||
|
||||
m_jobController.StartLoadPrepareJob();
|
||||
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,8 @@ void ClientWrapper::OfflineCheck() {
|
||||
auto client = m_clientList.begin();
|
||||
while (client != m_clientList.end()) {
|
||||
if (!(*client)->IsConnect()) {
|
||||
printf("%s 下线了...\n", (*client)->m_clientAddr.c_str());
|
||||
size_t pos = (*client)->m_clientAddr.find_first_of(':');
|
||||
printf("\n%s 下线了...\n", (*client)->m_clientAddr.substr(pos + 1).c_str());
|
||||
delete (*client);
|
||||
client = m_clientList.erase(client);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
auto lst = m_msgList.begin();
|
||||
while (lst != m_msgList.end()) {
|
||||
delete (*lst);
|
||||
++lst;
|
||||
}
|
||||
m_msgList.clear();
|
||||
}
|
||||
|
@ -11,14 +11,16 @@ void DataHandle::DataCallBackProc(void* pthis, const ReadData& msg) {
|
||||
void DataHandle::LayersDataCallBackProc(void* pthis,const ReadData& msg, ::stream::LayerData** response) {
|
||||
DataHandle* p = (DataHandle*)pthis;
|
||||
int index = atoi(msg.strValue.data());
|
||||
int size = p->m_controller->m_jobController.GetJob()->GetMetaData()->GetLayersVec().size();
|
||||
|
||||
|
||||
int size = (int)p->m_controller->m_jobController.m_PrepareJob->GetMetaData()->GetLayersVec().size();
|
||||
if (!p || index<1 || index>(int)size) return;
|
||||
p->m_controller->m_jobController.GetJob()->GetMetaData()->GetLayerByIndex(index-1,response);
|
||||
p->m_controller->m_jobController.m_PrepareJob->GetMetaData()->GetLayerByIndex(index-1,response);
|
||||
}
|
||||
|
||||
DataHandle::DataHandle()
|
||||
: m_dataCallBack(nullptr)
|
||||
, m_streamServer(nullptr)
|
||||
: /*m_dataCallBack(nullptr)
|
||||
,*/ m_streamServer(nullptr)
|
||||
, m_config(nullptr)
|
||||
, m_controller(nullptr)
|
||||
, m_testFlag(false){
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
static void DataCallBackProc(void* pthis, const ReadData& msg);
|
||||
static void LayersDataCallBackProc(void* pthis, const ReadData& msg,::stream::LayerData** response);
|
||||
private:
|
||||
DataCallBack m_dataCallBack;
|
||||
//DataCallBack m_dataCallBack;
|
||||
std::thread m_testTd;
|
||||
|
||||
ConfigManager* m_config;
|
||||
|
@ -90,6 +90,7 @@ enum WRITETYPE {
|
||||
|
||||
INITERRORINFOSRSP, //返回初始化错误信息
|
||||
VERSIONRSP, //返回版本信息
|
||||
IOSIGNALRSP, //io信号返回数据
|
||||
SYSPARAMDATA, //
|
||||
LASERCHILLER, //冷水机参数
|
||||
UPSPARAM, //ups参数
|
||||
@ -115,8 +116,12 @@ enum WRITETYPE {
|
||||
SIMPLESUPPLYPARAM_V21, //供应参数v2.1
|
||||
SIMPLESUPPLYPARAM_V22, //供应参数v2.2
|
||||
|
||||
SCANNERPOWERPARAM,
|
||||
PURIFIERPARAM, //冷水机参数
|
||||
POWERPARAM, //电能参数
|
||||
CHILLERPARAM, //冷却器参数
|
||||
|
||||
POWDERSUPPLYSIMPLEPARAM, //
|
||||
SCANNERPOWERPARAM, //ScannerPower 参数
|
||||
|
||||
};
|
||||
|
||||
|
@ -18,7 +18,7 @@ StreamServer::~StreamServer() {
|
||||
}
|
||||
|
||||
|
||||
//回复后连接中断
|
||||
//回复后连接中断 请求打印文件层
|
||||
::grpc::Status StreamServer::Simple(::grpc::ServerContext* context, const ::stream::RequestInfo* request, ::stream::LayerData* response) {
|
||||
|
||||
ReadData readData;
|
||||
@ -41,7 +41,7 @@ Status StreamServer::AllStream(ServerContext* context, grpc::ServerReaderWriter<
|
||||
|
||||
string addr = context->peer();
|
||||
size_t pos = addr.find_first_of(':');
|
||||
printf("%s client login...\n", addr.substr(pos+1).c_str());
|
||||
printf("\n%s client login...\n", addr.substr(pos+1).c_str());
|
||||
cinfo->m_clientAddr = context->peer();
|
||||
cinfo->m_context = context;
|
||||
ClientWrapper::Instance()->AddClient(cinfo);
|
||||
|
@ -55,7 +55,6 @@ void HBDSystem::GetVersion()
|
||||
string strVersion;
|
||||
::GetModuleFileName(NULL, cPath, sizeof(cPath));
|
||||
InfoSize = GetFileVersionInfoSize(cPath, &dwHandle);
|
||||
printf("version:%d\n", GetLastError());
|
||||
if (InfoSize == 0L) return;
|
||||
unsigned char* InfoBuf = new unsigned char[InfoSize];
|
||||
GetFileVersionInfo(cPath, 0, InfoSize, InfoBuf); //获得生成文件使用的代码页及文件版本
|
||||
@ -86,10 +85,9 @@ void HBDSystem::GetVersion()
|
||||
|
||||
|
||||
void HBDSystem::Usage() {
|
||||
printf("print service usage:\n");
|
||||
printf(" r(run):start run...\n");
|
||||
printf(" s(stop):stop run...\n");
|
||||
printf(" e(exit):exit program...\n");
|
||||
printf(" h(help):print this information...\n");
|
||||
|
||||
printf(COLOR_GREEN "print service usage:\n" COLOR_RESET);
|
||||
printf(" r(run): " COLOR_YELLOW "start run...\n" COLOR_RESET);
|
||||
printf(" s(stop): " COLOR_YELLOW "stop run...\n" COLOR_RESET);
|
||||
printf(" e(exit): " COLOR_YELLOW "exit program...\n" COLOR_RESET);
|
||||
printf(" h(help): " COLOR_YELLOW "print help information...\n" COLOR_RESET);
|
||||
}
|
@ -8,6 +8,10 @@
|
||||
#include <map>
|
||||
#include <conio.h>
|
||||
|
||||
// 假设你的系统支持ANSI颜色代码
|
||||
#define COLOR_RESET "\033[0m"
|
||||
#define COLOR_GREEN "\033[32m"
|
||||
#define COLOR_YELLOW "\033[33m"
|
||||
|
||||
class HBDSystem {
|
||||
public:
|
||||
|
@ -129,7 +129,8 @@ void SysParamWord::SetValue(short value)
|
||||
{
|
||||
S7WordData sword;
|
||||
sword.wValue = value;
|
||||
unsigned char* pv = (unsigned char*)m_CtrlCommand->getDataItems()[0].pdata;
|
||||
TS7DataItem* gg = m_CtrlCommand->getDataItems();
|
||||
unsigned char* pv = (unsigned char*)gg[0].pdata;
|
||||
pv[0] = sword.data[1];
|
||||
pv[1] = sword.data[0];
|
||||
//short* pv =(short*) m_CtrlCommand->getDataItems()[0].pdata;
|
||||
@ -215,7 +216,8 @@ void SysParamInt::SetValue(int value)
|
||||
{
|
||||
S7DWordData sdw;
|
||||
sdw.iValue = value;
|
||||
unsigned char* pv = (unsigned char*)m_CtrlCommand->getDataItems()[0].pdata;
|
||||
TS7DataItem* gg = m_CtrlCommand->getDataItems();
|
||||
unsigned char* pv = (unsigned char*)gg[0].pdata;
|
||||
pv[0] = sdw.data[3];
|
||||
pv[1] = sdw.data[2];
|
||||
pv[2] = sdw.data[1];
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
#include "FileProcessor.h"
|
||||
#include "H3DMetaData.h"
|
||||
|
||||
@ -11,7 +11,8 @@ public:
|
||||
int Process(string jobfile);
|
||||
int GetCurrentLayerIndex(void) { return GetLayerIndex(m_MetaData.GetCurrentLayer()); }
|
||||
int GetPreviewLayerIndex(void) { return GetLayerIndex(m_MetaData.GetPreviewLayer()); }
|
||||
MetaData* GetMetaData() { return &m_MetaData; }
|
||||
MetaData* GetMetaData() {
|
||||
return &m_MetaData; }
|
||||
string GetJobTitle() { return m_MetaData.GetJobTitle(); }
|
||||
string GetMaterialName() { return m_MetaData.GetMaterial(); }
|
||||
double GetLayerThickness() { return *m_MetaData.GetLayerThickness(); }
|
||||
|
@ -162,13 +162,13 @@ bool H3DMetaData::GetLayerByIndex(unsigned int lindex, ::stream::LayerData** res
|
||||
|
||||
stream::LayerDataBlock* p = (*response)->add_layerdatablock();
|
||||
p->set_order(datablocks[i]->order);
|
||||
p->set_blocktype(m_block_map[datablocks[i]]->type);
|
||||
size_t count = m_block_map[datablocks[i]]->point_indexs.size();
|
||||
p->set_blocktype(pbindb->type);
|
||||
size_t count = pbindb->point_indexs.size();
|
||||
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
if (p->blocktype() == BIN_VECTOR) {
|
||||
stream::VectorDataBlock* pvec = p->add_vecblocks();
|
||||
BPBinary::VectorPoint* vecp = (BPBinary::VectorPoint*)(m_block_map[datablocks[i]]->point_indexs[i]);
|
||||
BPBinary::VectorPoint* vecp = (BPBinary::VectorPoint*)(pbindb->point_indexs[i]);
|
||||
pvec->set_startx(vecp->x1);
|
||||
pvec->set_endx(vecp->y1);
|
||||
pvec->set_starty(vecp->x2);
|
||||
@ -176,7 +176,7 @@ bool H3DMetaData::GetLayerByIndex(unsigned int lindex, ::stream::LayerData** res
|
||||
}
|
||||
else if (p->blocktype() == BIN_CHAIN) {
|
||||
stream::ChainDataBlock* pChain = p->add_chainblocks();
|
||||
BPBinary::ChainPoint* chainp = (BPBinary::ChainPoint*)(m_block_map[datablocks[i]]->point_indexs[i]);
|
||||
BPBinary::ChainPoint* chainp = (BPBinary::ChainPoint*)(pbindb->point_indexs[i]);
|
||||
|
||||
pChain->set_dotnum(chainp->num_of_point);
|
||||
for (unsigned int chainPointIndex = 0; chainPointIndex < chainp->num_of_point; ++chainPointIndex) {
|
||||
|
@ -40,8 +40,9 @@ void JobController::StartLoadPrepareJob()
|
||||
DWORD WINAPI JobController::LoadPrepareJobProc(JobController* _this) {
|
||||
if (!_this)return 0;
|
||||
char buffer[512];
|
||||
MachineCfg* mcfg = ConfigManager::GetInstance()->GetMachineCfg();
|
||||
sprintf_s(buffer, sizeof(buffer), "%sPrepareJob/%d.h3d", g_AppPath.c_str(), mcfg->m_MachineType);
|
||||
//MachineCfg* mcfg = ConfigManager::GetInstance()->GetMachineCfg();
|
||||
//sprintf_s(buffer, sizeof(buffer), "%sPrepareJob/%d.h3d", g_AppPath.c_str(), mcfg->m_MachineType);
|
||||
sprintf_s(buffer, sizeof(buffer), "D://jobfile//bigmodel_name.h3d");
|
||||
H3DFileProcessor* fp = new H3DFileProcessor();
|
||||
if (fp->Process(buffer) != BP_SUCCESS)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
#include "../stdafx.h"
|
||||
#include <list>
|
||||
#include "JobFileProcessor.h"
|
||||
@ -27,7 +27,8 @@ public:
|
||||
|
||||
void RemoveJob(string job_title);
|
||||
void RemoveAllJob();
|
||||
FileProcessor* GetJob(void) { return m_CurrentJob; }
|
||||
FileProcessor* GetJob(void) {
|
||||
return m_CurrentJob; }
|
||||
FileProcessor* GetUnFinishedJob();
|
||||
float GetLoadProgress();
|
||||
string GetLoadInfo();
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user