runshiyan.cpp
来自「开发虚拟的被控对象及虚拟的PLC,模似PLC的工作过程进行实验。用户可根据具体的」· C++ 代码 · 共 116 行
CPP
116 行
#include "stdafx.h"
#include "PLC_DEMO.h"
#include "PLC_DEMODoc.h"
#include "PLC_DEMOView.h"
#include "Fetch_communicate.h"
extern CPLC_DEMOView *forrun;
extern int signoutput[10];
extern int signinput[8];
bool weigh=false;
bool canjin=true,canjia=true;
bool leveldao=false;
bool canding=true;
int xx=1;
void outtheresult()
{
if(signoutput[1])
forrun->GetDlgItem(IDC_EXITSWITCH2)->SetWindowText(
"on");
else forrun->GetDlgItem(IDC_EXITSWITCH2)->SetWindowText(
"off");
if(signoutput[2])
forrun->GetDlgItem(IDC_LUMP1)->SetWindowText(
"on");
else forrun->GetDlgItem(IDC_LUMP1)->SetWindowText(
"off");
if(signoutput[3])
forrun->GetDlgItem(IDC_LUMP2)->SetWindowText(
"on");
else forrun->GetDlgItem(IDC_LUMP2)->SetWindowText(
"off");
if(signoutput[4])
forrun->GetDlgItem(IDC_ELECTROMOTOR1)->SetWindowText(
"on");
else forrun->GetDlgItem(IDC_ELECTROMOTOR1)->SetWindowText(
"off");
if(signoutput[5])
forrun->GetDlgItem(IDC_ELECTROMOTOR2)->SetWindowText(
"on");
else forrun->GetDlgItem(IDC_ELECTROMOTOR2)->SetWindowText(
"off");
if(signoutput[6])
forrun->GetDlgItem(IDC_ELECTROMOTOR3)->SetWindowText(
"on");
else forrun->GetDlgItem(IDC_ELECTROMOTOR3)->SetWindowText(
"off");
if(signoutput[7])
forrun->GetDlgItem(IDC_EXITSWITCH1)->SetWindowText(
"on");
else forrun->GetDlgItem(IDC_EXITSWITCH1)->SetWindowText(
"off");
if (!leveldao)
{
signinput[2]=0;
forrun->GetDlgItem(IDC_SENSOR1)->SetWindowText(
"off");
}
else
{
signinput[2]=1;
forrun->GetDlgItem(IDC_SENSOR1)->SetWindowText(
"on");
}
if(signoutput[1]==1)
leveldao=false;
if(((!leveldao)&&(!signoutput[1]))&&(canding))
{
forrun->SetTimer(13,4000,NULL);
canding=false;
}
BOOL mm;
mm=forrun->GetDlgItem(IDC_CAR)->IsWindowVisible();
if((mm==FALSE)&&(canjin))
{
forrun->SetTimer(10,5000,NULL);
canjin=false;
signinput[1]=0;
}
if(mm==FALSE)
{
forrun->GetDlgItem(IDC_SENSOR2)->SetWindowText(
"off");
forrun->GetDlgItem(IDC_SWITCH1)->SetWindowText(
"off");
signinput[1]=0;
}
if((mm==TRUE)&&(!weigh))
{
forrun->GetDlgItem(IDC_SWITCH1)->SetWindowText(
"on");
signinput[1]=1;
if((signoutput[1]==1)&&(canjia))
{
forrun->SetTimer(11,12000,NULL);
canjia=false;
}
}
else if(mm==TRUE)
{
forrun->GetDlgItem(IDC_SWITCH1)->SetWindowText(
"off");
signinput[1]=0;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?