|
|
|
|
using gts;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Gugao.FunTest
|
|
|
|
|
{
|
|
|
|
|
public partial class Form1 : Form
|
|
|
|
|
{
|
|
|
|
|
short cardnum = 0;
|
|
|
|
|
short ret = 0;
|
|
|
|
|
public Form1()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnOpen_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ret = mc_pulse.GT_Open(cardnum, 0,0);
|
|
|
|
|
AddText($"ret = {ret}");
|
|
|
|
|
if(ret==0)
|
|
|
|
|
{
|
|
|
|
|
timer1.Enabled = true;
|
|
|
|
|
|
|
|
|
|
ret = mc_pulse.GT_LmtsOff(cardnum, 3, 0);
|
|
|
|
|
AddText($"ret = {ret}");
|
|
|
|
|
|
|
|
|
|
mc_pulse.GT_ClrSts(cardnum, short.Parse(cboxAxis.SelectedItem.ToString()), 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnDisablePlimit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ret= mc_pulse.GT_LmtsOff(cardnum, short.Parse(cboxAxis.SelectedItem.ToString()), 0);
|
|
|
|
|
AddText($"ret = {ret}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddText(string text)
|
|
|
|
|
{
|
|
|
|
|
txtLog.AppendText(text+"\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
cboxAxis.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ret = mc_pulse.GT_GetSts(cardnum, short.Parse(cboxAxis.SelectedItem.ToString()), out int pSts, 1, out uint pClock);
|
|
|
|
|
if(ret==0)
|
|
|
|
|
{
|
|
|
|
|
if((pSts >> 1 & 0x01)==1)
|
|
|
|
|
{
|
|
|
|
|
btnAlarm.BackColor= Color.Red;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btnAlarm.BackColor = SystemColors.Window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((pSts >> 5 & 0x01) == 1)
|
|
|
|
|
{
|
|
|
|
|
btnPlimitTrigger.BackColor = Color.Red;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btnPlimitTrigger.BackColor = SystemColors.Window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((pSts >> 6 & 0x01) == 1)
|
|
|
|
|
{
|
|
|
|
|
btnNlimitTrigger.BackColor = Color.Red;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btnNlimitTrigger.BackColor = SystemColors.Window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((pSts >> 9 & 0x01) == 1)
|
|
|
|
|
{
|
|
|
|
|
btnServo.BackColor = Color.Red;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btnServo.BackColor = SystemColors.Window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mc_pulse.GT_GetDi(cardnum, mc_pulse.MC_LIMIT_POSITIVE, out int pValue);
|
|
|
|
|
|
|
|
|
|
int v = ((pValue >> (short.Parse(cboxAxis.SelectedItem.ToString()) - 1)) & 0x01);
|
|
|
|
|
if(v==1)
|
|
|
|
|
{
|
|
|
|
|
btnPlimit.BackColor = Color.Red;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btnPlimit.BackColor= SystemColors.Window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mc_pulse.GT_GetDi(cardnum, mc_pulse.MC_LIMIT_NEGATIVE, out pValue);
|
|
|
|
|
|
|
|
|
|
v = ((pValue >> (short.Parse(cboxAxis.SelectedItem.ToString()) - 1)) & 0x01);
|
|
|
|
|
if (v == 1)
|
|
|
|
|
{
|
|
|
|
|
btnNlimit.BackColor = Color.Red;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btnNlimit.BackColor = SystemColors.Window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnClear_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
mc_pulse.GT_ClrSts(cardnum, short.Parse(cboxAxis.SelectedItem.ToString()),1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnEnablePlimit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ret = mc_pulse.GT_LmtsOn(cardnum, short.Parse(cboxAxis.SelectedItem.ToString()), 0);
|
|
|
|
|
AddText($"ret = {ret}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|