📄 unit1.~h
字号:
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <stdio.h>
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "YbCommDevice.h"
#include <ExtCtrls.hpp>
#include <Menus.hpp>
#include <ScktComp.hpp>
#include <ComCtrls.hpp>
#include <ToolWin.hpp>
#include <Buttons.hpp>
#include "Unit2.h"
//---------------------------------------------------------------------------
class TFrmADSLmain : public TForm
{
__published: // IDE-managed Components
TYbCommDevice *YbCommDevice1;
TClientSocket *ClientSocket1;
TMainMenu *MainMenu1;
TMenuItem *P1;
TMenuItem *N1;
TMenuItem *TCP1;
TMenuItem *R1;
TMenuItem *N2;
TMenuItem *N3;
TMenuItem *N4;
TMenuItem *H1;
TMenuItem *N5;
TTimer *Timer1;
TToolBar *ToolBar1;
TEdit *EditTCP;
TStaticText *StaticText1;
TStaticText *StaticText2;
TComboBox *CBAddress;
TCheckBox *CB_Save;
TMemo *Memo1;
TStaticText *StaticText3;
TComboBox *ComboBoxTimer;
TSpeedButton *SBStartTask;
TSpeedButton *SBStopTask;
TPageControl *PageControl1;
TTabSheet *TabSheetXH;
TTabSheet *TabSheetSET;
TTabSheet *TabSheetMSET;
TGroupBox *GroupBox1;
TGroupBox *GroupBox2;
TStatusBar *StatusBar1;
TLabel *Label48VXH;
TShape *Shape220VXH;
TLabel *Label220VXH;
TSpeedButton *SBPortSet;
TMenuItem *E1;
TStaticText *StaticText4;
TComboBox *ComboBoxCOM;
TMenuItem *L1;
TMenuItem *P2;
TShape *Shape1;
TShape *Shape2;
TShape *Shape3;
TShape *Shape4;
TShape *Shape5;
TShape *Shape6;
TLabel *Label1;
TLabel *Label2;
TLabel *Label3;
TLabel *Label4;
TLabel *Label5;
TLabel *Label6;
TShape *Shape7;
TLabel *Label7;
TGroupBox *GroupBox3;
TSpeedButton *SpeedButton1;
TStaticText *StaticText6;
TComboBox *ComboBox1;
TGroupBox *GroupBox4;
TStaticText *StaticText5;
TEdit *Edit1;
TStaticText *StaticText7;
TEdit *Edit2;
TStaticText *StaticText8;
TGroupBox *GroupBox5;
TStaticText *StaticText9;
TEdit *Edit4;
TStaticText *StaticText10;
TEdit *Edit5;
TEdit *Edit6;
TStaticText *StaticText11;
TGroupBox *GroupBox6;
TStaticText *StaticText12;
TEdit *Edit7;
TStaticText *StaticText13;
TEdit *Edit8;
TEdit *Edit9;
TStaticText *StaticText14;
TGroupBox *GroupBox7;
TStaticText *StaticText15;
TEdit *Edit10;
TStaticText *StaticText16;
TEdit *Edit11;
TEdit *Edit12;
TStaticText *StaticText17;
TLabel *Label8;
TEdit *Edit13;
TSpeedButton *SpeedButton2;
TSpeedButton *SpeedButton3;
TEdit *Edit3;
void __fastcall SBPortSetClick(TObject *Sender);
void __fastcall N1Click(TObject *Sender);
void __fastcall ComboBoxTimerChange(TObject *Sender);
void __fastcall E1Click(TObject *Sender);
void __fastcall N5Click(TObject *Sender);
void __fastcall ComboBoxCOMChange(TObject *Sender);
void __fastcall SBStartTaskClick(TObject *Sender); //开始传输
void __fastcall SBStopTaskClick(TObject *Sender); //结束传输
void __fastcall Timer1Timer(TObject *Sender);
void __fastcall YbCommDevice1CommNotify(TObject *Sender,
int NotifyType);
void __fastcall N2Click(TObject *Sender);
void __fastcall N4Click(TObject *Sender);
void __fastcall CB_SaveClick(TObject *Sender);
void __fastcall L1Click(TObject *Sender);
void __fastcall P2Click(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall SBAddrSETClick(TObject *Sender);
void __fastcall EditTCPChange(TObject *Sender);
void __fastcall ComboBox1Change(TObject *Sender);
void __fastcall SpeedButton3Click(TObject *Sender);
void __fastcall CBAddressChange(TObject *Sender);
private: // User declarations
void __fastcall DisplayData(AnsiString strDisplay); //显示信息
void __fastcall BuildCmd(void); //建立命令列表
void __fastcall SendCmd(void); //发送命令
char __fastcall CheckSum(char *P ,int PCount); //校验函数
char __fastcall CheckSum2(char *P ,int PCount); //电量校验函数(发送)
unsigned char __fastcall CheckSum1(unsigned char *P ,int PCount); //电量校验函数(接收)
bool __fastcall TimeOut(void); //超时处理
bool __fastcall ReceiveOk(void); //接收确认
void __fastcall DataRefresh(char * Buf); //数据解析
int __fastcall MakeCommand(void); //创建具体命令
void __fastcall BuildCommand(void); //创建命令
int __fastcall FindFrame(char *FrameStr, int FrameLen, char HeadChr); //寻找特征字符
char __fastcall BCDToChar(AnsiString StrBCD ,int Count); //BCD转换函数
AnsiString __fastcall ShowDetail(void); //显示操作详细统计信息
void __fastcall ShowPortSetInfo(void); //显示端口配置信息
void __fastcall CreateLogDir(void); //创建log目录
void __fastcall SB48VOrderXH(void); //登陆设置命令
void __fastcall SBAddressSet(void); //地址设置命令
void __fastcall SB48VPSetOrder(void); //电压系数设置
void __fastcall ClearShow(void); //显示清零
public: // User declarations
__fastcall TFrmADSLmain(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TFrmADSLmain *FrmADSLmain;
extern PACKAGE TFormVersion *FormVersion;
//---------------------------------------------------------------------------
typedef struct TADSLCommand //命令结构
{
Byte CommandCode; //命令类型代码
Word AnswerLen; //命令代码字节数
int Value; //赋值1 (电压系数、设备地址)
AnsiString Value1; //赋值2 (登陆码,DCB码)
} * PADSLCommand;
struct TStatistics //统计信息
{
int SendCount; //累计发送次数
int RecvCount; //累计接收次数
int SendByteCount; //累计发送字节数
int RecvByteCount; //累计接收字节数
int RecvCountTimeOut; //累计接收超时次数
int RecvCountError; //累计接收错误次数
};
bool PortIsOpen ; //端口打开标志
bool IsTransmit ; //传输标志
int DevAdd ; //设备地址
const BufSize = 4096;
unsigned char WBuf[BufSize]; //发送命令 字符串
int CmdNum ; //发送命令 字节数
unsigned char RBuf[BufSize]; //接收命令 字符串
int RBufNum ; //接收命令 字节数
struct TADSLCommand CurrentCommand ; //当前通讯命令
TList *PCommandList = new TList(); //通讯命令列表
bool CurrentsetParam; //设置命令标志
AnsiString FLogComFileName; //通讯记录文件名
AnsiString FLogPath; //通讯记录文件名路径
float FValve_V[2]; //模拟量存储阀值
int CircleIndex; //命令代码轮寻
bool FIsClearBuf; //是否清空数据缓存
struct TStatistics FStatistics; //统计信息
bool FIsRecvError; //接收数据解析与校验是否正常
TDateTime LastGetDataTime ; //当前时间
AnsiString strCmd; //命令字符串
//波特率数组
const AnsiString ArrayBound[]={"0","110","300","600","1200","2400","9600","14400",
"19200","38400","56000","57600","115200","128000","256000"};
const AnsiString ArrayCMD[]={"0306","0303","44E9","45E9","46E9","54E9","55E9","56E9",
"64E9","65E9","66E9","84E9","85E9","86E9","43C3","0A0C"};
AnsiString AddressBCD;
//----------------------------------------------------------------------------
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -