Programator.rar

  • DemoTester
    了解作者
  • C++ Builder
    开发工具
  • 29KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 5
    下载次数
  • 2010-03-15 19:10
    上传日期
Programator for MAXICON controler
Programator.rar
  • Maxicon_lite_Dallas.hex
    64.9KB
  • Programator.cpp
    950B
  • Config.h
    584B
  • UConfig.h
    1.2KB
  • Programator.bpr
    5.6KB
  • Test.hex
    413B
  • UMain.h
    1.4KB
  • Devices.h
    688B
  • Devices.cpp
    589B
  • UMain.dfm
    1.6KB
  • UConfig.dfm
    2.9KB
  • Programator.cfg
    28B
  • Programator.res
    876B
  • UMain.cpp
    6.4KB
  • Config.cpp
    1.9KB
  • UConfig.cpp
    1.7KB
内容介绍
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "UMain.h" #include "BldrSource.h" #include "DiskMan.h" #include "UConfig.h" #include "Config.h" #define RECORD_DATA_LENGTH 0x0002 #define RECORD_LOAD_ADDRESS 0x0004 #define RECORD_TYPE 0x0002 #define RECORD_CHECKSUM 0x0002 //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TFMain *FMain; //--------------------------------------------------------------------------- __fastcall TFMain::TFMain(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TFMain::CmExitClick(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- int Hex(char Hex) { if ( Hex >= '0' && Hex <= '9' ) return Hex - '0'; switch ( Hex ) { case 'A': case 'a': return 10; case 'B': case 'b': return 11; case 'C': case 'c': return 12; case 'D': case 'd': return 13; case 'E': case 'e': return 14; case 'F': case 'f': return 15; } return -1; } //--------------------------------------------------------------------------- BYTE HexToBYTE(AnsiString H) //Onley 2 simbols (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F) { BYTE ret = 0; if ( H.Length() < 2 ) return ret; //throw "Invalid Hex String!"; int First = Hex(H[1]); int Second = Hex(H[2]); if ( First < 0 || Second < 0 ) return ret; //throw "Invalid Hex String!"; ret |= (BYTE)((First<<4) + Second); return ret; } //--------------------------------------------------------------------------- void __fastcall TFMain::CmOpenFileClick(TObject *Sender) { if ( !OpenDialog->Execute() ) return; if ( !OpenDialog->FileName.Length() ) return; int FileSize; HANDLE Fh = OpenFileToRead(OpenDialog->FileName.c_str(), &FileSize); if ( Fh == INVALID_HANDLE_VALUE ) return; if ( !FileSize ) { CloseHandle(Fh); return; } char *Buffer = new char[FileSize]; if ( !Buffer ) { CloseHandle(Fh); return; } if ( !ReadFromFile(Fh, 0, Buffer, FileSize) ) { delete Buffer; return; } int Offset = 0; char *TempBuffer = new char[FileSize]; int Col = 1; int Row = 1; int DataSize = 0; ////////////////////////////////////////////////////// // CHECKSUM 頑 駑撼�� 頑震� - 表氛� !!!! int Index = 0; BYTE Sum = 0; BYTE Data = 0; ReadFromFile(Fh, 1, TempBuffer, RECORD_DATA_LENGTH + RECORD_LOAD_ADDRESS + RECORD_TYPE + (2 * 3)); TempBuffer[RECORD_DATA_LENGTH + RECORD_LOAD_ADDRESS + RECORD_TYPE + (2 * 3)] = 0; ShowMessage(TempBuffer); while ( 1 ) { if ( Index >= RECORD_DATA_LENGTH + RECORD_LOAD_ADDRESS + RECORD_TYPE + 6 ) break; Data = HexToBYTE(AnsiString(TempBuffer[Index]) + AnsiString(TempBuffer[Index + 1])); Sum += Data; Index += 2; } ShowMessage(Sum); ////////////////////////////////////////////////////// while ( Offset < FileSize ) { if ( Buffer[Offset] == ':' ) { Grid->Cells[0][Row] = Row; // 姥髡綑 Offset++; ReadFromFile(Fh, Offset, TempBuffer, RECORD_DATA_LENGTH); TempBuffer[RECORD_DATA_LENGTH] = 0; Grid->Cells[Col++][Row] = TempBuffer; DataSize = HexToBYTE(TempBuffer); // �擇� Offset += RECORD_DATA_LENGTH; ReadFromFile(Fh, Offset, TempBuffer, RECORD_LOAD_ADDRESS); TempBuffer[RECORD_LOAD_ADDRESS] = 0; Grid->Cells[Col++][Row] = TempBuffer; // 砍� Offset += RECORD_LOAD_ADDRESS; ReadFromFile(Fh, Offset, TempBuffer, RECORD_TYPE); TempBuffer[RECORD_TYPE] = 0; Grid->Cells[Col++][Row] = TempBuffer; // 丑瘩� Offset += RECORD_TYPE; ReadFromFile(Fh, Offset, TempBuffer, 2 * DataSize); TempBuffer[2 * DataSize] = 0; Grid->Cells[Col++][Row] = TempBuffer; // Checksum Offset += 2 * DataSize; ReadFromFile(Fh, Offset, TempBuffer, RECORD_CHECKSUM); TempBuffer[RECORD_CHECKSUM] = 0; Grid->Cells[Col++][Row] = TempBuffer; // ShowMessage(ChkS); // ShowMessage(HexToBYTE(AnsiString(TempBuffer))); // if ( ChkS == HexToBYTE(AnsiString(TempBuffer)) ) // ShowMessage("&&&&"); Row++; Col = 1; } Offset++; } Grid->RowCount = Row; delete Buffer; delete TempBuffer; CloseHandle(Fh); StatusBar->Panels->Items[0]->Text = OpenDialog->FileName; SetNativeWidths(Grid); } //--------------------------------------------------------------------------- void SetStringGridDimensions(TStringGrid *Grid, int ColCount, int RowCount) { Grid->ColCount = ColCount; // Grid->ColWidths[ColCount - 1] = -1; if ( RowCount > 1 ) Grid->RowCount = RowCount; else { Grid->RowCount = 2; Grid->Rows[1]->Clear(); } } //-------------------------------------------------------------------------- void TFMain::InitGrid() { int ColCount = 0; Grid->Cells[ColCount++][0] = "No"; Grid->Cells[ColCount++][0] = "姥髡綑"; Grid->Cells[ColCount++][0] = "�擇�"; Grid->Cells[ColCount++][0] = "砍�"; Grid->Cells[ColCount++][0] = "丑瘩�"; Grid->Cells[ColCount++][0] = "Checksum"; int Row = 1; SetStringGridDimensions(Grid, ColCount, Row); SetNativeWidths(Grid); } //--------------------------------------------------------------------------- void __fastcall TFMain::FormCreate(TObject *Sender) { // 1. 脊鋼� 蜻皺彆曖皖慘瘩摘� 鋒擋慮隧� ReadConfiguration(); InitGrid(); } //--------------------------------------------------------------------------- void __fastcall TFMain::CmConfigClick(TObject *Sender) { TFConfig *Dialog = new TFConfig(this, &ProgramConfiguration); if ( !Dialog ) return; int Result = Dialog->ShowModal(); delete Dialog; if ( Result != mrOk ) return; } //--------------------------------------------------------------------------- void __fastcall TFMain::FormClose(TObject *Sender, TCloseAction &Action) { SaveConfiguration(); } //---------------------------------------------------------------------------
评论
    相关推荐
    • CBuilder.rar
      针对图像图形的开发研究型文档集,值得认真思考研究。
    • Cbuilder.rar
      单片机开发程序,用于步进电机和他的正反转,促进大家对单片机的学习。
    • cbuilder.rar
      c++builder的入门教程,很全面,用wdl阅读器阅读
    • CBuilder.rar
      c++ builde 6。0 操作幫助說明 適用於初學者,帶實例說明
    • CBuilder-K3BOS.rar
      用C++Builder写K3BOS单据插件
    • C Builder 5编程实例与技巧
      前 言 2000年上半年,Inprise公司(原Borland公司)推出了C++Builder的最新版本:C++Builder 5。C++Builder 5继承了以前版本的优点,并在此基础上增添了许多新的功能,比如在ADO、数据模块设计、IBX、MIDAS、CORBA、...
    • DES算法加密解密控件 for C Builder
      DES算法加密解密控件for C Builder --------- 可以将需要加密的文字加密成16进制或非16进制 的字符串;也可以反过来解密之。 --------------- 操作十分方便,只需放入本控件, 然后调用4个...
    • MD5算法的C Builder实现
      MD5算法C++ Builder6.0实现
    • C Builder适用的区域生长函数
      C Builder适用的区域生长函数,修改自VC,windows xp + C++ builder下运行通过
    • Cbuilder-delphi2010破解
      破解 delphi cbuilder 3513,勿做商业用途!