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

📄 zdjcform.~cpp

📁 织带机监测系统的上位机软件。RS-485总线
💻 ~CPP
📖 第 1 页 / 共 3 页
字号:
     //时
     Buffer[4] = StrToBCD(EditHour->Text);
     //分
     Buffer[3] = StrToBCD(EditMin->Text);
     //秒
     Buffer[2] = StrToBCD(EditSecond->Text);

     WordType.w = CRC16 (Buffer, 9);
     Buffer[9] = WordType.b[0];
     Buffer[10] = WordType.b[1];

     //发送数据
     SendData (bAddress, Buffer, 11, 4);

     TimerQuery->Enabled = TimerStatus;
}
//---------------------------------------------------------------------------

Byte TMainForm::StrToBCD (AnsiString Str)
{
     Byte BCDCode;
     Byte IntCode;
     IntCode = Str.ToIntDef(0);
     BCDCode = (((IntCode / 10) << 4) & 0xF0) | ((IntCode % 10) & 0x0F);
     return BCDCode;
}


void __fastcall TMainForm::BitBtnGroupClick(TObject *Sender)
{
     bool TimerStatus;
     Byte Buffer[22];
     WORDTYPE WordType;
     TimerStatus = TimerQuery->Enabled;
     TimerQuery->Enabled = false;

     //准备数据
     Buffer[0] = bAddress;
     //命令
     Buffer[1] = 0x81;
     //第一班
     Buffer[2] = StrToBCD(Edit_11->Text);
     Buffer[3] = StrToBCD(Edit_12->Text);
     Buffer[4] = StrToBCD(Edit_13->Text);
     Buffer[5] = StrToBCD(Edit_14->Text);

     //第二班
     Buffer[6] = StrToBCD(Edit_21->Text);
     Buffer[7] = StrToBCD(Edit_22->Text);
     Buffer[8] = StrToBCD(Edit_23->Text);
     Buffer[9] = StrToBCD(Edit_24->Text);

     //第三班
     Buffer[10] = StrToBCD(Edit_31->Text);
     Buffer[11] = StrToBCD(Edit_32->Text);
     Buffer[12] = StrToBCD(Edit_33->Text);
     Buffer[13] = StrToBCD(Edit_34->Text);

     //第四班
     Buffer[14] = StrToBCD(Edit_41->Text);
     Buffer[15] = StrToBCD(Edit_42->Text);
     Buffer[16] = StrToBCD(Edit_43->Text);
     Buffer[17] = StrToBCD(Edit_44->Text);

     if (RadioButtonThree->Checked)
         Buffer[18] = 0x03;

     if (RadioButtonFour->Checked)
         Buffer[18] = 0x04;

     WordType.w = CRC16 (Buffer, 20);
     Buffer[20] = WordType.b[0];
     Buffer[21] = WordType.b[1];

     //发送数据
     SendData (bAddress, Buffer, 22, 4);

     TimerQuery->Enabled = TimerStatus;   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_11KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_11, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_12KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_12, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_13KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_13, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_14KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_14, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_21KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_21, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_22KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_22, Key);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_23KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_23, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_24KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_24, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_31KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_31, Key);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_32KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_32, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_41KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_41, Key);   
}
//---------------------------------------------------------------------------


void __fastcall TMainForm::Edit_42KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_42, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_33KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_33, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_43KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_43, Key);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_34KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_34, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Edit_44KeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, Edit_44, Key);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::EditYearKeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, EditYear, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::EditMonthKeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, EditMonth, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::EditDateKeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, EditDate, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::EditWeekKeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, EditWeek, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::EditHourKeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, EditHour, Key);   
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::EditMinKeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, EditMin, Key);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::EditSecondKeyPress(TObject *Sender, char &Key)
{
     KeyIsDigital (this->Handle, EditSecond, Key);
}
//---------------------------------------------------------------------------




void __fastcall TMainForm::N10Click(TObject *Sender)
{
     bool TimerStatus;
     Byte Buffer[11];
     WORDTYPE WordType;
     TDateTime DateTime;
     TimerStatus = TimerQuery->Enabled;
     TimerQuery->Enabled = false;

     //准备数据

     //地址
     Buffer[0] = 0x00;
     //命令
     Buffer[1] = 0x86;

     DateTime = DateTime.CurrentDateTime ();
     //年
     Buffer[8] = StrToBCD(DateTime.FormatString ("YY"));
     //星期
     Buffer[7] = DateTime.DayOfWeek () - 1;
     //月
     Buffer[6] = StrToBCD(DateTime.FormatString ("mm"));
     //日
     Buffer[5] = StrToBCD(DateTime.FormatString ("dd"));
     //时
     Buffer[4] = StrToBCD(DateTime.FormatString ("hh"));
     //分
     Buffer[3] = StrToBCD(DateTime.FormatString ("nn"));
     //秒
     Buffer[2] = StrToBCD(DateTime.FormatString ("ss"));

     WordType.w = CRC16 (Buffer, 9);
     Buffer[9] = WordType.b[0];
     Buffer[10] = WordType.b[1];

     //发送数据
     SendData (0x00, Buffer, 11, 4);

     TimerQuery->Enabled = TimerStatus;
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::K1Click(TObject *Sender)
{
     /*
     bool TimerStatus;
     Byte Buffer[11];
     WORDTYPE WordType;
     TDateTime DateTime;
     TimerStatus = TimerQuery->Enabled;
     TimerQuery->Enabled = false;

     //准备数据

     //地址
     Buffer[0] = 0x00;
     //命令
     Buffer[1] = 0x86;

     DateTime = DateTime.CurrentDateTime ();
     //年
     Buffer[8] = StrToBCD(DateTime.FormatString ("YY"));
     //星期
     Buffer[7] = DateTime.DayOfWeek () - 1;
     //月
     Buffer[6] = StrToBCD(DateTime.FormatString ("mm"));
     //日
     Buffer[5] = StrToBCD(DateTime.FormatString ("dd"));
     //时
     Buffer[4] = StrToBCD(DateTime.FormatString ("hh"));
     //分
     Buffer[3] = StrToBCD(DateTime.FormatString ("nn"));
     //秒
     Buffer[2] = StrToBCD(DateTime.FormatString ("ss"));

     WordType.w = CRC16 (Buffer, 9);
     Buffer[9] = WordType.b[0];
     Buffer[10] = WordType.b[1];

     //发送数据
     SendData (0x00, Buffer, 11, 4);

     TimerQuery->Enabled = TimerStatus;
     */
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::N192001Click(TObject *Sender)
{
     bool TimerStatus;
     Byte Buffer[11];
     WORDTYPE WordType;
     TDateTime DateTime;
     TimerStatus = TimerQuery->Enabled;
     TimerQuery->Enabled = false;

     //准备数据
     //地址
     Buffer[0] = 0x00;
     //命令
     Buffer[1] = 0x87;

     Buffer[2] = 4;

     WordType.w = CRC16 (Buffer, 3);
     Buffer[3] = WordType.b[0];
     Buffer[4] = WordType.b[1];

     //发送数据
     SendData (0x00, Buffer, 5, 4);

     TimerQuery->Enabled = TimerStatus;
}

//---------------------------------------------------------------------------

void __fastcall TMainForm::N96001Click(TObject *Sender)
{
     bool TimerStatus;
     Byte Buffer[11];
     WORDTYPE WordType;
     TDateTime DateTime;
     TimerStatus = TimerQuery->Enabled;
     TimerQuery->Enabled = false;

     //准备数据
     //地址
     Buffer[0] = 0x00;
     //命令
     Buffer[1] = 0x87;

     Buffer[2] = 3;

     WordType.w = CRC16 (Buffer, 3);
     Buffer[3] = WordType.b[0];
     Buffer[4] = WordType.b[1];

     //发送数据
     SendData (0x00, Buffer, 5, 4);

     TimerQuery->Enabled = TimerStatus;
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::N48001Click(TObject *Sender)
{
     bool TimerStatus;
     Byte Buffer[11];
     WORDTYPE WordType;
     TDateTime DateTime;
     TimerStatus = TimerQuery->Enabled;
     TimerQuery->Enabled = false;

     //准备数据
     //地址
     Buffer[0] = 0x00;
     //命令
     Buffer[1] = 0x87;

     Buffer[2] = 2;

     WordType.w = CRC16 (Buffer, 3);
     Buffer[3] = WordType.b[0];
     Buffer[4] = WordType.b[1];

     //发送数据
     SendData (0x00, Buffer, 5, 4);

     TimerQuery->Enabled = TimerStatus;
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::N24001Click(TObject *Sender)
{
     bool TimerStatus;
     Byte Buffer[11];
     WORDTYPE WordType;
     TDateTime DateTime;
     TimerStatus = TimerQuery->Enabled;
     TimerQuery->Enabled = false;

     //准备数据
     //地址
     Buffer[0] = 0x00;
     //命令
     Buffer[1] = 0x87;

     Buffer[2] = 1;

     WordType.w = CRC16 (Buffer, 3);
     Buffer[3] = WordType.b[0];
     Buffer[4] = WordType.b[1];

     //发送数据
     SendData (0x00, Buffer, 5, 4);

     TimerQuery->Enabled = TimerStatus;
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::N12001Click(TObject *Sender)
{
     bool TimerStatus;
     Byte Buffer[11];
     WORDTYPE WordType;
     TDateTime DateTime;
     TimerStatus = TimerQuery->Enabled;
     TimerQuery->Enabled = false;

     //准备数据
     //地址
     Buffer[0] = 0x00;
     //命令
     Buffer[1] = 0x87;

     Buffer[2] = 0;

     WordType.w = CRC16 (Buffer, 3);
     Buffer[3] = WordType.b[0];
     Buffer[4] = WordType.b[1];

     //发送数据
     SendData (0x00, Buffer, 5, 4);

     TimerQuery->Enabled = TimerStatus;
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::BitBtnPreClick(TObject *Sender)
{
     AnsiString ButtonHint;
     bRecordIndex ++;
     bRecordIndex %= 15;
     Command_84[2] = bRecordIndex;
     ButtonHint.printf ("上一班记录(%d)", bRecordIndex);
     BitBtnPre->Caption = ButtonHint;
}
//---------------------------------------------------------------------------


void __fastcall TMainForm::N5Click(TObject *Sender)
{
     AboutBox->ShowModal ();   
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

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