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

📄 uplocal.cpp

📁 符合移动协议的见空系统,很有使用简直,希望多下载
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "UpLocal.h"
#include "BaseMain.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TwUpLocal *wUpLocal;

extern TComControl gp_ComGrid[MAX_OBJECTID];
extern OBJGROUP  gObjectGroup[8]; //0x0001~0x06FF;
extern bool gb_Direct;
extern _PtrClassMemFunc gpmemfun;
//---------------------------------------------------------------------------
__fastcall TwUpLocal::TwUpLocal(TComponent* Owner)
  : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TwUpLocal::btnQueryClick(TObject *Sender)
{
  static INT16U lObjectId[][2]=
  {
    {0x0010, 0x00},
    {0x0013, 0x00},
    {0x0014, 0x00},
    {0x0015, 0x00},
    {0x0016, 0x00},
    {0x0020, 0x00},
    {0x00, 0x00},
  };
  INT8U i;
	if(Form1->m_Port.m_hComm==NULL)
	{
    Form2->SetMsgText("请打开串行口!");
    Form2->ShowModal();
    return;
	}
	else
	{
    Form3->InitShow(DELAY_DIRECT/1000 * 9);
    Form1->Timer1->Enabled = false;
    Form1->m_bUpdateProg = true;
    SetEvent(Form1->m_Port.m_hEvent);
    Form1->StaticsObjPack(lObjectId, 0x02, false);
    if(gb_Direct)
    {
      gpmemfun = &TForm1::SendQueryPackDirect;
    }
    else
    {
      gpmemfun = &TForm1::SendQueryPackModem;
    }
    Form1->StartThread();
    Form3->ShowModal();
	}
}
//---------------------------------------------------------------------------

void __fastcall TwUpLocal::btnSetClick(TObject *Sender)
{
  static INT16U lObjectId[][2]=
  {
    {0x0010, 0x00},
    {0x0013, 0x00},
    {0x0014, 0x00},
    {0x0015, 0x00},
    {0x0016, 0x00},
    {0x0020, 0x00},
    {0x00, 0x00},
  };
	if(Form1->m_Port.m_hComm==NULL)
	{
    Form2->SetMsgText("请打开串行口!");
    Form2->ShowModal();
    return;
	}
	else
	{
    Form3->InitShow(DELAY_DIRECT/1000 * 9);
    Form1->m_bUpdateProg = true;
    Form1->Timer1->Enabled = false;
    SetEvent(Form1->m_Port.m_hEvent);
    if(rbn1->Checked)
      gp_ComGrid[0x0010].pCbx->ItemIndex = 0;
    else
      gp_ComGrid[0x0010].pCbx->ItemIndex = 1;
    gp_ComGrid[0x0013].pEd->Text = txtNum->Text;
    gp_ComGrid[0x0014].pEd->Text = txtDelay->Text;
    gp_ComGrid[0x0015].pEd->Text = txtInter->Text;
    gp_ComGrid[0x0016].pEd->Text = txtPause->Text;
    gp_ComGrid[0x0020].pCbx->ItemIndex = cbxUpdate->ItemIndex;
    Form1->StaticsObjPack(lObjectId, 0x03, false);
    if(gb_Direct)
    {
      gpmemfun = &TForm1::SendSettingPackDirect;
    }
    else
    {
      gpmemfun = &TForm1::SendSettingPackModem;
    }
    Form1->StartThread();
    Form3->ShowModal();
	}
}
//---------------------------------------------------------------------------

void __fastcall TwUpLocal::btnDefaultClick(TObject *Sender)
{
  txtNum->Text = "4";
  txtDelay->Text = "40";
  txtInter->Text = "500";
  txtPause->Text = "60";
  cbxUpdate->ItemIndex = 1;
  rbn1->Checked = true;
}
//---------------------------------------------------------------------------





void __fastcall TwUpLocal::Button1Click(TObject *Sender)
{
  String filename;
  char Buf[_1K];
  OpenDialog1->Filter = "*.Hex|*.*";
  OpenDialog1->InitialDir = ExtractFileDir(ParamStr(0)) + "\\data";
  if(OpenDialog1->Execute())
  {
    filename = OpenDialog1->FileName;
    if (FileExists(filename))
    {
      String InfoLine;
      InfoLine.sprintf("已经打开文件:%s", filename);
      Memo1->Lines->Add(InfoLine);
      CWorkFile wk(filename.c_str(), "r");
      OpenAll(&wk, 0);
      while(wk.GetLine(Buf))
      {
        char *p1 = strchr(Buf, '\t');
        if(!p1) continue;
        *p1++ = 0;
      }
      CloseAll(&wk, 0);
    }
  }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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