You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

867 lines
40 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.EnterpriseServices;
using System.Text;
using System.Windows.Forms;
using DBFactory;
namespace wcfControlMonitorClient
{
/// <summary>
/// 20230815richard.liuWCS�͵���PLC�ڲ������������������ͻ�
/// </summary>
public partial class FrmZCKSetIOStation : Form
{
DBOperator dbo = CStaticClass.dbo;
Model.MDevice mdev;
StringBuilder sql=new StringBuilder();
private static FrmZCKSetIOStation _formInstance;
public static FrmZCKSetIOStation FormInstance
{
get
{
if (_formInstance == null)
{
_formInstance = new FrmZCKSetIOStation();
}
return _formInstance;
}
set { _formInstance = value; }
}
public FrmZCKSetIOStation()
{
InitializeComponent();
_formInstance = this;
}
private void button1_Click(object sender, EventArgs e)
{//12556\12577
int inout_mode12556 = 0; int inout_mode12577 = 0;
if (rb125561.Checked == true)
{
inout_mode12556 = 1;
}
else if (rb125562.Checked == true)
{
inout_mode12556 = 2;
}
else if (rb125563.Checked == true)
{
inout_mode12556 = 3;
}
else if (rb125560.Checked == true)
{
inout_mode12556 = 0;
}
if (rb125771.Checked == true)
{
inout_mode12577 = 1;
}
else if (rb125772.Checked == true)
{
inout_mode12577 = 2;
}
else if (rb125773.Checked == true)
{
inout_mode12577 = 3;
}
else if (rb125770.Checked == true)
{
inout_mode12577 = 0;
}
if (inout_mode12556 == inout_mode12577)
{
MessageBox.Show("·��12556-12563,·��12577-12570�����ⷽ��������ͬ��", "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Load12556_12577();
return;
}
if ((inout_mode12556 +inout_mode12577)!=3)
{
MessageBox.Show("��ȷ�Ϻ�������·��12556-12563,·��12577-12570�����ⷽ����", "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Load12556_12577();
return;
}
try
{
StringBuilder sbUnswitchRemark = new StringBuilder("");
StringBuilder tmpsbUnswitchRemark = new StringBuilder("");
char[] cc = new char[1] { ';' };
string[] AheadDetect;
DataView dv;
StringBuilder sql = new StringBuilder("");
#region 12556
dv = dbo.ExceSQL(String.Format("select * from T_BASE_IOMODE_SWITCH where input_station_code={0}", 12556)).Tables[0].DefaultView;
if (dv.Count > 0)
{
#region ��ǰ����
tmpsbUnswitchRemark.Clear();
if (dv[0]["station_inout_mode"].ToString() == "1" && inout_mode12556!=1)
{//����1�ж��Ƿ�����ת��Ϊ����2switch_to_output_detect
AheadDetect = dv[0]["switch_to_output_detect"].ToString().Split(cc);
splitAheadDetect(AheadDetect, out tmpsbUnswitchRemark);
}
else if (dv[0]["station_inout_mode"].ToString() == "2" && inout_mode12556 != 2)
{//����2�ж��Ƿ�����ת��Ϊ����1switch_to_input_detect
AheadDetect = dv[0]["switch_to_input_detect"].ToString().Split(cc);
splitAheadDetect(AheadDetect, out tmpsbUnswitchRemark);
}
else if (dv[0]["station_inout_mode"].ToString() == "3")
{//�ж��Ƿ�����ת��Ϊ������1switch_to_input_detect
if(inout_mode12556==2) {
AheadDetect = dv[0]["switch_to_output_detect"].ToString().Split(cc);
splitAheadDetect(AheadDetect, out tmpsbUnswitchRemark);
if (tmpsbUnswitchRemark.ToString().Length > 0)
{if (sbUnswitchRemark.ToString().IndexOf(tmpsbUnswitchRemark.ToString()) < 0)
{
sbUnswitchRemark.Append(tmpsbUnswitchRemark.ToString());
}
} }
if (inout_mode12556 == 1)
{
AheadDetect = dv[0]["switch_to_input_detect"].ToString().Split(cc);
splitAheadDetect(AheadDetect, out tmpsbUnswitchRemark);
}
}
else
{//Ŀǰû�д���3����������
}
if (tmpsbUnswitchRemark.ToString().Length > 0)
{
if (sbUnswitchRemark.ToString().IndexOf(tmpsbUnswitchRemark.ToString()) < 0) {
sbUnswitchRemark.Append(tmpsbUnswitchRemark.ToString()); }
}
if (sbUnswitchRemark.ToString().Length > 0)
{
MessageBox.Show(string.Format("ת��·��ʱ��������δͨ����{0}��", sbUnswitchRemark), "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Load12556_12577();
return;
}
else
{
//if (CStaticClass.WcfControl.WriteDBData(out string errText, 125562, "DB1", inout_mode12566.ToString()) == false)
//{
// MessageBox.Show(string.Format("·��12556-12563�����������ɣ�{0}ת��Ϊ{1}ʱд��PLC��ַ��ʧ�ܣ�{2}", dv[0]["station_inout_mode"].ToString(),inout_mode12566,errText), "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// Load12556_12577();
// return;
//}
//else
//{
// dbo.ExecuteSql(String.Format("update T_BASE_IOMODE_SWITCH set station_inout_mode={0} where input_station_code={1}",inout_mode12566, 12556));
//}
CStaticClass.WcfControl.BeginWriteDBData(125562, "DB1", inout_mode12556.ToString(), WriteDBDataCallBack, string.Format("12556,{0},{1}", dv[0]["station_inout_mode"].ToString(),inout_mode12556));
}
#endregion
}
#endregion
#region 12577
dv = dbo.ExceSQL(String.Format("select * from T_BASE_IOMODE_SWITCH where input_station_code={0}", 12577)).Tables[0].DefaultView;
if (dv.Count > 0)
{
#region ��ǰ����
tmpsbUnswitchRemark.Clear();
if (dv[0]["station_inout_mode"].ToString() == "1" && inout_mode12577 != 1)
{//����1�ж��Ƿ�����ת��Ϊ����2switch_to_output_detect
AheadDetect = dv[0]["switch_to_output_detect"].ToString().Split(cc);
splitAheadDetect(AheadDetect, out tmpsbUnswitchRemark);
}
else if (dv[0]["station_inout_mode"].ToString() == "2" && inout_mode12577 != 2)
{//����2�ж��Ƿ�����ת��Ϊ����1switch_to_input_detect
AheadDetect = dv[0]["switch_to_input_detect"].ToString().Split(cc);
splitAheadDetect(AheadDetect, out tmpsbUnswitchRemark);
}
else if (dv[0]["station_inout_mode"].ToString() == "3")
{//�ж��Ƿ�����ת��Ϊ������1switch_to_input_detect
if (inout_mode12577 == 2)
{
AheadDetect = dv[0]["switch_to_output_detect"].ToString().Split(cc);
splitAheadDetect(AheadDetect, out tmpsbUnswitchRemark);
if (tmpsbUnswitchRemark.ToString().Length > 0)
{
if (sbUnswitchRemark.ToString().IndexOf(tmpsbUnswitchRemark.ToString()) < 0)
{
sbUnswitchRemark.Append(tmpsbUnswitchRemark.ToString());
}
}
}
if (inout_mode12577 == 1)
{
AheadDetect = dv[0]["switch_to_input_detect"].ToString().Split(cc);
splitAheadDetect(AheadDetect, out tmpsbUnswitchRemark);
}
}
else
{//Ŀǰû�д���3����������
}
if (tmpsbUnswitchRemark.ToString().Length > 0)
{
if (sbUnswitchRemark.ToString().IndexOf(tmpsbUnswitchRemark.ToString()) < 0)
{
sbUnswitchRemark.Append(tmpsbUnswitchRemark.ToString());
}
}
if (sbUnswitchRemark.ToString().Length > 0)
{
MessageBox.Show(string.Format("ת��·��ʱ��������δͨ����{0}��", sbUnswitchRemark), "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Load12556_12577();
return;
}
else
{
//if (CStaticClass.WcfControl.WriteDBData(out string errText, 125772, "DB1", inout_mode12577.ToString()) == false)
//{
// MessageBox.Show(string.Format("·��12577-12570�����������ɣ�{0}ת��Ϊ{1}ʱд��PLC��ַ��ʧ�ܣ�{2}", dv[0]["station_inout_mode"].ToString(), inout_mode12577, errText), "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// Load12556_12577();
// return;
//}
//else
//{
//dbo.ExecuteSql(String.Format("update T_BASE_IOMODE_SWITCH set station_inout_mode={0} where input_station_code={1}", inout_mode12577, 12577));
//}
CStaticClass.WcfControl.BeginWriteDBData(125772, "DB1", inout_mode12577.ToString(), WriteDBDataCallBack, string.Format("12577,{0},{1}", dv[0]["station_inout_mode"].ToString(), inout_mode12577));
}
#endregion
}
#endregion
MessageBox.Show("������������ͨ�����ã�", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Information);
CommonClassLib.CCarryConvert.WriteDarkCasket("ϵͳ����", "UserID��" + CStaticClass.UserID + "�IJ�����־", "���������桿��ť", "����Ƭ�������������������¿�����", "");
}
catch (Exception ex)
{
throw ex;
}
}
private void button2_Click(object sender, EventArgs e)
{//12660\12661
int inout_mode12660 = 0; int inout_mode12661 = 0;
if (rb126601.Checked == true)
{
inout_mode12660 = 1;
}
else if (rb126602.Checked == true)
{
inout_mode12660 = 2;
}
else if (rb126600.Checked == true)
{
inout_mode12660 = 0;
}
if (rb126611.Checked == true)
{
inout_mode12661 = 1;
}
else if (rb126612.Checked == true)
{
inout_mode12661 = 2;
}
else if (rb126610.Checked == true)
{
inout_mode12661 = 0;
}
//if ((inout_mode12660 + inout_mode12661) != 3)
//{
// MessageBox.Show("��ȷ�Ϻ�������·��12660-12724,·��12661-12725�����ⷽ����", "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// Load12660_12661();
// return;
//}
try
{
StringBuilder sbUnswitchRemark = new StringBuilder("");
StringBuilder tmpsbUnswitchRemark = new StringBuilder("");
char[] cc = new char[1] { ';' };
string[] AheadDetect;
DataView dv;
StringBuilder sql = new StringBuilder("");
#region 12660
int dev12660 = 12685;
dv = dbo.ExceSQL(String.Format("select * from T_BASE_IOMODE_SWITCH where input_station_code={0}", dev12660)).Tables[0].DefaultView;
if (dv.Count > 0)
{
#region ��ǰ����
tmpsbUnswitchRemark.Clear();
if (dv[0]["station_inout_mode"].ToString() != "2" && inout_mode12660 ==2)
{//����1�ж��Ƿ�����ת��Ϊ����2switch_to_output_detect
AheadDetect = dv[0]["switch_to_output_detect"].ToString().Split(cc);
splitAheadDetect(AheadDetect, out tmpsbUnswitchRemark);
}
else if (dv[0]["station_inout_mode"].ToString() != "1" && inout_mode12660==1)
{//����2�ж��Ƿ�����ת��Ϊ����1switch_to_input_detect
AheadDetect = dv[0]["switch_to_input_detect"].ToString().Split(cc);
splitAheadDetect(AheadDetect, out tmpsbUnswitchRemark);
}
else
{//Ŀǰû�д���3����������
}
if (tmpsbUnswitchRemark.ToString().Length > 0)
{
if (sbUnswitchRemark.ToString().IndexOf(tmpsbUnswitchRemark.ToString()) < 0)
{
sbUnswitchRemark.Append(tmpsbUnswitchRemark.ToString());
}
}
if (sbUnswitchRemark.ToString().Length > 0)
{
MessageBox.Show(string.Format("ת��·��ʱ��������δͨ����{0}��", sbUnswitchRemark), "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Load12660_12661();
return;
}
else
{
//if( CStaticClass.WcfControl.WriteDBData(out string errText, 126602, "DB1", inout_mode12660.ToString())==false)
// {
// MessageBox.Show(string.Format("·��12660-12724�����������ɣ�{0}ת��Ϊ{1}ʱд��PLC��ַ��ʧ�ܣ�{2}", dv[0]["station_inout_mode"].ToString(), inout_mode12660, errText), "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// Load12660_12661();
// return;
// }
// else
{
CStaticClass.WcfControl.BeginWriteDBData(126602, "DB1", inout_mode12660.ToString(), WriteDBDataCallBack, string.Format("12660,{0},{1}", dv[0]["station_inout_mode"].ToString(), inout_mode12660));
//12660-12685����·��վ̨��12686����·��վ̨
switch (inout_mode12660)
{
case 0:
mdev = Model.CGetInfo.GetDeviceInfo(12685);
mdev.RunState = 4;
mdev.ManTaskReserve = 0;
mdev.ErrorCode = 998;
CStaticClass.WcfControl.BeginSetDeviceState(mdev, null, null);
dbo.ExecuteSql(string.Format("update T_BASE_DEVICE set f_lockedstate=-1 where f_deviceindex={0}",12685));
mdev = Model.CGetInfo.GetDeviceInfo(12686);
mdev.RunState = 4;
mdev.ManTaskReserve = 0;
mdev.ErrorCode = 998;
CStaticClass.WcfControl.BeginSetDeviceState(mdev, null, null);
dbo.ExecuteSql(string.Format("update T_BASE_DEVICE set f_lockedstate=-1 where f_deviceindex={0}",12686));
break;
case 1:
mdev = Model.CGetInfo.GetDeviceInfo(12685);
mdev.RunState = 0;
mdev.ManTaskReserve = 0;
mdev.ErrorCode = 0;
CStaticClass.WcfControl.BeginSetDeviceState(mdev,null,null);
dbo.ExecuteSql(string.Format("update T_BASE_DEVICE set f_lockedstate=0 where f_deviceindex=12685 and f_lockedstate=-1"));
mdev = Model.CGetInfo.GetDeviceInfo(12686);
mdev.RunState = 4;
mdev.ManTaskReserve = 0;
mdev.ErrorCode = 998;
CStaticClass.WcfControl.BeginSetDeviceState( mdev,null,null );
dbo.ExecuteSql(string.Format("update T_BASE_DEVICE set f_lockedstate=-1 where f_deviceindex=12686"));
break;
case 2:
mdev = Model.CGetInfo.GetDeviceInfo(12686);
mdev.RunState = 0;
mdev.ManTaskReserve = 0;
mdev.ErrorCode = 0;
CStaticClass.WcfControl.BeginSetDeviceState(mdev, null, null);
dbo.ExecuteSql(string.Format("update T_BASE_DEVICE set f_lockedstate=0 where f_deviceindex=12686 and f_lockedstate=-1"));
mdev = Model.CGetInfo.GetDeviceInfo(12685);
mdev.RunState = 4;
mdev.ManTaskReserve = 0;
mdev.ErrorCode = 998;
CStaticClass.WcfControl.BeginSetDeviceState(mdev, null, null);
dbo.ExecuteSql(string.Format("update T_BASE_DEVICE set f_lockedstate=-1 where f_deviceindex=12685"));
break;
}
dbo.ExecuteSql(String.Format("update T_BASE_IOMODE_SWITCH set station_inout_mode={0} where input_station_code={1}", inout_mode12660, 12660));
}
}
#endregion
}
#endregion
#region 12661
int dev12661 = 12692;
dv = dbo.ExceSQL(String.Format("select * from T_BASE_IOMODE_SWITCH where input_station_code={0}", dev12661)).Tables[0].DefaultView;
if (dv.Count > 0)
{
#region ��ǰ����
tmpsbUnswitchRemark.Clear();
if (dv[0]["station_inout_mode"].ToString() != "2" && inout_mode12661 == 2)
{//����1�ж��Ƿ�����ת��Ϊ����2switch_to_output_detect
AheadDetect = dv[0]["switch_to_output_detect"].ToString().Split(cc);
splitAheadDetect(AheadDetect, out tmpsbUnswitchRemark);
}
else if (dv[0]["station_inout_mode"].ToString() != "1" && inout_mode12661 == 1)
{//����2�ж��Ƿ�����ת��Ϊ����1switch_to_input_detect
AheadDetect = dv[0]["switch_to_input_detect"].ToString().Split(cc);
splitAheadDetect(AheadDetect, out tmpsbUnswitchRemark);
}
else
{//Ŀǰû�д���3����������
}
if (tmpsbUnswitchRemark.ToString().Length > 0)
{
if (sbUnswitchRemark.ToString().IndexOf(tmpsbUnswitchRemark.ToString()) < 0)
{
sbUnswitchRemark.Append(tmpsbUnswitchRemark.ToString());
}
}
if (sbUnswitchRemark.ToString().Length > 0)
{
MessageBox.Show(string.Format("ת��·��ʱ��������δͨ����{0}��", sbUnswitchRemark), "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Load12660_12661();
return;
}
else
{
//if (CStaticClass.WcfControl.WriteDBData(out string errText, 126612, "DB1", inout_mode12661.ToString()) == false)
//{
// MessageBox.Show(string.Format("·��12661-12725�����������ɣ�{0}ת��Ϊ{1}ʱд��PLC��ַ��ʧ�ܣ�{2}", dv[0]["station_inout_mode"].ToString(), inout_mode12661, errText), "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// Load12660_12661();
// return;
//}
//else
{
CStaticClass.WcfControl.BeginWriteDBData(126612, "DB1", inout_mode12661.ToString(), WriteDBDataCallBack, string.Format("12661,{0},{1}", dv[0]["station_inout_mode"].ToString(), inout_mode12661));
//12661-12692����·��վ̨��12693����·��վ̨
switch (inout_mode12661)
{
case 0:
mdev = Model.CGetInfo.GetDeviceInfo(12692);
mdev.RunState = 4;
mdev.ManTaskReserve = 0;
mdev.ErrorCode = 998;
CStaticClass.WcfControl.BeginSetDeviceState(mdev, null, null);
mdev = Model.CGetInfo.GetDeviceInfo(12693);
mdev.RunState = 4;
mdev.ManTaskReserve = 0;
mdev.ErrorCode = 998;
CStaticClass.WcfControl.BeginSetDeviceState(mdev, null, null);
dbo.ExecuteSql(string.Format("update T_BASE_DEVICE set f_lockedstate=-1 where f_deviceindex=12692 or f_deviceindex=12693"));
break;
case 1:
mdev = Model.CGetInfo.GetDeviceInfo(12692);
mdev.RunState = 0;
mdev.ManTaskReserve = 0;
mdev.ErrorCode = 0;
CStaticClass.WcfControl.BeginSetDeviceState(mdev, null, null);
dbo.ExecuteSql(string.Format("update T_BASE_DEVICE set f_lockedstate=0 where f_deviceindex=12692 and f_lockedstate=-1"));
mdev = Model.CGetInfo.GetDeviceInfo(12693);
mdev.RunState = 4;
mdev.ManTaskReserve = 0;
mdev.ErrorCode = 998;
CStaticClass.WcfControl.BeginSetDeviceState(mdev, null, null);
dbo.ExecuteSql(string.Format("update T_BASE_DEVICE set f_lockedstate=-1 where f_deviceindex=12693"));
break;
case 2:
mdev = Model.CGetInfo.GetDeviceInfo(12693);
mdev.RunState = 0;
mdev.ManTaskReserve = 0;
mdev.ErrorCode = 0;
CStaticClass.WcfControl.BeginSetDeviceState(mdev, null, null);
dbo.ExecuteSql(string.Format("update T_BASE_DEVICE set f_lockedstate=0 where f_deviceindex=12693 and f_lockedstate=-1"));
mdev = Model.CGetInfo.GetDeviceInfo(12692);
mdev.RunState = 4;
mdev.ManTaskReserve = 0;
mdev.ErrorCode = 998;
CStaticClass.WcfControl.BeginSetDeviceState(mdev, null, null);
dbo.ExecuteSql(string.Format("update T_BASE_DEVICE set f_lockedstate=-1 where f_deviceindex=12692"));
break;
}
dbo.ExecuteSql(String.Format("update T_BASE_IOMODE_SWITCH set station_inout_mode={0} where input_station_code={1}", inout_mode12661, 12661));
}
}
#endregion
}
#endregion
MessageBox.Show("������������ͨ�����ã�", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Information);
CommonClassLib.CCarryConvert.WriteDarkCasket("ϵͳ����", "UserID��" + CStaticClass.UserID + "�IJ�����־", "���������桿��ť", "����������������������������", "");
}
catch (Exception ex)
{
throw ex;
}
}
void WriteDBDataCallBack(IAsyncResult ar)
{
string errtext = string.Empty;
this.BeginInvoke(new MethodInvoker(delegate ()
{
if (CStaticClass.WcfControl.EndWriteDBData(out errtext, ar) == false)
{//12556,1,2
string[] devio = ar.AsyncState.ToString().Split(',');
if (devio[0] == "12556")
{
MessageBox.Show(string.Format("·��12556-12563�����������ɣ�{0}ת��Ϊ{1}ʱд��PLC��ַ��ʧ�ܣ�{2}", devio[1], devio[2], errtext), "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Load12556_12577();
}
else if (devio[0] == "12577")
{
MessageBox.Show(string.Format("·��12570-12577�����������ɣ�{0}ת��Ϊ{1}ʱд��PLC��ַ��ʧ�ܣ�{2}", devio[1], devio[2], errtext), "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Load12556_12577();
}
else if (devio[0] == "12660")
{
MessageBox.Show(string.Format("·��12660-12724�����������ɣ�{0}ת��Ϊ{1}ʱд��PLC��ַ��ʧ�ܣ�{2}", devio[1], devio[2], errtext), "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Load12660_12661();
}
else if (devio[0] == "12661")
{
MessageBox.Show(string.Format("·��12661-12725�����������ɣ�{0}ת��Ϊ{1}ʱд��PLC��ַ��ʧ�ܣ�{2}", devio[1], devio[2], errtext), "��������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Load12660_12661();
}
}
else
{
string[] devio = ar.AsyncState.ToString().Split(',');
dbo.ExecuteSql(String.Format("update T_BASE_IOMODE_SWITCH set station_inout_mode={0} where input_station_code={1}", devio[2], devio[0]));
}
}));
}
void SetDeviceStateCallBack(IAsyncResult ar)
{
string errtext = string.Empty;
this.BeginInvoke(new MethodInvoker(delegate ()
{
if (CStaticClass.WcfControl.EndSetDeviceState(out errtext, ar) == false)
{
MessageBox.Show(errtext, "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}));
}
private void splitAheadDetect(string[] AheadDetect, out StringBuilder outSBUnswitchRemark)
{
StringBuilder sBinput_station_codeNotUpdate = new StringBuilder("");
StringBuilder sbUnswitchRemark = new StringBuilder("");
string[] DS;
char[] dd = new char[1] { '.' };
int tempdevice = 0;
Model.MDevice mDevice;
try
{
for (int k = AheadDetect.GetLowerBound(0); k <= AheadDetect.GetUpperBound(0); k++)
{
if (AheadDetect[k].Trim().Length <= 0) continue;
if (AheadDetect[k].Trim().Substring(0, 1).ToUpper() == "I")//�Ƿ�����
{
tempdevice = Convert.ToInt32(AheadDetect[k].Trim().Substring(1));
mDevice = Model.CGetInfo.GetDeviceInfo(tempdevice);
if (mDevice == null) continue;
#region �Ƿ�����
if (mDevice.RunState != 0)
{//������
sbUnswitchRemark.Append(tempdevice).Append("������"); ;
}
#endregion
}
else if (AheadDetect[k].Trim().Substring(0, 1).ToUpper() == "D")//�Ƿ��޻�
{
#region �Ƿ��޻�
int devicebyte = 0, devbit = 0;
DS = AheadDetect[k].Trim().Substring(1).Split(dd);
int.TryParse(DS[0], out devicebyte);
int.TryParse(DS[1], out devbit);
//�ж��Ƿ�������������ֵ�����������Ƿ����㿪������0�޻���
if (devicebyte > 0)
{
mDevice = Model.CGetInfo.GetDeviceInfo(devicebyte);
if (mDevice == null) continue;
switch (devbit)
{
case 0:
if (mDevice.SplitByte_0 == 1)
{
sbUnswitchRemark.Append(".0���⿪�ر��ڵ���");
}
break;
case 1:
if (mDevice.SplitByte_1 == 1)
{
sbUnswitchRemark.Append(".1���⿪�ر��ڵ���");
}
break;
case 2:
if (mDevice.SplitByte_2 == 1)
{
sbUnswitchRemark.Append(".2���⿪�ر��ڵ���");
}
break;
case 3:
if (mDevice.SplitByte_3 == 1)
{
sbUnswitchRemark.Append(".3���⿪�ر��ڵ�");
}
break;
case 4:
if (mDevice.SplitByte_4 == 1)
{
sbUnswitchRemark.Append(".4���⿪�ر��ڵ���");
}
break;
case 5:
if (mDevice.SplitByte_5 == 1)
{
sbUnswitchRemark.Append(".5���⿪�ر��ڵ���");
}
break;
case 6:
if (mDevice.SplitByte_6 == 1)
{
sbUnswitchRemark.Append(".6���⿪�ر��ڵ���");
}
break;
case 7:
if (mDevice.SplitByte_7 == 1)
{
sbUnswitchRemark.Append(".7���⿪�ر��ڵ���");
}
break;
}
}
else
{//�ж��Ƿ����⸺������ֵ�����������Ƿ����㿪������1������Ӧ�ó���
}
#endregion
}
else if (AheadDetect[k].Trim().Substring(0, 1).ToUpper() == "U")//�Ƿ�������
{
tempdevice = Convert.ToInt32(AheadDetect[k].Trim().Substring(1));
mDevice = Model.CGetInfo.GetDeviceInfo(tempdevice);
if (mDevice == null) continue;
#region �Ƿ�������
sql.Clear();
sql.Append(string.Format("SELECT F_MonitorIndex FROM T_Monitor_Task WHERE (F_NumParam1 = {0} or F_NumParam4 = {0}) ", tempdevice));
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
if (dv.Count > 0)
{
sbUnswitchRemark.Append("��������");
}
#endregion
}
else
{
}
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
outSBUnswitchRemark = sbUnswitchRemark;
}
}
private void FrmIOStation_FormClosing(object sender, FormClosingEventArgs e)
{
_formInstance = null;
}
void Load12556_12577()
{
DataView dv = dbo.ExceSQL(string.Format(
"select station_inout_mode,switch_to_input_detect,switch_to_output_detect from T_BASE_IOMODE_SWITCH where input_station_code={0}"
, 12556)).Tables[0].DefaultView;
if (dv.Count > 0)
{
if (dv[0]["station_inout_mode"].ToString() == "1")
{
rb125561.Checked = true;
rb125562.Checked = false;
rb125563.Checked = false;
rb125560.Checked = false;
}
else if (dv[0]["station_inout_mode"].ToString() == "2")
{
rb125561.Checked = false;
rb125562.Checked = true;
rb125563.Checked = false;
rb125560.Checked = false;
}
else if (dv[0]["station_inout_mode"].ToString() == "3")
{
rb125561.Checked = false;
rb125562.Checked = false;
rb125563.Checked = true;
rb125560.Checked = false;
}
else if (dv[0]["station_inout_mode"].ToString() == "0")
{
rb125561.Checked = false;
rb125562.Checked = false;
rb125563.Checked = false;
rb125560.Checked = true;
}
else
{
rb125561.Checked = false;
rb125562.Checked = true;
rb125563.Checked = false;
rb125560.Checked = false;
}
}
dv = dbo.ExceSQL(string.Format(
"select station_inout_mode,switch_to_input_detect,switch_to_output_detect from T_BASE_IOMODE_SWITCH where input_station_code={0}"
, 12577)).Tables[0].DefaultView;
if (dv.Count > 0)
{
if (dv[0]["station_inout_mode"].ToString() == "1")
{
rb125771.Checked = true;
rb125772.Checked = false;
rb125773.Checked = false;
rb125770.Checked = false;
}
else if (dv[0]["station_inout_mode"].ToString() == "2")
{
rb125771.Checked = false;
rb125772.Checked = true;
rb125773.Checked = false;
rb125770.Checked = false;
}
else if (dv[0]["station_inout_mode"].ToString() == "3")
{
rb125771.Checked = false;
rb125772.Checked = false;
rb125773.Checked = true;
rb125770.Checked = false;
}
else if (dv[0]["station_inout_mode"].ToString() == "0")
{
rb125771.Checked = false;
rb125772.Checked = false;
rb125773.Checked = false;
rb125770.Checked = true;
}
else
{
rb125771.Checked = true;
rb125772.Checked = false;
rb125773.Checked = false;
rb125770.Checked = false;
}
}
}
void Load12660_12661()
{
DataView dv = dbo.ExceSQL(string.Format(
"select station_inout_mode,switch_to_input_detect,switch_to_output_detect from T_BASE_IOMODE_SWITCH where input_station_code={0}"
, 12685)).Tables[0].DefaultView;
if (dv.Count > 0)
{//12685=12660
if (dv[0]["station_inout_mode"].ToString() == "1")
{
rb126601.Checked = true;
rb126602.Checked = false;
rb126600.Checked = false;
}
else if (dv[0]["station_inout_mode"].ToString() == "2")
{
rb126601.Checked = false;
rb126602.Checked = true;
rb126600.Checked = false;
}
else if (dv[0]["station_inout_mode"].ToString() == "0")
{
rb126601.Checked = false;
rb126602.Checked = false;
rb126600.Checked = true;
}
else
{
rb126601.Checked = true;
rb126602.Checked = false;
rb126600.Checked = false;
}
}
dv = dbo.ExceSQL(string.Format(
"select station_inout_mode,switch_to_input_detect,switch_to_output_detect from T_BASE_IOMODE_SWITCH where input_station_code={0}"
, 12692)).Tables[0].DefaultView;
if (dv.Count > 0)
{//12692=12661
if (dv[0]["station_inout_mode"].ToString() == "1")
{
rb126611.Checked = true;
rb126612.Checked = false;
rb126610.Checked = false;
}
else if (dv[0]["station_inout_mode"].ToString() == "2")
{
rb126611.Checked = false;
rb126612.Checked = true;
rb126610.Checked = false;
}
else if (dv[0]["station_inout_mode"].ToString() == "0")
{
rb126611.Checked = false;
rb126612.Checked = false;
rb126610.Checked = true;
}
else
{
rb126611.Checked = true;
rb126612.Checked = false;
rb126610.Checked = false;
}
}
}
private void FrmZCKSetIOStation_Load(object sender, EventArgs e)
{
Load12556_12577();
Load12660_12661();
}
}
}