⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dwmain.cpp

📁 vb直流系统上位机测试软件,直流电力监控系统源码。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <owl\dc.h>
#include <owl\button.h>
#include <owl\static.h>
#include <owl\edit.h>
#include <owl\color.h>
#include <owl\dialog.h>
#include <owl\groupbox.h>
#include <owl\radiobut.h>
#include <owl\printer.h>
#include <classlib\file.h>
#include <fstream.h>
#include <string.h>
#include <iostream.h>
#include <dos.h>
#include <io.h>
#include <stdio.h>
#include <time.h>

#include "main.h"
#include "control.h"
#include "xlampapp.h"
#include "xlamprun.h"
#include "dlampapp.h"
#include "dlamprun.h"

//static unsigned char z3_buf[256]={0xff,0xff,0x14,0xfd,0x83,0x0a,0,0,0,1,0,0,0,1,0,5,0x6e};

//static unsigned char z3_send[256]={0xff,0xff,0x14,0xfd,0x83,0x0a,0,0,9,0,0,0,5,0,0x0b,0,0x5c};    //use for chang

//(1)on #1 lamp
//static unsigned char z3_send[256]={0xff,0xff,0x14,0xfd,0x81,0x10,0,0,9,0,0,0,2,0,0,1,0,0,0,1,0,0,0x64};

//(2)off #1 lamp
//static unsigned char z3_send[256]={0xff,0xff,0x14,0xfd,0x81,0x10,0,0,9,0,0,0,2,0,1,1,0,0,0,1,0,0,0x63};

//(3)flash #1 lamp
//static unsigned char z3_send[256]={0xff,0xff,0x14,0xfd,0x81,0x10,0,0,9,0,0,0,2,0,2,1,0,0,0,1,0,0,0x62};

//(4)on #2 lamp
//static unsigned char z3_send[256]={0xff,0xff,0x14,0xfd,0x81,0x10,0,0,9,0,0,0,2,0,0,2,0,0,0,2,0,0,0x62};

//(5)off #2 lamp
//static unsigned char z3_send[256]={0xff,0xff,0x14,0xfd,0x81,0x10,0,0,9,0,0,0,2,0,1,2,0,0,0,2,0,0,0x61};

//(6)flash #2 lamp
//static unsigned char z3_send[256]={0xff,0xff,0x14,0xfd,0x81,0x10,0,0,9,0,0,0,2,0,2,2,0,0,0,2,0,0,0x60};

//(7)on #0 group lamp
//static unsigned char z3_send[256]={0xff,0xff,0x14,0xfd,0x81,0x10,0,0,9,0,0,0,2,0,3,1,0,0,0,1,0,0,0x64};

//(8)off #0 group lamp
//static unsigned char z3_send[256]={0xff,0xff,0x14,0xfd,0x81,0x10,0,0,9,0,0,0,2,0,4,1,0,0,0,1,0,0,0x64};

//(9)flash #0 group lamp
//static unsigned char z3_send[256]={0xff,0xff,0x14,0xfd,0x81,0x10,0,0,9,0,0,0,2,0,5,1,0,0,0,1,0,0,0x64};

//inspect 0# ---5# status
//static unsigned char z3_send[256]={0xff,0xff,0x14,0xfd,0x83,0x0a,0,0,9,0,0,0,0,0,5,0,0x67};    //use for chang

// static unsigned char z3_send[256]={0xff,0xff,0x14,0xfd,0x83,0x0a,0,0,1,0,0,0,0,0,5,0,0x6f}; //use for yang
//static unsigned char z3_send[256]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};

static unsigned char SendInspect[]={0xff,0xff,0x14,0xfd,0x83,0x0a,0,0,9,0,0,0,0,0,5,0,0x67};    //use for chang
static unsigned char Control_data[]={0xff,0xff,0x14,0xfd,0x81,0x10,0,0,9,0,0,0,2,0,0,1,0,0,0,1,0,0,0x64};
static unsigned char Parts_Data[]={0xff,0xff,0x14,0xfd,0x81,0x10,0,0,9,0,0,0,2,0,3,1,0,0,0,1,0,0,0x64};
static unsigned char BackControl[]={0xff,0xff,0x27,0xfd,0x81,0x07,0x01,0x00,0x00,0x00,0x7e,0x00,0xff,0x00};
static unsigned char LampData[]={0xff,0xff,0x27,0x07,0x83,0x2a,0x00,0x0a,
											0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,
											0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,
											0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x06,
											0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x08,
											0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x0a,
											0x00};

void _export WINAPI Mydelay(unsigned int mili_second);
extern void WINAPI InitInterrupt(void);
extern void WINAPI InitData(unsigned long *buf,unsigned long *flag);
extern void WINAPI Init_Num();
extern void WINAPI Get_Leng(unsigned int *temp);

unsigned char Visit_data[17]={0xff,0xff,0x14,0x00,0x83,0x0a,0x00,0x00,0x01,
										0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00};
unsigned char tControl_data[]={0xff,0xff,0x14,0xfd,0x81,0x10,0x00,0x00,0x01,
										0x00,0x00,0x00,0x02,0x00,0x0a,0x00,0x00,0x00,
										0x00,0x00,0x00,0x01,0x00};
int PressData[45];
int slampOn=0,slampOff=0;
int plampOn=0,plampOff=0;
int slampflash=0,plampflash=0;
char SingleLampNumber=0;
char PartsLampNumber1=0;
char PartsLampNumber2=0;
int gj=0;
int dw=2,cs=0;
DEFINE_RESPONSE_TABLE1(TMainWindow, TDialog)
// EV_COMMAND(IDC_PUSHBUTTON2,WestApp),
 EV_COMMAND(IDC_PUSHBUTTON11,WestRun),
// EV_COMMAND(IDC_PUSHBUTTON4,EastApp),
// EV_COMMAND(IDC_PUSHBUTTON5,EastRun),
 EV_COMMAND(IDC_PUSHBUTTON8,EastRun),
 EV_COMMAND(IDC_PUSHBUTTON6,LampSingleControl),
 EV_COMMAND(IDC_PUSHBUTTON9,LampPartsControl),
 EV_COMMAND(IDC_PUSHBUTTON1,QuitSystem),
 EV_WM_TIMER,
 EV_WM_MOUSEMOVE,
END_RESPONSE_TABLE;

TMainWindow::TMainWindow(TWindow* parent)
 : TDialog(parent, 1)
{
  ed1=new TEdit(this,IDC_EDIT17,10);
  ed2=new TEdit(this,IDC_EDIT18,10);
  ed3=new TEdit(this,IDC_EDIT1,10);
  ed4=new TEdit(this,IDC_EDIT19,10);
  ReCount=0;
  TrCount=0;
  BadCount=0;
  SendNumber=0;
  Lamp0Station=5;
  Lamp1Station=5;
  Lamp2Station=5;
  Lamp3Station=5;
  Lamp4Station=5;
  Lamp5Station=5;
  dw=2,cs=0;
}
void TMainWindow::SetupWindow()
{
  TDialog::SetupWindow();
	InitInterrupt();//通信初始化
	outportb(0x3fc,0x09);

  SetTimer(IDC_TIMER1,1000);
  SetTimer(IDC_TIMER2,500);
  SetTimer(IDC_TIMER3,1000);

}
TMainWindow::~TMainWindow()
{
  KillTimer(IDC_TIMER1);
  KillTimer(IDC_TIMER2);
  KillTimer(IDC_TIMER3);
 
}
void TMainWindow::EvMouseMove(UINT, TPoint& point)
 {
  TClientDC dc(*this);
  char k[10];
  wsprintf(k,"[%d,%d]",point.x,point.y);
  dc.TextOut(0,0,k);
 }
void WINAPI MydelaY(unsigned int mili_second)
{
  unsigned  int i;
  long  int j;
  for(i=0;i<mili_second;i++)
			for(j=0;j<13043;j++);
}
void TMainWindow::QuitSystem()
{
  exit(IDC_PUSHBUTTON1);
}
void TMainWindow::WestApp()
{
 TXLampAppDialog XAppDialog=TXLampAppDialog(this,4,0);
		XAppDialog.Execute();
}
void TMainWindow::WestRun()
{
 TXLampRunDialog XRunDialog=TXLampRunDialog(this,5,0);
		XRunDialog.Execute();
}
void TMainWindow::EastApp()
{
 TDLampAppDialog DAppDialog=TDLampAppDialog(this,6,0);
		DAppDialog.Execute();
}
void TMainWindow::EastRun()
{
 TDLampRunDialog DAppDialog=TDLampRunDialog(this,7,0);
		DAppDialog.Execute();
}
void TMainWindow::LampSingleControl()
{
  TSingleLampControlDialog SOnDialog=TSingleLampControlDialog(this,2,0);
		SOnDialog.Execute();
}
void TMainWindow::LampPartsControl()
{
 TPartsLampControlDialog POnDialog=TPartsLampControlDialog(this,3,0);
		POnDialog.Execute();
}
void TMainWindow::DrawLampStation()
{
  int n1=5,n2=7,n3=9;   //列
  int m1=3,m2=3,m3=3;   //行
  TClientDC dc(*this);
  TBrush brush=TBrush(TColor::LtGray);
  dc.SelectObject(brush);
  TPen pen=TPen(TColor(0,255,0));
  dc.SelectObject(pen);
  dc.SetTextColor(TColor(0,180,0));
 //   dc.SetBkColor(TColor(0,128,128));
//  dc.FillRect(0,0,645,485,TColor(0,128,128));
	int BeginH=90,BeginZ=70;
	int LampRadi=2,Zzb=0,Hzb=0;
	for (int xa1=1;xa1<=15;xa1++)
	 {
		Zzb=0;
	 for (int xa2=1;xa2<=5;xa2++)
	  {
		Zzb+=10;
	 //display #1 lamp's station
	  if ((xa1==n1)&&(Lamp1Station==0)&&(xa2==m1)) //bad
		 {
			BadCount++;
			TPen pen=TPen(TColor(255,0,0));
			dc.SelectObject(pen);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
		  continue;
		 }
	  if ((xa1==n1)&&(Lamp1Station==1)&&(xa2==m1))//on
		 {
			TPen pen=TPen(TColor(0,255,0));
			dc.SelectObject(pen);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
			 continue;
		 }
	  if ((xa1==n1)&&(Lamp1Station==2)&&(xa2==m1)) //off
		 {
			TPen pen=TPen(TColor(0,0,0));
			dc.SelectObject(pen);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
			 continue;
		 }
	  if ((xa1==n1)&&(Lamp1Station==3)&&(xa2==m1))//flash
		 {
			TPen pen=TPen(TColor(0,255,0));
			dc.SelectObject(pen);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
			 MydelaY(200);
			TPen pen1=TPen(TColor(120,120,120));
			dc.SelectObject(pen1);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
			MydelaY(200);
			TPen pen2=TPen(TColor(0,255,0));
			dc.SelectObject(pen2);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);

			continue;
		 }
	  //display #1 lamp's station
	 //display #2 lamp's station
	  if ((xa1==n2)&&(Lamp2Station==0)&&(xa2==m2)) //bad
		 {
			BadCount++;
			TPen pen=TPen(TColor(255,0,0));
			dc.SelectObject(pen);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
		  continue;
		 }
	  if ((xa1==n2)&&(Lamp2Station==1)&&(xa2==m2))//on
		 {
			TPen pen=TPen(TColor(0,255,0));
			dc.SelectObject(pen);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
			 continue;
		 }
	  if ((xa1==n2)&&(Lamp2Station==2)&&(xa2==m2)) //off
		 {
			TPen pen=TPen(TColor(0,0,0));
			dc.SelectObject(pen);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
			 continue;
		 }
	  if ((xa1==n2)&&(Lamp2Station==3)&&(xa2==m2))//flash
		 {
			TPen pen=TPen(TColor(0,255,0));
			dc.SelectObject(pen);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
			 MydelaY(200);
			TPen pen1=TPen(TColor(120,120,120));
			dc.SelectObject(pen1);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
			MydelaY(200);
			TPen pen2=TPen(TColor(0,255,0));
			dc.SelectObject(pen2);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);

			continue;
		 }
	 //display #2 lamp's station
	 //display #3 lamp's station
	  if ((xa1==n3)&&(Lamp3Station==0)&&(xa2==m3)) //bad
		 {
			BadCount++;
			TPen pen=TPen(TColor(255,0,0));
			dc.SelectObject(pen);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
		  continue;
		 }
	  if ((xa1==n3)&&(Lamp3Station==1)&&(xa2==m3))//on
		 {
			TPen pen=TPen(TColor(0,255,0));
			dc.SelectObject(pen);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
			 continue;
		 }
	  if ((xa1==n3)&&(Lamp3Station==2)&&(xa2==m3)) //off
		 {
			TPen pen=TPen(TColor(0,0,0));
			dc.SelectObject(pen);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
			 continue;
		 }
	  if ((xa1==n3)&&(Lamp3Station==3)&&(xa2==m3))//flash
		 {
			TPen pen=TPen(TColor(0,255,0));
			dc.SelectObject(pen);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
			 MydelaY(200);
			TPen pen1=TPen(TColor(120,120,120));
			dc.SelectObject(pen1);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
			MydelaY(200);
			TPen pen2=TPen(TColor(0,255,0));
			dc.SelectObject(pen2);
			dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
			dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);

			continue;
		 }
	 //display #3 lamp's station
		TPen pen=TPen(TColor(0,255,0));
		dc.SelectObject(pen);
		dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
		dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);

			  };
	  Hzb+=30;
	 };
	 wsprintf(ls1,"%d ",BadCount);
	 ed3->SetText(ls1);
	 BadCount=0;
/*	 BeginZ=120;Zzb=0,Hzb=0;
	for (int xa3=1;xa3<=15;xa3++)
	 {
		Zzb=0;
	 for (int xa4=1;xa4<=5;xa4++)
	  {
		Zzb+=6;
		dc.MoveTo(BeginH+Hzb,BeginZ+Zzb);
		dc.Arc(BeginH-LampRadi+Hzb,BeginZ-LampRadi+Zzb,BeginH+LampRadi+Hzb,BeginZ+LampRadi+Zzb,
				 BeginH+Hzb,BeginZ+LampRadi+Zzb,BeginH+Hzb,BeginZ+LampRadi+Zzb);
	  };Hzb+=30;
	 }   */
}
void TMainWindow::GuZhangZhuangTai()
{
 //	KillTimer(IDC_TIMER1);
 //	MydelaY(1000);
	Lrc_visit=0;
//	for( s3=0;s3<23;s3++){ Visit_East_data[s3]=Control_data[s3];}
//	Visit_East_data[3]=0xfd;
//	Visit_East_data[14]=0x01;
//	Visit_East_data[19]=0x05;     //1为关机,0为开机
	for( s31=3;s31<=21;s31++){ Lrc_visit+=Visit_East_data[s31];}
	Lrc_visit=0xff&Lrc_visit;
	Lrc_visit=0xff-Lrc_visit;
	Visit_East_data[22]=Lrc_visit;
	for( s32=0;s32<=23;s32++){Control_data[s32]=Visit_East_data[s32];}
	VisitControlData();
	TrCount++;
	MydelaY(50);
//	 if (SendNumber==5)
//	 SetTimer(IDC_TIMER3,1000);
 //MessageBox("","",MB_OK);
}
void TMainWindow::EvTimer(UINT timerId)
{
  unsigned char k,k1,k2;
	switch (timerId)
  {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -