/********************************************************************************
* *
* Outline : Modbus communication application (RTU) with RC controller
* *
* *
* System : *
* *
* Author : IAI Software *
* *
* Remarks : *
* *
********************************************************************************/
//---------------------------------------------------------------------------
#include <vcl.h>
#include <stdio.h>
#include <stdlib.h>
#pragma hdrstop
#include "Main.h"
#include "Function.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
CRITICAL_SECTION critical_section; /* critical section */
/* Sending character string generating jamp table */
pStrFunc MakeStrFuncTbl[10] =
{
MakePosStr,
MakeDecideWidthStr,
MakeVelStr,
MakeZonePlusStr,
MakeZoneMinusStr,
MakeAccStr,
MakeDecStr,
MakePushStr,
MakeBoundaryStr,
MakeIncStr
};
/* Jamp table to write value into the chart */
pIniFunc InitFuncTbl[10] =
{
PosGrid,
VelGrid,
AccGrid,
DecGrid,
PushGrid,
BoundaryGrid,
DecideWidthGrid,
ZonePlusGrid,
ZoneMinusGrid,
IncGrid
};
/* Default value input jamp table */
pWriteFunc DefaultWriteTbl[10] =
{
WritePos,
WriteVel,
WriteAcc,
WriteDec,
WritePush,
WriteBoundary,
WriteDecideWidth,
WriteZonePlus,
WriteZoneMinus,
WriteInc
};
char* FixedQuery[27] = /* fixed command */
{
"0390000002", /* gain present position */
"0390020001", /* gain alarm code */
"0390070001", /* gain register to confirm whether moving or not */
"0390080002", /* gain output port value */
"0390100002", /* gain accumulated time */
"050403FF00", /* command for servo ON */
"0504030000", /* command for servo OFF */
"0504070000", /* alarm reset release */
"050407FF00", /* alarm reset command */
"05040A0000", /* pause release */
"05040AFF00", /* pause command */
"05040B0000", /* homing release */
"05040BFF00", /* homing command */
"05040C0000", /* positioning movement release */
"05040CFF00", /* positioning movement start command */
"050411FF00", /* change command to inching movement */
"0504110000", /* change command to jog movement */
"050414FF00", /* change command to teaching mode */
"0504140000", /* change command to standard mode */
"050415FF00", /* command to take in position data */
"0504160000", /* jog+release */
"050416FF00", /* jog+command */
"0504170000", /* jog-release */
"050417FF00", /* jog-command */
"050427FF00", /* PIO start disable setting */
"0504270000", /* PIO start permit setting */
"05042CFF00" /* axis stop command */
};
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
/********************************************************************************
* *
* ProcName : FormCreate *
* *
* Outline : *
* *
* Function : Initialize the chart of valuable for form 1, communication class and position data *
* *
* Return : void *
* *
* Modify : *
* *
* Remarks : *
* *
********************************************************************************/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
AxisNo = "01"; /* set axis number "0" (zero) */ /// axis number specify point specified by slave address ( axis number+1 ) ///
PosDatSum = 4; /* total number of position data */
Com = new TCommunicate("COM1"); /* open communication port with COM1 */ /// COM port specify point ///
InitializeCriticalSection(&critical_section); /* initialize critical section */
InitPosDataGrid(); /* initialize position data chart */
MoveTarget = NON; /* initialize target position number of position specified movement */
FlgStp = OFF; /* initialize the flag whether it is under pausing or not */
PosRow = POS_START_NO; /* change the number of selected cell line to "1" */
PosCol = POS_START_NO; /* change the number of selected cell row to "1" */
FlgInvData = OFF; /* initialize the flag to serch invalid data */
FlgInitializedGrid = OFF; /* initialize the initialize complete flag */
}
//---------------------------------------------------------------------------
/******************************
评论0