public void AddIoOutput(string ioname, int nCardNo, int nAxisNo, int nIoIndex) { IoDefine ioDefine = new IoDefine(); ioDefine._AxisIndex = nAxisNo; ioDefine._IoIndex = nIoIndex; ioDefine._CardIndex = nCardNo; if (ioname != "" && !m_ioOutput.ContainsKey(ioname)) { m_ioOutput.Add(ioname, ioDefine); m_ioOutputOldState.Add(ioname, false); } else if (ioname != "") { string str = "输出:" + ioname + ":配置出错,请检查"; MessageBox.Show(str, "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public bool InStopDisenable(string ioname) { IoDefine ioDefine = new IoDefine(); if (!m_ioInput.TryGetValue(ioname, out ioDefine)) { //throw new Exception(string.Format("{0}不在配置文件中,请检查配置文件")); MessageBox.Show(string.Format("{0}不在配置文件中,请检查配置文件", ioname), "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } int index = (ioDefine._AxisIndex << 8) | ioDefine._IoIndex; //io 写入IO卡 研华的前8位为板卡的轴号,后为Io的索引 if (ioDefine._CardIndex >= m_listCard.Count) { MessageBox.Show("Io配置中,卡索引不对", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(m_listCard[ioDefine._CardIndex].InStopDisenable(index)); }
public bool WriteIoBit(string ioname, bool bval) { IoDefine ioDefine = new IoDefine(); if (!m_ioOutput.TryGetValue(ioname, out ioDefine)) { //throw new Exception(string.Format("{0}不在配置文件中,请检查配置文件")); MessageBox.Show(string.Format("{0}不在配置文件中,请检查配置文件", ioname), "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } bool bSafe = true; //输出 IO 安全检查 if (m_eventIsSafeWhenOutIo != null) { Delegate[] delegates = m_eventIsSafeWhenOutIo.GetInvocationList(); foreach (var tem in delegates) { MethodInfo methodInfo = tem.GetMethodInfo(); bSafe &= (bool)methodInfo.Invoke(null, new object[] { ioname, bval }); } } if (!bSafe) { return(false); } // _loggger.Info(string.Format("《{0}》 输出:{1}", ioname, bval)); //if (!m_eventIsSafeWhenOutIo(ioname, bval)) // return false; int index = (ioDefine._AxisIndex << 8) | ioDefine._IoIndex; //io 写入IO卡 研华的前8位为板卡的轴号,后为Io的索引 if (ioDefine._CardIndex >= m_listCard.Count) { MessageBox.Show("Io配置中,卡索引不对", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(m_listCard[ioDefine._CardIndex].WriteIoBit(index, bval)); }
public bool ReadIoOutBit(string ioname) { IoDefine ioDefine = new IoDefine(); if (!m_ioOutput.TryGetValue(ioname, out ioDefine)) { //throw new Exception(string.Format("{0}不在配置文件中,请检查配置文件", ioname)); MessageBox.Show(string.Format("{0}不在Io输出配置文件中,请检查配置文件", ioname), "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } int index = (ioDefine._AxisIndex << 8) | ioDefine._IoIndex; //io 写入IO卡 研华的前8位为板卡的轴号,后为Io的索引 if (ioDefine._CardIndex >= m_listCard.Count) { MessageBox.Show($"{ioname} Io配置中,卡索引不对", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } bool bval = m_listCard[ioDefine._CardIndex].ReadIoOutBit(index); return(bval); }