using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Seagull.BarTender.Print;
using System.Data;
using System.Drawing;
using Microsoft.VisualBasic.PowerPacks;
//0
namespace TiesTest
{
class Common
{
public static string DevName = "JJC扎带测试系统";
public static string strDevName = ""; //设备名称 UNUSED
public static string Language = "";
public static string DrawingPath = ""; //图纸完整路径
public static string DrawingName = ""; //图纸名称不带扩展名
public static string DrawingDataPath = ""; //图纸扎带数据不带扩展名
public static string DrawingCfgPath = ""; //图纸配置数据不带扩展名
//public static string DrawingId = ""; //图纸ID号
public static int TiesIndexMaxNumInDrawing = 0; //图纸中使用的扎带的序号index的最大值,非扎带数量
public static int DrawingOptMode = 0; //0,编辑模式,1,检测模式 UNUSED
public static Point ClickPoint = new Point(); //图纸编辑时,鼠标左键按下的点坐标,用于传给扎带窗体
public static DataTable dtDrawingTies = new DataTable(); //图纸中的扎带表,编辑时将该表保存成XML格式后缀为dat的文件,检测时将xml格式的的dat文件读取到该表中
public static CfgType Cfg = new CfgType(); //配置信息
public static string UserID = ""; // 用户编号 实际上是用户名称
public static string UserName = ""; // 用户名 是管理员/操作工
public static string UserLevel = ""; // 用户级别
public static bool isNeedRegist = false; // 需要注册标志
public static string OperaterName = ""; // 操作工名称
public static string TiesCheckCommNum = ""; //串口号
public static bool ScanDrawingCodeEnter = false; //扫码打开图纸
public static bool DrawingCodeUniquenessCheck = false; //条码唯一性检测
public static bool LinkMes = false;
public static bool HolderPop = false;
public static int HolderPopTimesSec = 0;
public static bool HolderMoveUpCheck = false;
public static bool AutoRun = false;
public static int AutoRunTimesSec = 0;
public static bool MemoryCheck = false;
public static bool HolderLockCheck = false;
public static bool OutSideDrawingCheck = false;
public static int PhyPinMax = 0;
public static int TiesShapeRadius = 0;
public static bool PowerOnSelfCheck = false;
public static bool VoiceEn = false;
public static bool GenerateCheckLog = false;
public static int LedNum = 0; //LED指示灯数量
public static Engine PrintEngine = new Engine();
public const int ADD = 0;
public const int EDIT = 1;
public static UInt16 CommCnt; //通讯计数,用于同步
public static Byte FieldStrength;
public static Byte KeyVal;
public static UInt16 FieldStrengthKey; //场强 or键值
public static byte[] Data = new byte[4]; //16*18=288个导通数据
public static UInt16 InputStatus; //输入
public static UInt16 OutputCoil; //输出
public static string PhyPin = "";
public static string LockHolderPhyPin = "";
public static string[] ErrorInfoArray = new string[4096]; //错误信息
///
/// 修改数据表DataTable某一列的类型和记录值(正确步骤:1.克隆表结构,2.修改列类型,3.修改记录值,4.返回希望的结果)
///
/// 数据表DataTable
/// 数据表DataTable
public static DataTable UpdateDataTable(DataTable argDataTable)
{
DataTable dtResult = new DataTable();
dtResult = argDataTable.Clone(); //克隆表结构只有表头没有数据
foreach (DataColumn col in dtResult.Columns)
{
if (col.ColumnName == "TiesIndex")
{
//修改列类型
col.DataType = typeof(Int32);
}
}
foreach (DataRow row in argDataTable.Rows) //遍历源表,取出每条记录,添加到新表
{
DataRow rowNew = dtResult.NewRow();
//修改记录值
rowNew["TiesIndex"] = Convert.ToInt32(row["TiesIndex"]);
rowNew["TiesName"] = row["TiesName"];
rowNew["PhyPin"] = row["PhyPin"];
rowNew["Pos"] = row["Pos"];
rowNew["RedLedPin"] = row["RedLedPin"];
rowNew["GreLedPin"] = row["GreLedPin"];
rowNew["LockHolder"] = row["LockHolder"];
dtResult.Rows.Add(rowNew);
}
return dtResult;
}
//16进制的字节数组转16进制字符串
public static string byteToHexStr(byte[] bytes)
{
string returnStr = "";
if (bytes != null)
{
for (int i = 0; i < bytes.Length; i++)
{
returnStr += bytes[i].ToString("X2");
}
}
return returnStr;
}
}
public struct _TiesData //扎带点数据,用于构造检测时使用的图纸中所有的扎带信息表
{
public int TiesIndex; //扎带序号
public string TiesName; //扎带名称
public int LedNum; //LED指示灯数量 0,1,2
public string EndPin; //所对应的终止针
public bool bCheckOk; //检测通过
public bool bRedLedOn; //红灯打开
public bool bGreLedOn; //红灯打开
public OvalShape TiesShape; //扎带图形
}
}