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 + "的操作日志", "点击【保存】按钮", "电池片车间入出库正反向恒温库设置", "");
}
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 + "的操作日志", "点击【保存】按钮", "组件车间连廊入出库正反向设置", "");
}
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();
}
}
}