using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using GC.Motion;

namespace ScriptDemo_csharp
{
    public partial class FormMain : Form
    {
        ushort m_hDev = 0;
        int m_instIdx = 0;
        public FormMain()
        {
            InitializeComponent();
        }

        private void buttonInit_Click(object sender, EventArgs e)
        {
            short devNo = 0;
            int rtn = CNMCLib20.NMC_DevOpen(devNo, ref m_hDev);
            if (rtn == 0)
            {
                rtn = Scpt.ScptItf_InitByHandle(m_instIdx, m_hDev, 0, 1000, 10);
                if (rtn == 0) { timerSts.Enabled = true; return; }
            }
            MessageBox.Show("init error");
        }

        Scpt.TScptStsUser m_scptSts = new Scpt.TScptStsUser(true);
        private void timerSts_Tick(object sender, EventArgs e)
        {
            int rtn = Scpt.ScptItf_GetStatus(m_instIdx, ref m_scptSts);
            if (rtn == 0)
            {
                labelRunSts.Text = m_scptSts.runState.ToString();
            }
            else
            {
                labelRunSts.Text = "err";
            }

        }
    }
}
