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

413 lines
16 KiB
C#

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization.Formatters.Soap;
using System.Data;
using System.Xml.Serialization;
namespace Mesnac.Action.Feeding
{
/// <summary>
/// 上辅机系统全局常量和变量和方法
/// </summary>
public class Global
{
#region 协议头常量
/// <summary>
/// 协议头常量
/// </summary>
public class ProtocalHeader
{
/// <summary>
/// 计划执行协议头
/// 郑立兵于2013-8月添加
/// </summary>
public const string ReceiveExecPlanNumber = "9101"; //计划执行协议头
/// <summary>
/// 车数(计划数)修改协议头
/// 郑立兵于2013-9月添加
/// </summary>
public const string ReceiveModifyPlanNumber = "9102"; //车数(计划数)修改协议头
/// <summary>
/// Send计划协议头
/// </summary>
public const string ReceivePlanIpNumber = "9990";//Send计划协议头
/// <summary>
/// Send判断密炼及其秤状态提示
/// </summary>
public const string ReceiveMixStatuIpNumber = "9991";//Send判断密炼及其秤状态提示
/// <summary>
/// Send配方下传状态
/// </summary>
public const string ReceiveRecipeDownLoadStatu = "9992";//Send配方下传状态
//{
// 0正在下传基础配方......
// 18正在下传炭黑称量配方......
// 36正在下传油称量配方......
// 54正在下传胶料称量配方......
// 72正在下传密炼配方......
// 85正在开始称量......
// 95正在开始密炼......
// 100下传完毕!
// 101计划信息更新成功
//}
/// <summary>
/// Send Plc A区
/// </summary>
public const string ReceiveFirstPlcIpNumber = "9993"; //Send Plc A区
/// <summary>
/// Send Plc B区
/// </summary>
public const string ReceiveSecondPlcIpNumber = "9994"; //Send Plc B区
/// <summary>
/// /Base Info
/// </summary>
public const string ReceiveBaseStatu = "9995";//Base Info
/// <summary>
/// Alam Data
/// </summary>
public const string ReceiveAlarmDataIpNumber = "9997";//Alam Data
/// <summary>
/// 接收到称量参数协议头
/// </summary>
public const string ReceiveWeighParamIpNumber = "9998";//接收到称量参数协议头
/// <summary>
/// rubset:...:|ruberror...:|ThSet:...:|Therror...:|YSet:...:|Yerror:...:|/
/// </summary>
public const string ReceiveMixingIpNumber = "9999";
public const string ReceiveThirdStatusIpNumber = "5555";
/// <summary>
/// 实时生产时,"条码生成打印表" 每插入一条记录,则发送此消息 格式7002架子条码/
/// </summary>
public const string ReceiveJiepian = "7002"; //实时生产时,"条码生成打印表" 每插入一条记录,则发送此消息 格式7002架子条码/
/// <summary>
/// 实时密炼曲线,用于向生产网络发送实时密炼曲线
/// </summary>
public const string ReceiveCurveData = "6789";//实时密炼曲线,用于向生产网络发送实时密炼曲线
/// <summary>
/// 新配方开始生产时,产生的"车条码"的基数
/// </summary>
public const string ReceivePfbarcode = "9900"; //新配方开始生产时,产生的"车条码"的基数
/// <summary>
/// 胶料存盘数据 格式9996XX:XX:/
/// </summary>
public const string ReceiveSavePlyData = "9996";//胶料存盘数据 格式9996XX:XX:/
/// <summary>
/// 计划号
/// </summary>
public const string ReceivePlanIdIpNumber = "9100";//计划号
/// <summary>
/// 增加对于小料当成胶料来处理,但混炼步骤中有加小药步骤(即小料和胶料分开加)的情况
/// </summary>
public const string ReceiveHaveAddXLTag = "9300"; //2005-08-16 增加对于小料当成胶料来处理,但混炼步骤中有加小药步骤(即小料和胶料分开加)的情况
/// <summary>
/// 上辅机定义的状态点的状态信息
/// </summary>
public const string ReceiveSFJStatus = "9601"; //2005-10-14 上辅机定义的状态点的状态信息
/// <summary>
/// 密炼机定义的状态点的状态信息
/// </summary>
public const string ReceiveMixerStatus = "9602"; //2005-10-14 密炼机定义的状态点的状态信息
/// <summary>
/// 密炼机定义的状态点的状态信息
/// </summary>
public const string ReceiveXFJStatus = "9603"; //2005-10-14 下辅机定义的状态点的状态信息
/// <summary>
/// 要求输送系统强制输送
/// </summary>
public const string RecvSSReachBottom = "8848"; // 要求输送系统强制输送
//2006-2-10
/// <summary>
/// 0:计划开始1计划终止或者计划完成
/// </summary>
public const string ReceivePlanExecInfo = "8300"; //0:计划开始1计划终止或者计划完成
/// <summary>
/// 当前生产的物料的累计车次号由上辅机发送
/// </summary>
public const string ReceiveMonthId = "9255"; //2006-05-18 当前生产的物料的累计车次号由上辅机发送
/// <summary>
/// 当扫描的条码追溯重量或数量使用完毕后,向胶料秤客户端发送报警提示信息
/// </summary>
public const string ReceiveBarWarning = "9500"; //2006-12-18 当扫描的条码追溯重量或数量使用完毕后,向胶料秤客户端发送报警提示信息
/// <summary>
/// 接收网络修改计划次数
/// </summary>
public const string RecipeModifyPlanNum = "9501"; //接收网络修改计划次数
/// <summary>
/// 接收网络修改计划次数并修改完成
/// </summary>
public const string ModifyPlanNumFinish = "9502"; //接收网络修改计划次数并修改完成
/// <summary>
/// 当班生产人员卡片
/// </summary>
public const string ReceiveWorkerBarcode = "8100"; //当班生产人员卡片
/// <summary>
/// 修改车数
/// </summary>
public const string SendModifyNum = "8000";
/// <summary>
/// Receive要显示的计划协议头 格式date|shfit
/// </summary>
public const string SelectPlanIpNumber = "8001";//Receive要显示的计划协议头 格式date|shfit
/// <summary>
/// Receive计划协议头 格式date|shift|Name+code+set+finish~Name+code+set+finish........~
/// </summary>
public const string SendPlanIpNumber = "8002";//Receive计划协议头 格式date|shift|Name+code+set+finish~Name+code+set+finish........~
/// <summary>
/// Receive确认协议头
/// </summary>
public const string SendEnterIpNumber = "8003"; //Receive确认协议头
/// <summary>
/// Receive取消协议头
/// </summary>
public const string SendESCIpNumber = "8004"; //Receive取消协议头
/// <summary>
/// 0 Or 1;0:单个下传1连续运行
/// </summary>
public const string SendExcPlanIpNumber = "8005"; //0 Or 1;0:单个下传1连续运行
/// <summary>
/// Receive Stop Plan
/// </summary>
public const string SendStopPlanIpNumber = "8006"; //Receive Stop Plan
/// <summary>
/// Reset
/// </summary>
public const string SendResetInNumber = "8007"; //Reset
/// <summary>
/// 子系统增加计划 格式8008+":"+配方编码14位+":"+计划数
/// </summary>
public const string SendAddPlanIpNumbar = "8008"; //子系统增加计划 格式8008+":"+配方编码14位+":"+计划数
//2005-06-07
/// <summary>
/// 当班生产人员卡片
/// </summary>
public const string SendWorkerBarcode = "8100"; //当班生产人员卡片
//2005-06-09
/// <summary>
/// 扫描的架子条码
/// </summary>
public const string SendMaterBarcode = "8200"; //扫描的架子条码
//2005-07-11 //网络新下达的计划提示协议头
/// <summary>
/// 网络新下达的计划提示协议头
/// </summary>
public const string SendNetNewPlan = "7771";
//2011-03-18 //网络新下达的计划提示协议头
public const string SendNewMessage = "7772";
//2006-4-18
/// <summary>
/// 气力输送发送过来的日罐料位信息
/// </summary>
public const string SendWareInfo = "8500"; //气力输送发送过来的日罐料位信息
/// <summary>
/// 条码扫描错误信号
/// </summary>
public const string SendBarRight = "8311"; //条码扫描错误信号 2006-05-18
/// <summary>
/// 开始维修标志
/// </summary>
public const string SendRepair = "8322"; //开始维修标志 2007-8-8
//2011-10-21
/// <summary>
/// 网络罐设置变化
/// </summary>
public const string SendWareChange = "8400"; //网络罐设置变化
/// <summary>
/// 修改计划数
/// </summary>
public const string SendModifyPlanNum = "9501"; //修改计划数
/// <summary>
/// 锁定胶料秤输送
/// </summary>
public const string SendLockRubWeigh = "5555"; //锁定胶料秤输送
/// <summary>
/// 掺用胶料扫描
/// </summary>
public const string SendChanYong = "3701"; //掺用胶料扫描
/// <summary>
/// 掺用胶料扫描
/// </summary>
public const string SendStopChanYong = "3702"; //掺用胶料扫描
}
#endregion
#region 系统全局变量
/// <summary>
/// 系统全局变量
/// </summary>
public class PublicVar
{
#region 单例实现
private static PublicVar instance;
public static PublicVar Instance
{
get
{
if (instance == null)
{
instance = new PublicVar();
}
return instance;
}
}
private PublicVar()
{
}
#endregion
/// <summary>
/// 项目名称
/// </summary>
public string ProjectWizardName { get; set; }
/// <summary>
/// 当前生产车数取余等于1的车条码
/// </summary>
public string FirstLotBarCode { get; set; }
/// <summary>
/// 当前生产车数取余等于1的车的物料
/// </summary>
public string FirstLotMaterCode { get; set; }
/// <summary>
/// 当前架子的起始车次号
/// </summary>
public int FirstLotSerialId { get; set; }
/// <summary>
/// 当前架子的最后一车车次
/// </summary>
public int LastLotNum { get; set; }
/// <summary>
/// 当前架子的计划号
/// </summary>
public string FirstLotPlanId { get; set; }
/// <summary>
/// 炭黑扫描机台
/// </summary>
public string G_CBEquip { get; set; }
}
#endregion
#region 业务辅助方法
/// <summary>
/// 解析二进制位
/// </summary>
/// <param name="x">要解析的变量</param>
/// <param name="len">解析的长度</param>
/// <returns>返回解析的二进制值数组</returns>
public static int[] ParseBinaryValue(int x, int len)
{
int[] result = new int[len];
int b = 1;
for (int i = 0; i < len; i++)
{
result[i] = (x & b) == 0 ? 0 : 1;
b = b << 1;
}
return result;
}
/// <summary>
/// 根据称重类型获取物料类型(根据上辅机业务,物料类型目前只分为:炭黑、油料、粉料、胶料)
/// </summary>
/// <param name="weightType">称重类型</param>
/// <returns>返回向物料表中添加的物料类型</returns>
public static string GetMaterialTypeByWeightType(string weightType)
{
string materialType = String.Empty;
switch (weightType.Trim())
{
case "0":
materialType = "炭黑";
break;
case "1":
materialType = "油1";
break;
case "2":
materialType = "胶料";
break;
case "3":
materialType = "小料";
break;
case "4":
materialType = "粉料";
break;
case "5":
materialType = "油2";
break;
default:
materialType = String.Empty;
break;
}
return materialType;
}
/// <summary>
/// 根据称量类型获取罐的类型0-炭黑,1-油1,3-粉料,5-油2
/// </summary>
/// <param name="weightType">称量类型</param>
/// <returns>返回对应的罐的类型</returns>
public static string GetJarTypeByWeightType(string weightType)
{
string jarType = String.Empty;
switch (weightType.Trim())
{
case "0":
jarType = "炭黑";
break;
case "1":
jarType = "油1";
break;
case "2":
jarType = "胶料没有罐";
break;
case "3":
jarType = "粉料";
break;
case "4":
jarType = "小料没有罐";
break;
case "5":
jarType = "油2";
break;
default:
jarType = "获取失败";
break;
}
return jarType;
}
#endregion
}
}