📄 run_object_check.cpp
字号:
#include "stdafx.h"
#include "PLC_DEMO.h"
#include "PLC_DEMODoc.h"
#include "PLC_DEMOView.h"
#include "Fetch_communicate.h"
#include "Makesure_in_out_point.h"
#include "Draw_function.h"
bool sensorshow1;
bool sensorshow2;
bool sensorshow3;
bool tranenable;
bool goodsarrive;
int goods[20];
int goodssign;
bool canclearwaster;
bool downthewaster;
int wasterplace;
int qualitygoodsplace;
int goodskind[6];
int thegoodsplace;
bool downqualitygoods;
bool waitup;
bool thesensor3true;
bool canaddplace;
bool cancleargoods;
bool canshow1;
bool canshow2;
extern bool WR[1000];
extern int forobjectcheckinput[5];
extern int forobjectcheckoutput[2];
extern int signinput[8];
extern int signoutput[10];
extern CPLC_DEMOView *forrun;
void clearpart(int,int,int,int,CBrush*,CDC*);
void drawround(int,int,int,int,CDC*);
void object_check_startset()
{
canaddplace=true;
downqualitygoods=false;
thegoodsplace=415;
thesensor3true=false;
waitup=true;
downthewaster=false;
sensorshow1=false;
sensorshow2=false;
sensorshow3=false;
tranenable=true;
goodsarrive=false;
canshow1=true;
canshow2=true;
cancleargoods=false;
canclearwaster=true;
wasterplace=215;
qualitygoodsplace=195;
goods[0]=0; goods[1]=0;goods[2]=0;goods[3]=1;
goods[4]=0;goods[5]=0;goods[6]=0;goods[7]=0;
goods[8]=0;goods[9]=0;goods[10]=0;goods[11]=1;
goods[12]=1;goods[13]=0;goods[14]=0;goods[15]=1;
goods[16]=0;goods[17]=0;goods[18]=1;goods[19]=0;
goodssign=0;
for (int i=0;i<6;i++)
goodskind[i]=2;
}
void object_check_outresult()
{
CDC *thisDC=forrun->GetDC();
CPen blackpen(PS_SOLID,1,RGB(0,0,0));
CPen redpen(PS_SOLID,1,RGB(255,0,0));
CBrush blackbrush(RGB(0,0,0));
CBrush redbrush(RGB(255,0,0));
CPen *oldpen=thisDC->SelectObject(&blackpen);
CBrush *oldbrush=thisDC->SelectObject(&blackbrush);
CBrush nobrush;
nobrush.CreateSysColorBrush(COLOR_3DFACE);
thisDC->SetBkMode(TRANSPARENT);
if(((signinput[forobjectcheckinput[3]])
&&(tranenable))&&(signinput[forobjectcheckinput[4]]))
{
tranenable=false;
forrun->SetTimer(17,1000,NULL);
}
if(!signoutput[forobjectcheckoutput[1]])
{
canaddplace=true;
tranenable=true;
forrun->KillTimer(17);
forrun->KillTimer(20);
}
if(!signinput[forobjectcheckinput[4]])
drawround(350,200,10,10,thisDC);
if(!signoutput[forobjectcheckoutput[1]])
drawround(350,160,10,10,thisDC);
if(goodsarrive)
{
if(canaddplace)
{
canaddplace=false;
forrun->SetTimer(20,50,NULL);
}
goodsarrive=false;
signinput[forobjectcheckinput[1]]=true;
}
else
signinput[forobjectcheckinput[1]]=false;
if(signinput[forobjectcheckinput[1]])
{
if(goodskind[4]==1)
forrun->SetTimer(25,100,NULL);
goodskind[4]=2;
if (goodskind[2]==0)
goodskind[2]=2;
goodssign+=1;
if (goodssign==20)
goodssign=0;
for(int i=5;i>=1;i--)
goodskind[i]=goodskind[i-1];
if (!goods[goodssign])
{
goodskind[0]=1;
signinput[forobjectcheckinput[0]]=false;
}
else
{
goodskind[0]=0;
signinput[forobjectcheckinput[0]]=true;
}
thegoodsplace=415;
}
else
signinput[forobjectcheckinput[0]]=false;
if(signinput[forobjectcheckinput[0]])
sensorshow1=true;
if(!sensorshow1)
drawround(510,75,10,10,thisDC);
if(signinput[forobjectcheckinput[1]])
sensorshow2=true;
if ((sensorshow2)&&(canshow1))
{
canshow1=false;
forrun->SetTimer(18,200,NULL);
}
if(!sensorshow2)
drawround(350,240,10,10,thisDC);
if(thesensor3true)
{
thesensor3true=false;
signinput[forobjectcheckinput[2]]=true;
}
else
signinput[forobjectcheckinput[2]]=false;
if((sensorshow3)&&(canshow2))
{
canshow2=false;
forrun->SetTimer(19,200,NULL);
}
if(!sensorshow3)
drawround(380,350,10,10,thisDC);
if(!signinput[forobjectcheckinput[3]])
drawround(320,60,10,10,thisDC);
if(cancleargoods)
{
cancleargoods=false;
clearpart(540,176,150,13,&nobrush,thisDC);
for(int i=0;i<6;i++)
{
if(goodskind[i]==1)
{
thisDC->MoveTo(thegoodsplace+i*43,189);
thisDC->LineTo(thegoodsplace+i*43,164);
thisDC->LineTo(thegoodsplace+25+i*43,164);
thisDC->LineTo(thegoodsplace+25+i*43,189);
CString ss;
ss.Format("正");
thisDC->TextOut(thegoodsplace+5+i*43,170,ss);
}
else if(goodskind[i]==0)
{
thisDC->MoveTo(thegoodsplace+i*43,189);
thisDC->LineTo(thegoodsplace+i*43,164);
thisDC->LineTo(thegoodsplace+25+i*43,164);
thisDC->LineTo(thegoodsplace+25+i*43,189);
CString ss;
ss.Format("次");
thisDC->TextOut(thegoodsplace+5+i*43,170,ss);
}
}
}
clearpart(545,280,25,69,&nobrush,thisDC);
if(downthewaster)
{
thisDC->MoveTo(535,wasterplace);
thisDC->LineTo(560,wasterplace);
thisDC->LineTo(560,wasterplace+25);
thisDC->LineTo(535,wasterplace+25);
thisDC->LineTo(535,wasterplace);
CString ss;
ss.Format("次");
thisDC->TextOut(540,wasterplace+6,ss);//物品
}
thisDC->MoveTo(510,330);
thisDC->LineTo(610,330);
clearpart(680,260,28,90,&nobrush,thisDC);
clearpart(650,189,10,1,&nobrush,thisDC);
if(downqualitygoods)
{
thisDC->MoveTo(660,qualitygoodsplace);
thisDC->LineTo(685,qualitygoodsplace);
thisDC->LineTo(685,qualitygoodsplace+25);
thisDC->LineTo(660,qualitygoodsplace+25);
thisDC->LineTo(660,qualitygoodsplace);
CString ss;
ss.Format("正");
thisDC->TextOut(665,qualitygoodsplace+6,ss);
}
thisDC->MoveTo(630,350);
thisDC->LineTo(660,330);
thisDC->LineTo(760,330);
thisDC->SelectObject(&redpen);
thisDC->SelectObject(&redbrush);
if(sensorshow1)
drawround(510,75,10,10,thisDC);
if(sensorshow2)
drawround(350,240,10,10,thisDC);
if(sensorshow3)
drawround(380,350,10,10,thisDC);
if(signinput[forobjectcheckinput[3]])
drawround(320,60,10,10,thisDC);
if(signinput[forobjectcheckinput[4]])
drawround(350,200,10,10,thisDC);
if(signoutput[forobjectcheckoutput[1]])
drawround(350,160,10,10,thisDC);
CPen blackpen1(PS_SOLID,4,RGB(0,0,0));
thisDC->SelectObject(&blackpen1);
if(!signoutput[forobjectcheckoutput[0]])
{
waitup=true;
thisDC->MoveTo(525,214);
thisDC->LineTo(543,214);
thisDC->MoveTo(568,214);
thisDC->LineTo(550,214);
}
else
{
if(canclearwaster)
{
forrun->SetTimer(23,10,NULL);
downthewaster=true;
canclearwaster=false;
}
thisDC->MoveTo(525,214);
thisDC->LineTo(525,232);
thisDC->MoveTo(568,214);
thisDC->LineTo(568,232);
}
if(signinput[forobjectcheckinput[2]])
{
sensorshow3=true;
canclearwaster=true;
wasterplace=215;
}
thisDC->SelectObject(oldpen);
thisDC->SelectObject(oldbrush);
forrun->ReleaseDC(thisDC);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -