91 lines
2.7 KiB
C#
91 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Sys;
|
|
namespace ConsoleTestDll
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
Test_RS232();
|
|
}
|
|
static void Test_RS232()
|
|
{
|
|
IntPtr hwnd = (IntPtr)0;
|
|
Console.WriteLine("init_rs232.");
|
|
var rStatus = RS232_API.init_rs232(hwnd, 1, 2400);
|
|
Console.WriteLine("RStatus:{0}", rStatus);
|
|
Console.WriteLine("Press any key to next step...");
|
|
Console.ReadLine();
|
|
byte[] buf = { 3, 1, 13 };
|
|
Console.WriteLine("Led:Green");
|
|
RS232_API.Write_Com(buf, 3);
|
|
Console.WriteLine("Press any key to next step...");
|
|
Console.ReadLine();
|
|
buf[1] = 2;
|
|
Console.WriteLine("Led:Red");
|
|
RS232_API.Write_Com(buf, 3);
|
|
Console.WriteLine("Press any key to exit...");
|
|
Console.ReadLine();
|
|
}
|
|
static void Test_MachineInterface()
|
|
{
|
|
MACHINEINTERFACEDLL.SSI_STATUS_MOTION rStatus;
|
|
Console.WriteLine("Machine_Startup.");
|
|
rStatus = MACHINEINTERFACEDLL.Machine_Startup(false, MACHINEINTERFACEDLL.EHOME_MACHINE_MODE.HOME_XYZ);
|
|
Console.WriteLine("RStatus:{0}\n", rStatus);
|
|
Byte bDISts = 0;
|
|
Console.WriteLine("Machine_GetDIO.");
|
|
rStatus = MACHINEINTERFACEDLL.Machine_GetDIO(MACHINEINTERFACEDLL.EIO_PORT.LIMIT_SWITCH_J4, ref bDISts);
|
|
Console.WriteLine("RStatus:{0}\n", rStatus);
|
|
bool IOStatus = false;
|
|
int iComp1 = 1;
|
|
int iComp2 = 0;
|
|
int i = 0;
|
|
Console.WriteLine("IOStatus:");
|
|
for (i = 0; i < 6; i++)
|
|
{
|
|
iComp2 = iComp1 << i;
|
|
if ((bDISts & iComp2) == iComp2)
|
|
{
|
|
IOStatus = true;
|
|
}
|
|
else
|
|
{
|
|
IOStatus = false;
|
|
}
|
|
Console.WriteLine("{0} ", IOStatus);
|
|
}
|
|
|
|
Console.WriteLine("Wait...");
|
|
Console.ReadLine();
|
|
Console.WriteLine("Machine_GetDIO.");
|
|
bDISts = 0;
|
|
rStatus = MACHINEINTERFACEDLL.Machine_GetDIO(MACHINEINTERFACEDLL.EIO_PORT.LIMIT_SWITCH_J4, ref bDISts);
|
|
Console.WriteLine("RStatus:{0}\n", rStatus);
|
|
i = 0;
|
|
Console.WriteLine("IOStatus:");
|
|
for (i = 0; i < 6; i++)
|
|
{
|
|
iComp2 = iComp1 << i;
|
|
if ((bDISts & iComp2) == iComp2)
|
|
{
|
|
IOStatus = true;
|
|
}
|
|
else
|
|
{
|
|
IOStatus = false;
|
|
}
|
|
Console.WriteLine("{0} ", IOStatus);
|
|
}
|
|
Console.WriteLine("Machine_Shutdown");
|
|
rStatus = MACHINEINTERFACEDLL.Machine_Shutdown();
|
|
Console.WriteLine("RStatus:{0}\n", rStatus);
|
|
Console.WriteLine("Press enter key to exit...");
|
|
Console.ReadLine();
|
|
}
|
|
}
|
|
}
|