int main(
int argc,
char **
const argv)
{
int rc, i;
UINT32 doSlot = 2, slotMin = 0, slotMax = 0;
int tcChannelAmount = 8;
int doChannelAmount = 16;
int tcTypeAmount = 11;
UINT8 arrMode[doChannelAmount];
float fThreshold = 100.0f;
while(-1 != (rc = getopt(argc, argv, "c:hi:r:s:t:")))
{
switch(rc)
{
case 'c':
tcChannel = atoi(optarg);
if(tcChannel < 0 || tcChannel >= tcChannelAmount)
{
printf("Error parameter: channel: %d\n", tcChannel);
return -1;
}
break;
case 'i':
tcSlot = atoi(optarg);
if(tcSlot < slotMin || tcSlot > slotMax)
{
printf("Error parameter: slot: %d\n", tcSlot);
return -1;
}
break;
case 'r':
fThreshold = atof(optarg);
break;
case 's':
doSlot = atoi(optarg);
if(doSlot < slotMin || doSlot > slotMax)
{
printf("Error parameter: slot: %d\n", doSlot);
return -1;
}
break;
case 't':
tcType = atoi(optarg);
if(tcType < 0 || tcType >= tcTypeAmount)
{
printf("Error parameter: type: %d\n", tcType);
return -1;
}
break;
case '?':
case 'h':
default:
printf("TC sample program.\n\n");
printf("Usage: ./tc [OPTIONS]\n\n");
printf("Options:\n");
printf("\t%-8s Channel on TC module [%d-%d]. Default channel = %d\n",
"-c", 0, tcChannelAmount - 1, tcChannel);
printf("\t%-8s Slot of TC module [%d-%d]. Default slot = %d\n",
"-i", slotMin, slotMax, tcSlot);
printf("\t%-8s Test threshold. Default threshold = %.3f\n",
"-r", fThreshold);
printf("\t%-8s Slot of DO module [%d-%d]. Default slot = %d\n",
"-s", slotMin, slotMax, doSlot);
printf("\t%-8s TC type [%d-%d]. Default type = %d\n",
"-t", 0, tcTypeAmount - 1, tcType);
printf("\n");
return 0;
}
}
printf("%-10s: %d\n", "TC slot", tcSlot);
printf("%-10s: %d\n", "TC channel", tcChannel);
printf("%-10s: %d\n", "TC type", tcType);
printf("%-10s: %d\n", "DO slot", doSlot);
printf("%-10s: %.3f\n", "threshold", fThreshold);
printf("MX_RTU_Module_TC_Type_Set(%d, %d, %d), return code = %d.\n",
tcSlot, tcChannel, 1, rc);
for(i = 0; i < doChannelAmount; i++)
printf("MX_RTU_Module_DO_Mode_Set(%d, %d, %d, %d), return code = %d.\n",
printf("Start!\n");
while(1)
{
float fEngVal = 0;
{
printf("MX_RTU_Module_DO_Value_Get(%d), return code = %d.\n", doSlot, rc);
break;
}
{
printf("MX_RTU_Module_TC_Burnout_Status_Get(%d, %d, %d), return code = %d.\n",
tcSlot, tcChannel, 1, rc);
break;
}
{
printf("MX_RTU_Module_TC_Eng_Value_Get(%d, %d, %d), return code = %d.\n",
tcSlot, tcChannel, 1, rc);
break;
}
{
u32DOVal &= ~0x1;
u32DOVal |= 0x2;
}
else
{
u32DOVal &= ~0x2;
if(fEngVal > fThreshold)
u32DOVal |= 0x1;
else
u32DOVal &= ~0x1;
}
{
printf("MX_RTU_Module_DO_Value_Set(%d, 0x%04X), return code = %d.\n",
doSlot, u32DOVal, rc);
break;
}
}
return 0;
}