init: 导入项目到 meswork Gitea
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{0D55E2C7-82A4-4607-B4CC-E6CF2C1D1E4A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MesDataFunctionWebApi</RootNamespace>
|
||||
<AssemblyName>MesDataFunctionWebApi</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SccProjectName>
|
||||
</SccProjectName>
|
||||
<SccLocalPath>
|
||||
</SccLocalPath>
|
||||
<SccAuxPath>
|
||||
</SccAuxPath>
|
||||
<SccProvider>
|
||||
</SccProvider>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="AsyncIO">
|
||||
<HintPath>..\DLL\AsyncIO.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BasicData">
|
||||
<HintPath>..\DLL\BasicData.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BouncyCastle.Crypto">
|
||||
<HintPath>..\DLL\BouncyCastle.Crypto.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ConLink">
|
||||
<HintPath>..\DLL\ConLink.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.SharpZipLib">
|
||||
<HintPath>..\DLL\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MesControl">
|
||||
<HintPath>..\DLL\MesControl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MesWork.DeviceDriver">
|
||||
<HintPath>..\DLL\MesWork.DeviceDriver.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MesWork.PLC">
|
||||
<HintPath>..\DLL\MesWork.PLC.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Monitor.MesWork">
|
||||
<HintPath>..\DLL\Monitor.MesWork.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MQTTnet">
|
||||
<HintPath>..\DLL\MQTTnet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MQTTnet.Extensions.ManagedClient">
|
||||
<HintPath>..\DLL\MQTTnet.Extensions.ManagedClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NetMQ">
|
||||
<HintPath>..\DLL\NetMQ.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPOI">
|
||||
<HintPath>..\DLL\NPOI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPOI.OOXML">
|
||||
<HintPath>..\DLL\NPOI.OOXML.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPOI.OpenXml4Net">
|
||||
<HintPath>..\DLL\NPOI.OpenXml4Net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPOI.OpenXmlFormats">
|
||||
<HintPath>..\DLL\NPOI.OpenXmlFormats.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Opc.Ua.Client">
|
||||
<HintPath>..\DLL\Opc.Ua.Client.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Opc.Ua.Configuration">
|
||||
<HintPath>..\DLL\Opc.Ua.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Opc.Ua.Core">
|
||||
<HintPath>..\DLL\Opc.Ua.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpcUaHelper">
|
||||
<HintPath>..\DLL\OpcUaHelper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http">
|
||||
<HintPath>..\DLL\System.Net.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Formatting">
|
||||
<HintPath>..\DLL\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Web.Cors">
|
||||
<HintPath>..\DLL\System.Web.Cors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http">
|
||||
<HintPath>..\DLL\System.Web.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.Cors">
|
||||
<HintPath>..\DLL\System.Web.Http.Cors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.SelfHost">
|
||||
<HintPath>..\DLL\System.Web.Http.SelfHost.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="OpcOperation.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="WebApi\Controller\PLC.SaveData.Controller.cs" />
|
||||
<Compile Include="WebApi\Controller\PLC.Base.Controller.cs" />
|
||||
<Compile Include="WebApi\Controller\PLC.Read.Controller.cs" />
|
||||
<Compile Include="WebApi\Controller\PLC.Write.Controller.cs" />
|
||||
<Compile Include="WebApi\Controller\SQLCommon.Controller.cs" />
|
||||
<Compile Include="WebApi\InitWebApi.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Common\01DoWhatPlc\01_01DoWhatPlc.csproj">
|
||||
<Project>{0d1af432-439a-4920-8692-43ae139f5530}</Project>
|
||||
<Name>01_01DoWhatPlc</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\02DataLinkMesWork\00_DataLinkMesWork.csproj">
|
||||
<Project>{97127b87-d43d-457c-9894-5f2244e4d2e7}</Project>
|
||||
<Name>00_DataLinkMesWork</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\MES.BizFacade\02_P1.MIS.BizFacade.csproj">
|
||||
<Project>{f191342c-2dbe-4865-84c3-6b6a286c7686}</Project>
|
||||
<Name>02_P1.MIS.BizFacade</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\MesDataFunction\01_MesDataFunction.csproj">
|
||||
<Project>{594929d5-60d6-4049-9d3b-a6642b5ccb77}</Project>
|
||||
<Name>01_MesDataFunction</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\WebFun_base\MesWebFun_base.csproj">
|
||||
<Project>{f883e65c-8609-4f7e-9ada-8f9483207336}</Project>
|
||||
<Name>MesWebFun_base</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,81 @@
|
||||
using BasicData;
|
||||
using MesWork;
|
||||
using OpcBasic;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MesDataFunctionWebApi
|
||||
{
|
||||
public class LoadTagTypeCodeID
|
||||
{
|
||||
|
||||
public static void Load(string path)
|
||||
{
|
||||
OpcOperation.hashtable_TagType = new NameValueCollection() ;
|
||||
OpcOperation.hashtable_TagTypeTagName = new NameValueCollection();
|
||||
OpcOperation.hashtable_TagTypeChange = new NameValueCollection();
|
||||
OpcOperation.hashtable_MesTagTypeChange = new NameValueCollection();
|
||||
OpcOperation.hashtable_WebTagTypeChange = new NameValueCollection();
|
||||
OpcOperation.hashtable_TagTypeDataType = new NameValueCollection();
|
||||
|
||||
var dt = NPOITest.ExeclHelper.ExcelToDataTable(path, "变量类型代码", true);
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
//序号 变量类型 TagTypeDataType TagName 变量类型代码 TagTypeChange MesTagTypeChange WebTagTypeChange 信号点名称 变量类型名称
|
||||
|
||||
var TagTypeDataType = dt.Rows[i]["TagTypeDataType"].ToString();
|
||||
var TagName = dt.Rows[i]["TagName"].ToString();
|
||||
var 变量类型代码 = dt.Rows[i]["变量类型代码"].ToString();
|
||||
var TagTypeChange = dt.Rows[i]["TagTypeChange"].ToString();
|
||||
var WebTagTypeChange = dt.Rows[i]["WebTagTypeChange"].ToString();
|
||||
var MesTagTypeChange = dt.Rows[i]["MesTagTypeChange"].ToString();
|
||||
|
||||
OpcOperation.hashtable_TagType.Add(TagName, 变量类型代码);
|
||||
OpcOperation.hashtable_TagTypeTagName.Add(变量类型代码, TagName);
|
||||
OpcOperation.hashtable_TagTypeChange.Add(TagName, TagTypeChange);
|
||||
OpcOperation.hashtable_MesTagTypeChange.Add(TagName, MesTagTypeChange);
|
||||
OpcOperation.hashtable_WebTagTypeChange.Add(TagName, WebTagTypeChange);
|
||||
OpcOperation.hashtable_TagTypeDataType.Add(变量类型代码, TagTypeDataType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void Load(DataTable dt)
|
||||
{
|
||||
OpcOperation.hashtable_TagType = new NameValueCollection();
|
||||
OpcOperation.hashtable_TagTypeTagName = new NameValueCollection();
|
||||
OpcOperation.hashtable_TagTypeChange = new NameValueCollection();
|
||||
OpcOperation.hashtable_MesTagTypeChange = new NameValueCollection();
|
||||
OpcOperation.hashtable_WebTagTypeChange = new NameValueCollection();
|
||||
OpcOperation.hashtable_TagTypeDataType = new NameValueCollection();
|
||||
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
//序号 变量类型 TagTypeDataType TagName 变量类型代码 TagTypeChange MesTagTypeChange WebTagTypeChange 信号点名称 变量类型名称
|
||||
var TagTypeDataType = dt.Rows[i]["TagTypeDataType"].ToString();
|
||||
var TagName = dt.Rows[i]["TagName"].ToString();
|
||||
var 变量类型代码 = dt.Rows[i]["变量类型代码"].ToString();
|
||||
var TagTypeChange = dt.Rows[i]["TagTypeChange"].ToString();
|
||||
var WebTagTypeChange = dt.Rows[i]["WebTagTypeChange"].ToString();
|
||||
var MesTagTypeChange = dt.Rows[i]["MesTagTypeChange"].ToString();
|
||||
|
||||
OpcOperation.hashtable_TagType.Add(TagName, 变量类型代码);
|
||||
OpcOperation.hashtable_TagTypeTagName.Add(变量类型代码, TagName);
|
||||
OpcOperation.hashtable_TagTypeChange.Add(TagName, TagTypeChange);
|
||||
OpcOperation.hashtable_MesTagTypeChange.Add(TagName, MesTagTypeChange);
|
||||
OpcOperation.hashtable_WebTagTypeChange.Add(TagName, WebTagTypeChange);
|
||||
OpcOperation.hashtable_TagTypeDataType.Add(变量类型代码, TagTypeDataType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
""
|
||||
{
|
||||
"FILE_VERSION" = "9237"
|
||||
"ENLISTMENT_CHOICE" = "NEVER"
|
||||
"PROJECT_FILE_RELATIVE_PATH" = "relative:MesDataFunction"
|
||||
"NUMBER_OF_EXCLUDED_FILES" = "0"
|
||||
"ORIGINAL_PROJECT_FILE_PATH" = ""
|
||||
"NUMBER_OF_NESTED_PROJECTS" = "0"
|
||||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using DataLinkMesWork;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
public class InitTagValueListData
|
||||
{
|
||||
public InitTagValueListData()
|
||||
{
|
||||
DataTable dt = ReadMesServerData();
|
||||
|
||||
InitMesReadTagKey();
|
||||
initAllItemValue(dt);
|
||||
}
|
||||
|
||||
DataTable ReadMesServerData()
|
||||
{
|
||||
return MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 监控属性代码 = '{ApplicationConfig.MES_Code.ToString()}'").CopyToDataTable<DataRow>();
|
||||
}
|
||||
|
||||
void InitMesReadTagKey()
|
||||
{
|
||||
DataTable dt = MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 变量类型代码=19 and 监控属性代码 = '{ApplicationConfig.MES_Code.ToString()}'").CopyToDataTable<DataRow>(); ;
|
||||
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
if (MesReadTagKey_Hash.ContainsKey(dt.Rows[i]["工位号"].ToString()))
|
||||
{
|
||||
MesReadTagKey_Hash[dt.Rows[i]["工位号"].ToString()] = dt.Rows[i]["TagID"].ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
MesReadTagKey_Hash.Add(dt.Rows[i]["工位号"].ToString(), dt.Rows[i]["TagID"].ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void initAllItemValue(DataTable dt)
|
||||
{
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
if (ItemValue_Hash.ContainsKey(dt.Rows[i]["TagID"]))
|
||||
{
|
||||
if (Convert.ToInt32(dt.Rows[i]["列位置"]) != 0)
|
||||
{
|
||||
ItemValue_Hash[dt.Rows[i]["TagID"]] = dt.Rows[i]["测量项目"].ToString() + "(" + dt.Rows[i]["列位置"].ToString() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemValue_Hash[dt.Rows[i]["TagID"]] = dt.Rows[i]["测量项目"].ToString();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Convert.ToInt32(dt.Rows[i]["列位置"]) != 0)
|
||||
{
|
||||
ItemValue_Hash[dt.Rows[i]["TagID"]] = dt.Rows[i]["测量项目"].ToString() + "(" + dt.Rows[i]["列位置"].ToString() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemValue_Hash[dt.Rows[i]["TagID"]] = dt.Rows[i]["测量项目"].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Hashtable MesReadTagKey_Hash = new Hashtable();
|
||||
public static Hashtable ItemValue_Hash = new Hashtable();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
|
||||
using System.Windows.Forms;
|
||||
using bizFacade;
|
||||
using System.Collections.Specialized;
|
||||
using MesWork;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
static object lockerBarcode = new object();
|
||||
|
||||
/// <summary>
|
||||
///1.扫描配送单号,用于接收物料,扫描单号的时候,将接收的物料信息显示在“物料拉动”Tab区域
|
||||
///2.扫描料箱标签/看板卡,用于追溯物料批次信息
|
||||
///3.扫描零件条码,根据零件图号进行防错
|
||||
///第一步,判断条码类型,根据条码类型,执行对应的存储过程
|
||||
///第二步,条码类型(将扫描的条码保存到对应的表中)
|
||||
///第三步,扫描完成之后给出允许工作信号
|
||||
/// 处理页面扫描条码
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="barcode"></param>
|
||||
static public void Barcode(object e)
|
||||
{
|
||||
lock (lockerBarcode)
|
||||
{
|
||||
try
|
||||
{
|
||||
OpcData.CustomeEvetnArgs msgEvent = (OpcData.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
string barcode = Convert.ToString(msgEvent.TagValue);
|
||||
string AlarmStr = "";
|
||||
|
||||
int IsAllowWork;
|
||||
int IsSuccess = 0;
|
||||
bool EngineGetOver_PLC_NextWorkStep;
|
||||
//传递机型是否到位
|
||||
MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep);
|
||||
|
||||
BaseDataSystemMES.PartMaterial_DM_Update(OpName, barcode, out IsSuccess);
|
||||
if (IsSuccess == 0)
|
||||
{
|
||||
AsyncSendMessage_Notice(OpName, "条码无效,请确认");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
SendInfomation("MaterialList", "1", OpName);//通知界面更新零件信息
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获取是否允许工作
|
||||
BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork);
|
||||
|
||||
//此处逻辑有问题 需要考虑到批次扫描 提示PLC未传递机型的情况
|
||||
if (EngineGetOver_PLC_NextWorkStep && IsSuccess == 1)
|
||||
{
|
||||
if (IsAllowWork == 1)
|
||||
{
|
||||
BaseDataSystemMES.Material_Insert(OpName, 1);
|
||||
|
||||
//if (!BaseDataSystemMES.QualityVerifyStatusOutline(OpName, out AlarmStr))
|
||||
//{
|
||||
// SendInfomation("LineoutAlert", AlarmStr, OpName);
|
||||
// return;
|
||||
//}
|
||||
//通知PLC允许工作,允许工作在保存完成时清空
|
||||
MIS_BASE.Write_FixAllow(OpName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
AsyncSendMessage_Notice(OpName, "请扫描物料!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AsyncSendMessage_Notice(OpName, "PLC未传递机型");
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "Function02:Barcode");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
|
||||
using System.Windows.Forms;
|
||||
using bizFacade;
|
||||
using System.Collections.Specialized;
|
||||
using MesWork;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
static object lockerConfirmOkGo = new object();
|
||||
|
||||
static public void ConfirmOkGo(object e)
|
||||
{
|
||||
lock (lockerConfirmOkGo)
|
||||
{
|
||||
try
|
||||
{
|
||||
OpcData.CustomeEvetnArgs msgEvent = (OpcData.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||||
|
||||
if (tagValue == 1)
|
||||
{
|
||||
|
||||
//BaseDataSystemMES.Material_Insert(OpName, 1);
|
||||
|
||||
//更新订单完工数量及物料
|
||||
Sendmessage("24", "11", OpName);
|
||||
|
||||
//工作完成
|
||||
MIS_BASE.Write_MaterialVerifyOver(OpName, true);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
|
||||
using System.Windows.Forms;
|
||||
using bizFacade;
|
||||
using System.Collections.Specialized;
|
||||
using MesWork;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
static object lockerEngineTypeGetOver_PLC_Work = new object();
|
||||
|
||||
|
||||
static public void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code)
|
||||
{
|
||||
lock (lockerEngineTypeGetOver_PLC_Work)
|
||||
{
|
||||
int IsAllowWork;
|
||||
int RepairPartStatusPLC = 0;
|
||||
int MES_QualityMask = 1;
|
||||
string OrderForm = "";//订单号
|
||||
DataTable dt;
|
||||
|
||||
if (EngineTypeID <= 0)
|
||||
{
|
||||
AsyncSendMessage_Notice(OpName, "PLC传递机型为空");
|
||||
return;
|
||||
}
|
||||
|
||||
//第一步,查询订单号,保存机型、机型代码、总成号、托盘号、订单号到数据库
|
||||
BaseDataSystemMES.GetEngineID_Select(OpName, EngineID, out dt);
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
OrderForm = Convert.ToString(dt.Rows[0]["订单号"]);
|
||||
}
|
||||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, OrderForm, EngineTypeID, EngineType, EngineID, PartPallet_Code, 0, 0, "");
|
||||
SaveMobyMessage(OpName, EngineTypeID, EngineType, EngineID, OrderForm);
|
||||
|
||||
//第二步,将零件信息转移到零件_临时表中(本地BOM与订单BOM的选择显示关系)
|
||||
BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName);
|
||||
|
||||
//通知web显示
|
||||
Sendmessage("5123", "1111", OpName);
|
||||
MIS_BASE.Read_PalletInfo(OpName, out MES_QualityMask);//合格标志
|
||||
MIS_BASE.Read_RepairStatus_PLC(OpName, out RepairPartStatusPLC);//返修标志
|
||||
SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);//显示合格标志
|
||||
SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);//显示返修标志
|
||||
|
||||
if (MES_QualityMask == 2)
|
||||
{
|
||||
//工作完成
|
||||
MIS_BASE.Write_MaterialVerifyOver(OpName, true);
|
||||
SendInfomation("NgGO", "1", OpName);//显示不合格标志
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//第三步,用于工件离开后完工数量统计及工件编号追溯
|
||||
BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);//更新订单产量
|
||||
|
||||
//第四步,获取是否允许工作
|
||||
BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork);
|
||||
|
||||
//暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况
|
||||
if (IsAllowWork == 1)
|
||||
{
|
||||
//通知PLC允许工作,允许工作在保存完成时清空
|
||||
MIS_BASE.Write_FixAllow(OpName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
AsyncSendMessage_Notice(OpName, "请扫描物料!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存MOBY信息
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="engineTypeID"></param>
|
||||
/// <param name="engineType"></param>
|
||||
/// <param name="engineID"></param>
|
||||
static private void SaveMobyMessage(string OpName, int engineTypeID, string engineType, string engineID, string orderForm)
|
||||
{
|
||||
if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID.ContainsKey(OpName))
|
||||
{
|
||||
MIS_BASE.hashtable_EngineGetOver_EngineTypeID[OpName] = engineTypeID;
|
||||
}
|
||||
if (MIS_BASE.hashtable_EngineGetOver_EngineType.ContainsKey(OpName))
|
||||
{
|
||||
MIS_BASE.hashtable_EngineGetOver_EngineType[OpName] = engineType;
|
||||
}
|
||||
if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName))
|
||||
{
|
||||
MIS_BASE.hashtable_EngineGetOver_EngineID[OpName] = engineID;
|
||||
}
|
||||
if (MIS_BASE.hashtable_EngineGetOver_OrderForm.ContainsKey(OpName))
|
||||
{
|
||||
MIS_BASE.hashtable_EngineGetOver_OrderForm[OpName] = orderForm;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返修件需要工作
|
||||
/// </summary>
|
||||
/// <param name="OpName">工位号</param>
|
||||
static private void IsNeedRepaire_OK(string OpName)
|
||||
{
|
||||
string orderForm = "";
|
||||
int engineTypeID;
|
||||
string engineType = "";
|
||||
string engineID = "";
|
||||
string palletCode = "";
|
||||
int isRepair;
|
||||
string repairCode = "";
|
||||
//从监控系统中查询出本工位信息
|
||||
BaseDataSystemMES.OpName_MIS_Moby_Select(OpName,
|
||||
out orderForm, out engineTypeID, out engineType,
|
||||
out engineID, out palletCode, out isRepair, out repairCode);
|
||||
|
||||
EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
|
||||
using System.Windows.Forms;
|
||||
using bizFacade;
|
||||
using System.Collections.Specialized;
|
||||
using MesWork;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
static object lockerFalseGO = new object();
|
||||
|
||||
|
||||
static public void FalseGO(object e)
|
||||
{
|
||||
lock (lockerConfirmOkGo)
|
||||
{
|
||||
try
|
||||
{
|
||||
OpcData.CustomeEvetnArgs msgEvent = (OpcData.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||||
|
||||
if (tagValue == 1)
|
||||
{
|
||||
//总合格标志2(不合格)
|
||||
|
||||
//BaseDataSystemMES.Material_Insert_NG(OpName, 2);
|
||||
|
||||
Sendmessage("24", "11", OpName);
|
||||
|
||||
//工作完成
|
||||
MIS_BASE.Write_MaterialVerifyOver(OpName, true);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "Function02:FalseGO");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
|
||||
using System.Windows.Forms;
|
||||
using bizFacade;
|
||||
using System.Collections.Specialized;
|
||||
using MesWork;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
static object lockerMaterial_Insert = new object();
|
||||
|
||||
static public void Material_Insert(string OpName)
|
||||
{
|
||||
lock (lockerMaterial_Insert)
|
||||
{
|
||||
try
|
||||
{
|
||||
//int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||||
int IsAllowWork;
|
||||
//第四步,获取是否允许工作
|
||||
BaseDataSystemMES.MesServer_Judge_IsCanWork(OpName, out IsAllowWork);
|
||||
bool EngineGetOver_PLC_NextWorkStep;
|
||||
//传递机型是否到位
|
||||
MIS_BASE.Read_EngineGetOver_PLC(OpName, out EngineGetOver_PLC_NextWorkStep);
|
||||
|
||||
//暂时先定义为扫描完成才能进行压装工作,因为考虑到工作完成后,操作工未必会去扫描物料的情况
|
||||
if (EngineGetOver_PLC_NextWorkStep&&IsAllowWork == 1)
|
||||
{
|
||||
BaseDataSystemMES.Material_Insert(OpName, 1);
|
||||
|
||||
//更新订单完工数量及物料
|
||||
Sendmessage("24", "11", OpName);
|
||||
|
||||
//工作完成
|
||||
MIS_BASE.Write_MaterialVerifyOver(OpName, true);
|
||||
//通知PLC允许工作,允许工作在保存完成时清空
|
||||
MIS_BASE.Write_FixAllow(OpName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
AsyncSendMessage_Notice(OpName, "请扫描物料!");
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "Function02:ConfirmOkGo");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
|
||||
using System.Windows.Forms;
|
||||
using bizFacade;
|
||||
using System.Collections.Specialized;
|
||||
using MesWork;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
static object lockerMesReadOver = new object();
|
||||
|
||||
/// <summary>
|
||||
/// 保存完成(针对半自动和手动压装工位)
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
static public void MesReadOver(object e)
|
||||
{
|
||||
lock (lockerMesReadOver)
|
||||
{
|
||||
try
|
||||
{
|
||||
OpcData.CustomeEvetnArgs msgEvent = (OpcData.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
var tagValue = msgEvent.TagValue.ToString();
|
||||
|
||||
if (tagValue == "1" | tagValue.ToLower() == "true")
|
||||
{
|
||||
int qualityMask;
|
||||
MIS_BASE.Read_QualityMask(OpName, out qualityMask);
|
||||
|
||||
SendInfomation("ShowTimelyQuality", "1&" + qualityMask.ToString(), OpName);//发给Web页面显示质量数据
|
||||
|
||||
if (qualityMask == 1)//全部OK,给出合格放行
|
||||
{
|
||||
//如果存在线外扫描工位,根据扫描条码绑定线外数据 需要时解除禁用
|
||||
//BaseDataSystemMES.TransLaunchDataByMainMaterial(OpName, EngineType, EngineID, EngineTypeID);
|
||||
|
||||
//如果存在线外排队工位,根据排队编号绑定线外数据 需要时解除禁用
|
||||
////BaseDataSystemMES.MailLineAndSubLineData_InsertByEngineID_Subline(OpName,EngineID, EngineTypeID, EngineType);
|
||||
|
||||
MIS_BASE.Write_ConfirmOkGo(OpName, true);
|
||||
//MIS_BASE.Write_FalseGO(OpName, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//MIS_BASE.Write_ConfirmOkGo(OpName, false);
|
||||
MIS_BASE.Write_FalseGO(OpName, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "Function02:MesReadOver");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
|
||||
using System.Windows.Forms;
|
||||
using bizFacade;
|
||||
using System.Collections.Specialized;
|
||||
using MesWork;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 发送提示消息
|
||||
/// </summary>
|
||||
/// <param name="Message"></param>
|
||||
static private void AsyncSendMessage_Notice(string opname, string notice)
|
||||
{
|
||||
//通知Web界面
|
||||
BaseDataSystemMES.Web_Notice_Insert(opname, notice);
|
||||
string SendMessage = "MES|Notice|" + opname + "|" + "1";
|
||||
MIS_BASE.asyncSendMessage(SendMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向WEB发送信息(value为字符串)
|
||||
/// </summary>
|
||||
/// <param name="Command">消息种类</param>
|
||||
/// <param name="Value">消息内容</param>
|
||||
/// <param name="OpName">工位号</param>
|
||||
static string SendInfomation(string Command, string Value, string OpName)
|
||||
{
|
||||
string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value;
|
||||
return AsyncSendMessage(SendMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送信息到MES通讯服务器或者其他的
|
||||
/// </summary>
|
||||
/// <param name="Message"></param>
|
||||
static private string AsyncSendMessage(string Message)
|
||||
{
|
||||
return MIS_BASE.asyncSendMessage(Message);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 批量发送WEB消息(Value为BOOL值)
|
||||
/// </summary>
|
||||
/// <param name="MessageNumm">消息编号组合</param>
|
||||
/// <param name="Value">消息值组合</param>
|
||||
/// <param name="OpName">工位号</param>
|
||||
static void Sendmessage(string MessageNumm, string Value, string OpName)
|
||||
{
|
||||
for (int i = 0; i < MessageNumm.Length; i++)
|
||||
{
|
||||
Sendmessage(MessageNumm[i], Value[i].ToString(), OpName);
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 选择发送给WEB的消息
|
||||
/// </summary>
|
||||
/// <param name="Num">消息类型</param>
|
||||
/// <param name="OpName">消息工位</param>
|
||||
static string Sendmessage(char Num, string Value, string OpName)
|
||||
{
|
||||
string SendMessage;
|
||||
string result = "";
|
||||
switch (Num)
|
||||
{
|
||||
case '1':
|
||||
//1(直接在界面通过选择机型确认工序内容)
|
||||
SendMessage = "MES|ProcessList|" + OpName + "|" + Value;
|
||||
result = AsyncSendMessage(SendMessage);
|
||||
break;
|
||||
case '2':
|
||||
//2显示物料
|
||||
SendMessage = "MES|MaterialList|" + OpName + "|" + Value;
|
||||
result = AsyncSendMessage(SendMessage);
|
||||
break;
|
||||
case '3':
|
||||
//3显示操作指导图片
|
||||
SendMessage = "MES|PicShow|" + OpName + "|" + Value;
|
||||
result = AsyncSendMessage(SendMessage);
|
||||
break;
|
||||
case '4':
|
||||
//4订单完工模块刷新完成数量
|
||||
SendMessage = "MES|OrderFormList|" + OpName + "|" + Value;
|
||||
AsyncSendMessage(SendMessage);
|
||||
break;
|
||||
case '5':
|
||||
SendMessage = "MES|ShowMoby|" + OpName + "|" + Value;
|
||||
result = AsyncSendMessage(SendMessage);
|
||||
break;
|
||||
case '6':
|
||||
SendMessage = "MES|MaterialCheckPosition|" + OpName + "|" + Value;
|
||||
result = AsyncSendMessage(SendMessage);
|
||||
break;
|
||||
case '7':
|
||||
SendMessage = "MES|WorkStart|" + OpName + "|" + Value;
|
||||
result = AsyncSendMessage(SendMessage);
|
||||
break;
|
||||
case '8'://清除MES生成编号
|
||||
|
||||
break;
|
||||
case '9':
|
||||
SendMessage = "MES|ConfirmOkGo|" + OpName + "|" + Value;
|
||||
result = AsyncSendMessage(SendMessage);
|
||||
break;
|
||||
case 'a':
|
||||
SendMessage = "MES|FixAllow|" + OpName + "|" + Value;
|
||||
result = AsyncSendMessage(SendMessage);
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
///// <summary>
|
||||
///// 向WEB发送信息(value为字符串)
|
||||
///// </summary>
|
||||
///// <param name="Command">消息种类</param>
|
||||
///// <param name="Value">消息内容</param>
|
||||
///// <param name="OpName">工位号</param>
|
||||
//string SendInfomation(string Command, string Value, string OpName)
|
||||
//{
|
||||
// string SendMessage = "MES|" + Command + "|" + OpName + "|" + Value;
|
||||
// return AsyncSendMessage(SendMessage);
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 发送在线产量、在线节拍
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
private void SendActuallyCount(string OpName, int tagValue)
|
||||
{
|
||||
//当工件离开时,更新在线产量、在线节拍
|
||||
if (tagValue == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
int opNameCount = 0;//在线产量
|
||||
int opNameCountTime = 0;//在线节拍
|
||||
//基本数据_工作日历_班次产量查询_New
|
||||
BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime);
|
||||
string SendMessage;
|
||||
SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString();
|
||||
AsyncSendMessage(SendMessage);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "Function02:SendActuallyCount");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
|
||||
using System.Windows.Forms;
|
||||
using bizFacade;
|
||||
using System.Collections.Specialized;
|
||||
using MesWork;
|
||||
using SystemFramework;
|
||||
using System.Threading;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
static object lockerWebSubmit = new object();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 处理WEB页面发送过来的请求(m_Command + "|" + m_Value;)
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="Content"></param>
|
||||
static public void WebSubmit(object e)
|
||||
{
|
||||
lock (lockerWebSubmit)
|
||||
{
|
||||
try
|
||||
{
|
||||
OpcData.CustomeEvetnArgs msgEvent = (OpcData.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
string Content = Convert.ToString(msgEvent.TagValue);
|
||||
|
||||
string[] dataArray = Content.Split('|');
|
||||
if (dataArray.Length != 2)
|
||||
return;
|
||||
//消息类型
|
||||
string m_Command = dataArray[0].ToString();
|
||||
//消息参数
|
||||
string m_Value = dataArray[1].ToString();
|
||||
//消息参数数量
|
||||
string[] m_Value_array = m_Value.Split('&');
|
||||
//消息参数长度
|
||||
int m_Value_length = m_Value_array.Length;
|
||||
|
||||
//工件信息
|
||||
string engineID = "";
|
||||
if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName))
|
||||
{
|
||||
engineID = MIS_BASE.hashtable_EngineGetOver_EngineID[OpName].ToString();
|
||||
}
|
||||
|
||||
OpcData.CustomeEvetnArgs _e = new OpcData.CustomeEvetnArgs();
|
||||
_e.OpName = OpName;
|
||||
_e.TagValue = m_Value;
|
||||
|
||||
//根据请求的命令处理逻辑
|
||||
switch (m_Command)
|
||||
{
|
||||
case "Barcode":
|
||||
if (m_Value_length > 1) return;
|
||||
fun_Barcode(_e);
|
||||
break;
|
||||
case "ConfirmOkGo"://合格放行
|
||||
//删除不合格放行记录
|
||||
//修改托盘状态
|
||||
//Update_PalletStatus(OpName, 1, false);
|
||||
BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID);
|
||||
MIS_BASE.Write_ConfirmOkGo(OpName, true);
|
||||
MIS_BASE.Write_FalseGO(OpName, false);
|
||||
break;
|
||||
case "FalseGO"://返修放行
|
||||
//修改托盘状态
|
||||
//Update_PalletStatus(OpName, 3, false);
|
||||
BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Delete(OpName, engineID);
|
||||
MIS_BASE.Write_FalseGO(OpName, true);
|
||||
MIS_BASE.Write_ConfirmOkGo(OpName, false);
|
||||
break;
|
||||
case "NgGO"://不合格放行
|
||||
//修改托盘状态
|
||||
//Update_PalletStatus(OpName, 2, false);
|
||||
//保存不合格信息(必须保存不合格放行信息,由于B5A的Moby没有不合格标志位)
|
||||
BaseDataSystemMES.BaseData_tagTable_Engine_IsNG_Insert(OpName, engineID, "", "");
|
||||
MIS_BASE.Write_FalseGO(OpName, true);
|
||||
MIS_BASE.Write_ConfirmOkGo(OpName, false);
|
||||
break;
|
||||
case "OnLineState"://在线0、离线1、屏蔽2
|
||||
try
|
||||
{
|
||||
if (m_Value_length > 1) return;
|
||||
int a = Convert.ToInt32(m_Value);
|
||||
if (a <= 2)
|
||||
{
|
||||
BaseDataSystemMES.IsOnLine_Update(OpName, m_Value.ToString());
|
||||
MIS_BASE.Write_OnLineState(OpName, Convert.ToInt32(m_Value));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
case "Reset"://复位,将MES所有的信息都复位了
|
||||
SetMoby(OpName);//将MES所有信号清空
|
||||
break;
|
||||
case "FixAllow"://重新拧紧
|
||||
MIS_BASE.Write_FixAllow(OpName, false);
|
||||
MIS_BASE.Write_FixAllow(OpName, true);
|
||||
break;
|
||||
case "IsAutoGetEngineID"://自动手动申请编号(线首)
|
||||
if (m_Value_length > 1) return;
|
||||
MIS_BASE.Write_IsAutoGetEngineID(OpName, Convert.ToInt32(m_Value));
|
||||
break;
|
||||
case "PartPalletGoOver"://空托盘放行
|
||||
int Is_PartPalletGoOver;
|
||||
MIS_BASE.Read_PartPalletGoOver(OpName, out Is_PartPalletGoOver);
|
||||
if (Is_PartPalletGoOver == 1)
|
||||
{
|
||||
MIS_BASE.Write_PartPalletGoOver(OpName, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
MIS_BASE.Write_PartPalletGoOver(OpName, 0);
|
||||
}
|
||||
break;
|
||||
case "SetMoby"://清空托盘(线首)
|
||||
SetMoby(OpName);//将MES所有信号清空
|
||||
//MIS_BASE.Write_PartPalletCode_PLC(OpName, 1);
|
||||
break;
|
||||
case "RepairUplineMES"://返修上线
|
||||
MIS_BASE.Write_RepairUpline_MES(OpName, true);
|
||||
break;
|
||||
case "CancelRepair"://将返修件置为正常件
|
||||
|
||||
break;
|
||||
case "PartPalletCode"://申请写入托盘号
|
||||
//MIS_BASE.Write_PartPalletCode_PLC(OpName, 1);
|
||||
break;
|
||||
case "WritePartPalletCode"://写入托盘号
|
||||
if (m_Value_length > 1) return;
|
||||
MIS_BASE.Write_PalletCode(OpName, Convert.ToInt32(m_Value));
|
||||
break;
|
||||
case "Normal"://启用正常拧紧工位
|
||||
MIS_BASE.Write_Normal(OpName, 1);
|
||||
MIS_BASE.Write_UnNormal(OpName, 0);
|
||||
break;
|
||||
case "UnNormal"://启用备用拧紧工位
|
||||
MIS_BASE.Write_Normal(OpName, 0);
|
||||
MIS_BASE.Write_UnNormal(OpName, 1);
|
||||
break;
|
||||
case "ResetDevice"://复位设备
|
||||
MIS_BASE.Write_ResetDevice(OpName, true);
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
MIS_BASE.Write_ResetDevice(OpName, false);
|
||||
break;
|
||||
case "IsNeedRepaire"://返修上线(返修上线点)
|
||||
if (Convert.ToInt32(m_Value) == 1)
|
||||
{
|
||||
//修改托盘状态
|
||||
MIS_BASE.Write_PalletInfo(OpName, 3);
|
||||
//通知修改成功
|
||||
MIS_BASE.Write_UpdatePalletOK(OpName, true);
|
||||
IsNeedRepaire_OK(OpName);
|
||||
|
||||
}
|
||||
else if (Convert.ToInt32(m_Value) == 0)
|
||||
{
|
||||
//通知修改成功
|
||||
MIS_BASE.Write_UpdatePalletOK(OpName, true);
|
||||
//直接给出工作完成
|
||||
MIS_BASE.Write_MaterialVerifyOver(OpName, true);
|
||||
}
|
||||
else
|
||||
{ }
|
||||
|
||||
break;
|
||||
case "ContinueMatch":
|
||||
BaseDataSystemMES.QualityVerifyStatus_Hash_Write(OpName, true);
|
||||
break;
|
||||
//初始化网页信号
|
||||
case "IniSingalToWeb":
|
||||
InitializeSingalToWeb(OpName);
|
||||
break;
|
||||
case "Reset_Engine"://返修上线(返修上线点)
|
||||
SetMoby(OpName);//将MES所有信号清空
|
||||
//fun_EngineTypeGetOverPLC(OpName, 0);
|
||||
//fun_EngineTypeGetOverPLC(OpName, 1);
|
||||
break;
|
||||
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "Function02:WebSubmit");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//1.工件到位后,PLC给MES传递机型(DBX0.4)(44),
|
||||
//MES判断条码是否全部扫描完成
|
||||
//PLC给出允许保存(DBX100.2)(19),MES见到(DBX100.2)(19)为1后给出保存完成(DBX102.2)(20),
|
||||
//PLC见到保存完成(DBX102.2)(20)为1后,清空允许保存(DBX100.2)(19),
|
||||
//MES见到允许保存(DBX100.2)(19)为0后,清空保存完成(DBX102.2)(20)
|
||||
//MES判断总合格标志(INT104)(21)为1后,给出合格放行(DBX2.5)(51)
|
||||
/// <summary>
|
||||
/// 扫描条码
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="barcode"></param>
|
||||
static public void fun_Barcode(OpcData.CustomeEvetnArgs e)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(Barcode, e);
|
||||
}
|
||||
static private void SetMoby(string OpName)
|
||||
{
|
||||
try
|
||||
{
|
||||
//清空Moby时,需要将MES信号清空
|
||||
MIS_BASE.Write_ClearMesMoby(OpName);
|
||||
|
||||
BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName);
|
||||
|
||||
Sendmessage("5123", "1111", OpName);
|
||||
|
||||
MIS_BASE.Write_ResetDevice(OpName, true);
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
MIS_BASE.Write_ResetDevice(OpName, false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/// 网页重现登录,恢复关闭前的页面状态
|
||||
/// </summary>
|
||||
/// <param name="Opname">工位号</param>
|
||||
static private void InitializeSingalToWeb(string Opname)
|
||||
{
|
||||
|
||||
//工件到位 DBX0.1
|
||||
bool S_WorkStart;
|
||||
bool S_FixAllow;
|
||||
bool S_EngineGetOver;
|
||||
bool S_MaterialVerifyOver;
|
||||
|
||||
MIS_BASE.Read_WorkStart(Opname, out S_WorkStart);
|
||||
MIS_BASE.Read_FixAllow(Opname, out S_FixAllow);
|
||||
MIS_BASE.Read_EngineGetOver_PLC(Opname, out S_EngineGetOver);
|
||||
MIS_BASE.Read_MaterialVerifyOver(Opname, out S_MaterialVerifyOver);
|
||||
|
||||
|
||||
|
||||
if (S_WorkStart == true)
|
||||
{
|
||||
SendInfomation("WorkStart", Convert.ToString(Convert.ToInt32(S_WorkStart)), Opname);
|
||||
}
|
||||
|
||||
if (S_EngineGetOver == true)
|
||||
{
|
||||
|
||||
SendInfomation("EngineTypeGetOverPLC", Convert.ToString(Convert.ToInt32(S_EngineGetOver)), Opname);
|
||||
Sendmessage("5123", "1111", Opname);
|
||||
}
|
||||
if (S_FixAllow == true)
|
||||
{
|
||||
SendInfomation("FixAllow", Convert.ToString(Convert.ToInt32(S_FixAllow)), Opname);
|
||||
}
|
||||
if (S_MaterialVerifyOver == true)
|
||||
{
|
||||
SendInfomation("MaterialVerifyOver", Convert.ToString(Convert.ToInt32(S_MaterialVerifyOver)), Opname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
|
||||
using System.Windows.Forms;
|
||||
using bizFacade;
|
||||
using System.Collections.Specialized;
|
||||
using MesWork;
|
||||
using SystemFramework;
|
||||
using System.Threading;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
static object lockerWorkStart = new object();
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工件到位与离开时,清空MES自身信号
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
static public void WorkStart(object e)
|
||||
{
|
||||
lock (lockerWorkStart)
|
||||
{
|
||||
try
|
||||
{
|
||||
OpcData.CustomeEvetnArgs msgEvent = (OpcData.CustomeEvetnArgs)e;
|
||||
string OpName = Convert.ToString(msgEvent.OpName);
|
||||
int tagValue = Convert.ToInt32(msgEvent.TagValue);
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "Function02:WorkStart");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,784 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
|
||||
using System.Windows.Forms;
|
||||
using bizFacade;
|
||||
using System.Collections.Specialized;
|
||||
using MesWork;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
public partial class MIS_BASE: PlcLinkForm
|
||||
{
|
||||
/// <summary>
|
||||
/// 全部数据列表
|
||||
/// </summary>
|
||||
public static DataTable BasicDataTagValue;
|
||||
/// <summary>
|
||||
/// MES_基本数据_测量范围
|
||||
/// </summary>
|
||||
public static DataTable BasicDataTagValueUpDown;
|
||||
/// <summary>
|
||||
/// 是否通过监控系统保存数据
|
||||
/// 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据
|
||||
/// </summary>
|
||||
static public Hashtable hashtable_tagTable_OpName_SaveData;
|
||||
/// <summary>
|
||||
/// 变量代码与列位置
|
||||
/// </summary>
|
||||
static public Hashtable hashtable_tagTable_TagID_TagOrderBy;
|
||||
/// <summary>
|
||||
/// 变量代码与变量排序
|
||||
/// </summary>
|
||||
static public Hashtable hashtable_tagTable_TagID_TagItemOrderBy;
|
||||
/// <summary>
|
||||
/// 变量代码与变量特点
|
||||
/// 0:没定义1:工位合格标志2:需要合格标志的测量数据3:每个工位的合格标志4:物料5:IQA码6:压装数据7:压装合格标志8:(自动拧紧)工位合格标志
|
||||
/// </summary>
|
||||
static public Hashtable hashtable_tagTable_TagID_TagProperty;
|
||||
/// <summary>
|
||||
/// 发动机类型转换表
|
||||
/// SELECT ID,发动机机型代码 FROM MES_计划BOM_发动机型号代码
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_EngineTypeID;
|
||||
|
||||
/// <summary>
|
||||
/// 工位号与工位上下线类型
|
||||
/// (0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线)
|
||||
/// </summary>
|
||||
public static Hashtable hashtableOpName_OpType;
|
||||
/// <summary>
|
||||
/// 工位号与大屏幕代码
|
||||
/// 对应LED大屏幕(1,2,3,4)
|
||||
/// </summary>
|
||||
public static Hashtable hashtableOpName_LedID;
|
||||
/// <summary>
|
||||
/// 大屏幕显示产量端口(41104)
|
||||
/// </summary>
|
||||
public static Hashtable hashtableOpName_LedID_Port;
|
||||
|
||||
/// <summary>
|
||||
/// 大屏幕显示Andon大屏幕代码 1
|
||||
/// </summary>
|
||||
public static Hashtable hashtableOpName_AndonID;
|
||||
|
||||
/// <summary>
|
||||
/// 大屏幕显示Andon端口 (41105)
|
||||
/// </summary>
|
||||
public static Hashtable hashtableOpName_AndonID_Port;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否有打印机(0,1)
|
||||
/// </summary>
|
||||
public static Hashtable hashtableOpName_IsPrinter;
|
||||
|
||||
/// <summary>
|
||||
/// 打印机通讯端口
|
||||
/// </summary>
|
||||
public static Hashtable hashtableOpName_IsPrinter_Port;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工位号与目标循环时间
|
||||
/// </summary>
|
||||
public static Hashtable hashtableOpName_TargetTime;
|
||||
/// <summary>
|
||||
/// 工位号与线体类型
|
||||
/// </summary>
|
||||
public static Hashtable hashtableOpName_LineType;
|
||||
/// <summary>
|
||||
/// 是否有工位计算机
|
||||
/// </summary>
|
||||
public static Hashtable hashtableOpName_IsHaveComputer;
|
||||
/// <summary>
|
||||
/// 变量名称
|
||||
/// </summary>
|
||||
public static Hashtable hashtableTagID_TagName;
|
||||
/// <summary>
|
||||
/// 工位号
|
||||
/// </summary>
|
||||
public static Hashtable hashtableTagID_OpName;
|
||||
/// <summary>
|
||||
/// 数据来源
|
||||
/// </summary>
|
||||
public static Hashtable hashtableTagID_OpNameFrom;
|
||||
|
||||
/// <summary>
|
||||
/// 工位名称
|
||||
/// </summary>
|
||||
static Hashtable hashtableTagID_OpName_Name;
|
||||
/// <summary>
|
||||
/// 测量位置
|
||||
/// </summary>
|
||||
public static Hashtable hashtableTagID_ShaftID;
|
||||
/// <summary>
|
||||
/// 测量项目
|
||||
/// </summary>
|
||||
public static Hashtable hashtableTagID_ItemVale;
|
||||
/// <summary>
|
||||
/// 变量代码与变量类型
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_tagTable_TagID_TagTypeID_All;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///工位号与机床状态
|
||||
/// [测量数据机床状态]
|
||||
/// </summary>
|
||||
public static Hashtable m_MachineStatus_OpName;
|
||||
/// <summary>
|
||||
///工位号与工件离开 1->0 =0 无工件或工件离开
|
||||
///工位号与工件到位 0->1 =1 有工件或工件到达
|
||||
///[测量数据发动机在线状态]
|
||||
/// </summary>
|
||||
public static Hashtable m_WorkStart_OpName;
|
||||
|
||||
/// <summary>
|
||||
///工位号与工件到位时间
|
||||
///工位号与工件到位 0->1
|
||||
///[测量数据发动机在线状态]
|
||||
/// </summary>
|
||||
public static Hashtable m_WorkStart_OpName_Time;
|
||||
|
||||
/// <summary>
|
||||
///工位号与工件到位时间
|
||||
///工位号与工件到位 0->1,零件运动方向
|
||||
/// </summary>
|
||||
public static Hashtable m_WorkStart_OpName_PartMoveDirection;
|
||||
|
||||
|
||||
/// <summary>
|
||||
///工位号与发动机号
|
||||
/// </summary>
|
||||
public static Hashtable m_EngineTrace_OpName;
|
||||
/// <summary>
|
||||
///工位号与发动机号_时间
|
||||
/// </summary>
|
||||
public static Hashtable m_EngineTrace_OpName_Time;
|
||||
/// <summary>
|
||||
///工位号与合格标志
|
||||
///[测量数据发动机在线状态]
|
||||
/// </summary>
|
||||
public static Hashtable m_QualityMask_OpName;
|
||||
|
||||
/// <summary>
|
||||
///工位号与机型
|
||||
///[测量数据发动机在线状态]
|
||||
/// </summary>
|
||||
public static Hashtable m_EngineNumberType_OpName;
|
||||
/// <summary>
|
||||
///工位号与发动机号
|
||||
///[测量数据发动机在线状态]
|
||||
/// </summary>
|
||||
public static Hashtable m_EngineNumber_OpName;
|
||||
|
||||
/// <summary>
|
||||
///工位号与订单号
|
||||
///[测量数据发动机在线状态]
|
||||
/// </summary>
|
||||
public static Hashtable m_OrderForm_OpName;
|
||||
/// <summary>
|
||||
///工位号与操作者工号
|
||||
///[测量数据发动机在线状态]
|
||||
/// </summary>
|
||||
public static Hashtable m_OperatorCode_OpName;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 测量合格标志
|
||||
/// 全部测量数据的测量工位
|
||||
/// 全部测量数据的测量工位的数据来源
|
||||
/// 全部测量数据的测量工位的数据来源的测量变量
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_QualityData_GoodBad_MIS_OpName;
|
||||
/// <summary>
|
||||
/// 列位置
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_QualityData_GoodBad_Index;
|
||||
|
||||
/// <summary>
|
||||
/// MesServerCode
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_MesServerCode;
|
||||
/// <summary>
|
||||
/// MesDll
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_MesDll;
|
||||
/// <summary>
|
||||
/// 各个工位是否允许工作
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_IsAllowWork;
|
||||
|
||||
/// <summary>
|
||||
/// 返修工位是否需要强制合格放行
|
||||
/// //20141104 ljl
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_IsConfirmOkGo;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工步属性哈西表
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_workStepProperty;
|
||||
|
||||
/// <summary>
|
||||
/// 工作顺序哈西表
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_WorkGroupIndex;
|
||||
|
||||
/// <summary>
|
||||
/// 返修工位哈西表
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_OpNameRepair;
|
||||
|
||||
/// <summary>
|
||||
/// 记录工件到位的发动机机型代码
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_EngineGetOver_EngineTypeID;
|
||||
/// <summary>
|
||||
/// 记录工件到位的发动机机型
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_EngineGetOver_EngineType;
|
||||
/// <summary>
|
||||
/// 记录工件到位的发动机号
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_EngineGetOver_EngineID;
|
||||
/// <summary>
|
||||
/// 记录工件到位的订单号
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_EngineGetOver_OrderForm;
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧/压装过程中的合格标志
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_QualityMesRead;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 物料检测哈希表
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_CheckMaterial;
|
||||
|
||||
/// <summary>
|
||||
/// 托盘状态哈希表
|
||||
/// </summary>
|
||||
public static Hashtable hashtable_PalletInfo;
|
||||
/// <summary>
|
||||
///[测量数据机床状态_分拆统计]
|
||||
///各个工位机床上电开始时间
|
||||
///机床上电产生 0->1
|
||||
///机床上电解除 1->0
|
||||
/// </summary>
|
||||
public static Hashtable m_MachineStatusPutOn_OpName_Time;
|
||||
/// <summary>
|
||||
///[测量数据机床状态_分拆统计]
|
||||
///各个工位循环开始 开始时间
|
||||
///循环开始产生 0->1
|
||||
///循环开始解除 1->0
|
||||
/// </summary>
|
||||
public static Hashtable m_MachineStatusWorkOn_OpName_Time;
|
||||
/// <summary>
|
||||
///[测量数据机床状态_分拆统计]
|
||||
///各个工位机床故障开始时间
|
||||
///机床故障产生 0->1
|
||||
///机床故障解除 1->0
|
||||
/// </summary>
|
||||
public static Hashtable m_MachineStatusAlarm_OpName_Time;
|
||||
/// <summary>
|
||||
///[测量数据机床状态_分拆统计]
|
||||
///各个工位上料无件开始时间
|
||||
///上料无件产生 0->1
|
||||
///上料无件解除 1->0
|
||||
/// </summary>
|
||||
public static Hashtable m_MachineStatusNoPart_OpName_Time;
|
||||
/// <summary>
|
||||
///[测量数据机床状态_分拆统计]
|
||||
///各个工位下料堵塞开始时间
|
||||
///下料堵塞产生 0->1
|
||||
///下料堵塞解除 1->0
|
||||
/// </summary>
|
||||
public static Hashtable m_MachineStatusBlock_OpName_Time;
|
||||
|
||||
/// <summary>
|
||||
///工位号与托盘离开 1->0
|
||||
///工位号与托盘到位 0->1
|
||||
///[测量数据_监控系统_托盘到位]
|
||||
/// </summary>
|
||||
public static Hashtable m_PartPalletStatus_OpName;
|
||||
/// <summary>
|
||||
///工位号与托盘离开 1->0
|
||||
///工位号与托盘到位 0->1
|
||||
///[测量数据_监控系统_托盘到位]
|
||||
/// </summary>
|
||||
public static Hashtable m_PartPalletStatus_OpName_Time;
|
||||
/// <summary>
|
||||
/// 托盘到位(1)托盘离开(0) (DBX101.7)(13)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
|
||||
/// <summary>
|
||||
///[测量数据机床状态_分拆统计]
|
||||
///各个工位机床上电开始时间
|
||||
///机床上电产生 0->1
|
||||
///机床上电解除 1->0
|
||||
/// </summary>
|
||||
public static Hashtable m_MachineStatusPutOn_OpName;
|
||||
/// <summary>
|
||||
///[测量数据机床状态_分拆统计]
|
||||
///各个工位循环开始 开始时间
|
||||
///循环开始产生 0->1
|
||||
///循环开始解除 1->0
|
||||
/// </summary>
|
||||
public static Hashtable m_MachineStatusWorkOn_OpName;
|
||||
/// <summary>
|
||||
///[测量数据机床状态_分拆统计]
|
||||
///各个工位机床故障开始时间
|
||||
///机床故障产生 0->1
|
||||
///机床故障解除 1->0
|
||||
/// </summary>
|
||||
public static Hashtable m_MachineStatusAlarm_OpName;
|
||||
/// <summary>
|
||||
///[测量数据机床状态_分拆统计]
|
||||
///各个工位上料无件开始时间
|
||||
///上料无件产生 0->1
|
||||
///上料无件解除 1->0
|
||||
/// </summary>
|
||||
public static Hashtable m_MachineStatusNoPart_OpName;
|
||||
/// <summary>
|
||||
///[测量数据机床状态_分拆统计]
|
||||
///各个工位下料堵塞开始时间
|
||||
///下料堵塞产生 0->1
|
||||
///下料堵塞解除 1->0
|
||||
/// </summary>
|
||||
public static Hashtable m_MachineStatusBlock_OpName;
|
||||
/// <summary>
|
||||
/// 托盘代码(DBB86)(80)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
|
||||
/// <summary>
|
||||
/// 创建MesServerCode哈西表
|
||||
/// </summary>
|
||||
public void InitHashtable_MesServerCode()
|
||||
{
|
||||
hashtable_MesServerCode = new Hashtable();
|
||||
hashtable_IsAllowWork = new Hashtable();
|
||||
hashtable_WorkGroupIndex = new Hashtable();
|
||||
hashtable_EngineGetOver_EngineTypeID = new Hashtable();
|
||||
hashtable_EngineGetOver_EngineType = new Hashtable();
|
||||
hashtable_EngineGetOver_EngineID = new Hashtable();
|
||||
hashtable_EngineGetOver_OrderForm = new Hashtable();
|
||||
hashtable_QualityMesRead = new Hashtable();
|
||||
hashtable_CheckMaterial = new Hashtable();
|
||||
hashtable_PalletInfo = new Hashtable();
|
||||
hashtable_IsConfirmOkGo = new Hashtable();
|
||||
hashtable_MesDll=new Hashtable();
|
||||
|
||||
string OpName;
|
||||
string MesServerCode;
|
||||
string MesDll;
|
||||
string workStepProperty;
|
||||
string OpNameRepair;
|
||||
DataTable dt;
|
||||
dt = BaseDataSystemMES.GetMesServerCodeFromMIS();
|
||||
if (dt != null)
|
||||
{
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
OpName = dt.Rows[i]["工位号"].ToString();
|
||||
MesServerCode = dt.Rows[i]["MesServerCode"].ToString();
|
||||
MesDll = dt.Rows[i]["MesDll"].ToString();
|
||||
hashtable_MesDll.Add(OpName, MesDll);
|
||||
hashtable_MesServerCode.Add(OpName, MesServerCode);
|
||||
hashtable_IsAllowWork.Add(OpName, 1);
|
||||
hashtable_IsConfirmOkGo.Add(OpName, 0);//20141104 ljl
|
||||
hashtable_PalletInfo.Add(OpName, 0);//20141104 ljl
|
||||
hashtable_WorkGroupIndex.Add(OpName, 1);
|
||||
hashtable_EngineGetOver_EngineTypeID.Add(OpName, 0);
|
||||
hashtable_EngineGetOver_EngineType.Add(OpName, "");
|
||||
hashtable_EngineGetOver_EngineID.Add(OpName, "");
|
||||
hashtable_EngineGetOver_OrderForm.Add(OpName, "");
|
||||
hashtable_QualityMesRead.Add(OpName, 0);
|
||||
hashtable_CheckMaterial.Add(OpName, new bool[16]);
|
||||
}
|
||||
}
|
||||
|
||||
//初始化工步属性
|
||||
hashtable_workStepProperty = new Hashtable();
|
||||
dt = BaseDataSystemMES.GetworkStepPropertyFromMIS();
|
||||
if (dt != null)
|
||||
{
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
OpName = dt.Rows[i]["工位号"].ToString();
|
||||
workStepProperty = dt.Rows[i]["工步属性"].ToString();
|
||||
hashtable_workStepProperty.Add(OpName, workStepProperty);
|
||||
}
|
||||
}
|
||||
|
||||
//返修工位
|
||||
hashtable_OpNameRepair = new Hashtable();
|
||||
dt = BaseDataSystemMES.GetOpNameRepairFromMIS();
|
||||
if (dt != null)
|
||||
{
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
OpName = dt.Rows[i]["工位号"].ToString();
|
||||
OpNameRepair = dt.Rows[i]["返修工位号"].ToString();
|
||||
hashtable_OpNameRepair.Add(OpName, OpNameRepair);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建合格标志哈西表
|
||||
/// </summary>
|
||||
private void InitHashtable_QualityData_GoodBad()
|
||||
{
|
||||
//列位置
|
||||
string index;
|
||||
//
|
||||
int tagID;
|
||||
DataTable dt ;
|
||||
dt = BaseDataSystemMES.BaseData_tagTable_All_B5A();
|
||||
|
||||
hashtable_QualityData_GoodBad_Index = new Hashtable();
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
tagID = Convert.ToInt32(dt.Rows[i]["TagID"]);
|
||||
index = (dt.Rows[i]["列位置"]).ToString();
|
||||
hashtable_QualityData_GoodBad_Index.Add(tagID, index);
|
||||
}
|
||||
|
||||
hashtable_EngineTypeID = new Hashtable();
|
||||
dt = BaseDataSystemMES.BaseData_tagTable_QualityData_EngineTypeID();
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
tagID = Convert.ToInt32(dt.Rows[i]["发动机机型代码"]);
|
||||
index = (dt.Rows[i]["ID"]).ToString();
|
||||
hashtable_EngineTypeID.Add(tagID, index);
|
||||
}
|
||||
//工位号
|
||||
DataTable dt_OpName;
|
||||
//工位号数据来源
|
||||
DataTable dt_OpNameFrom;
|
||||
//数据来源对应的TagID
|
||||
DataTable dt_OpNameTagID;
|
||||
string opName;
|
||||
string opNameFrom;
|
||||
hashtable_QualityData_GoodBad_MIS_OpName = new Hashtable();
|
||||
// 测量合格标志
|
||||
// 全部测量数据的测量工位的数据来源
|
||||
Hashtable hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom;
|
||||
|
||||
// 测量合格标志
|
||||
// 全部测量数据的测量工位的数据来源的测量变量
|
||||
Hashtable hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID;
|
||||
dt_OpName = BaseDataSystemMES.BaseData_tagTable_QualityData_GoodBad_MIS_OpName_B5A();
|
||||
if (dt_OpName != null)
|
||||
{
|
||||
//有不合格标志的测量工位
|
||||
for (int i = 0; i < dt_OpName.Rows.Count; i++)
|
||||
{
|
||||
//有不合格标志的测量工位 对应的 数据来源工位号
|
||||
hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom = new Hashtable();
|
||||
opName = dt_OpName.Rows[i]["工位号"].ToString();
|
||||
dt_OpNameFrom = BaseDataSystemMES.BaseData_tagTable_QualityData_GoodBad_MIS_OpName(opName);
|
||||
if (dt_OpNameFrom != null)
|
||||
{
|
||||
for (int j = 0; j < dt_OpNameFrom.Rows.Count; j++)
|
||||
{
|
||||
opNameFrom = dt_OpNameFrom.Rows[j]["数据来源"].ToString();
|
||||
dt_OpNameTagID = BaseDataSystemMES.BaseData_tagTable_QualityData_GoodBad_MIS_OpName(opName, opNameFrom);
|
||||
//
|
||||
hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID = new Hashtable();
|
||||
if (dt_OpNameTagID != null)
|
||||
{
|
||||
for (int k = 0; k < dt_OpNameTagID.Rows.Count; k++)
|
||||
{
|
||||
tagID = Convert.ToInt32(dt_OpNameTagID.Rows[k]["TagID"]);
|
||||
hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID.Add(tagID, tagID);
|
||||
}
|
||||
}
|
||||
tagID = Convert.ToInt32(dt_OpNameFrom.Rows[j]["TagID"]);
|
||||
//全部测量数据的测量工位的数据来源的测量变量
|
||||
hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom.Add(tagID, hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom_TagID);
|
||||
}
|
||||
}
|
||||
hashtable_QualityData_GoodBad_MIS_OpName.Add(opName, hashtable_QualityData_GoodBad_MIS_OpName_OpNameFrom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static NameValueCollection hashtable_TagTypeID_OpName_ToTagID;
|
||||
|
||||
/// <summary>
|
||||
/// 变量代码与其他字段的对应关系
|
||||
/// </summary>
|
||||
public void InitHashtableTagID()
|
||||
{
|
||||
//变量代码
|
||||
string tagID;
|
||||
//变量名称
|
||||
string tagName;
|
||||
//工位号
|
||||
string opNmae;
|
||||
//测量位置
|
||||
string shaftID;
|
||||
//测量项目
|
||||
string itemVale;
|
||||
//变量排序
|
||||
int tagItemOrderBy;
|
||||
//变量特点
|
||||
// 0:没定义1:工位合格标志2:需要合格标志的测量数据3:每个工位的合格标志4:物料5:IQA码6:压装数据7:压装合格标志8:(自动拧紧)工位合格标志
|
||||
int tagProperty;
|
||||
//列位置
|
||||
int tagOrderBy;
|
||||
InitHashtable_QualityData_GoodBad();
|
||||
//MesServerCode哈希表创建
|
||||
InitHashtable_MesServerCode();
|
||||
//列位置
|
||||
hashtable_tagTable_TagID_TagOrderBy = new Hashtable();
|
||||
// 变量代码与变量排序
|
||||
hashtable_tagTable_TagID_TagItemOrderBy = new Hashtable();
|
||||
// 变量代码与变量特点
|
||||
// 0:没定义1:工位合格标志2:需要合格标志的测量数据3:每个工位的合格标志4:物料5:IQA码6:压装数据7:压装合格标志8:(自动拧紧)工位合格标志
|
||||
hashtable_tagTable_TagID_TagProperty = new Hashtable();
|
||||
hashtable_tagTable_OpName_SaveData = new Hashtable();
|
||||
//工位号与机床状态
|
||||
//[测量数据发动机在线状态]
|
||||
m_MachineStatus_OpName = new Hashtable();
|
||||
////工位号与工件离开 0
|
||||
////工位号与工件到位 1
|
||||
////[测量数据发动机在线状态]
|
||||
//m_WorkStart_OpName = new Hashtable();
|
||||
////工位号与工件到位时间
|
||||
////工位号与工件到位 0->1
|
||||
////[测量数据发动机在线状态]
|
||||
//m_WorkStart_OpName_Time = new Hashtable();
|
||||
//工位号与发动机号
|
||||
//[测量数据发动机在线状态]
|
||||
m_EngineTrace_OpName = new Hashtable();
|
||||
m_EngineTrace_OpName_Time = new Hashtable();
|
||||
//工位号与合格标志
|
||||
//[测量数据发动机在线状态]
|
||||
m_QualityMask_OpName = new Hashtable();
|
||||
//工位号与目标循环时间
|
||||
hashtableOpName_TargetTime = new Hashtable();
|
||||
//工位号与线体类型
|
||||
hashtableOpName_LineType = new Hashtable();
|
||||
//是否有工位计算机
|
||||
hashtableOpName_IsHaveComputer = new Hashtable();
|
||||
|
||||
//工位号与机型
|
||||
//[测量数据发动机在线状态]
|
||||
m_EngineNumberType_OpName = new Hashtable();
|
||||
//工位号与发动机号
|
||||
//[测量数据发动机在线状态]
|
||||
m_EngineNumber_OpName = new Hashtable();
|
||||
//工位号与订单号
|
||||
//[测量数据发动机在线状态]
|
||||
m_OrderForm_OpName = new Hashtable();
|
||||
//工位号与操作者工号
|
||||
//[测量数据发动机在线状态]
|
||||
m_OperatorCode_OpName = new Hashtable();
|
||||
|
||||
|
||||
// <summary>
|
||||
// 变量名称
|
||||
// </summary>
|
||||
hashtableTagID_TagName = new Hashtable();
|
||||
// <summary>
|
||||
// 工位号
|
||||
// </summary>
|
||||
hashtableTagID_OpName = new Hashtable();
|
||||
// <summary>
|
||||
// 数据来源
|
||||
// </summary>
|
||||
hashtableTagID_OpNameFrom = new Hashtable();
|
||||
// <summary>
|
||||
// 工位名称
|
||||
// </summary>
|
||||
hashtableTagID_OpName_Name = new Hashtable();
|
||||
// <summary>
|
||||
// 测量位置
|
||||
// </summary>
|
||||
hashtableTagID_ShaftID = new Hashtable();
|
||||
// <summary>
|
||||
// 测量项目
|
||||
// </summary>
|
||||
hashtableTagID_ItemVale = new Hashtable();
|
||||
|
||||
hashtable_tagTable_TagID_TagTypeID_All = new Hashtable();
|
||||
|
||||
// 工位号与工位上下线类型
|
||||
// (0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线)
|
||||
hashtableOpName_OpType = new Hashtable();
|
||||
// 工位号与大屏幕代码
|
||||
// 对应LED大屏幕(1,2,3,4)
|
||||
hashtableOpName_LedID = new Hashtable();
|
||||
|
||||
|
||||
|
||||
|
||||
// 大屏幕显示产量端口(41104)
|
||||
hashtableOpName_LedID_Port = new Hashtable();
|
||||
// 大屏幕显示Andon大屏幕代码 1
|
||||
hashtableOpName_AndonID = new Hashtable();
|
||||
// 大屏幕显示Andon端口 (41105)
|
||||
hashtableOpName_AndonID_Port = new Hashtable();
|
||||
// 是否有打印机(0,1)
|
||||
hashtableOpName_IsPrinter = new Hashtable();
|
||||
// 打印机通讯端口 (缸盖打印机 41101) (发动机上线打印机 41102) (发动机下线打印机 41103)
|
||||
hashtableOpName_IsPrinter_Port = new Hashtable();
|
||||
|
||||
m_WorkStart_OpName_Time = new Hashtable();
|
||||
m_WorkStart_OpName = new Hashtable();
|
||||
|
||||
|
||||
m_MachineStatusPutOn_OpName_Time = new Hashtable();
|
||||
m_MachineStatusPutOn_OpName = new Hashtable();
|
||||
m_MachineStatusWorkOn_OpName_Time = new Hashtable();
|
||||
m_MachineStatusWorkOn_OpName = new Hashtable();
|
||||
m_MachineStatusAlarm_OpName_Time = new Hashtable();
|
||||
m_MachineStatusAlarm_OpName = new Hashtable();
|
||||
m_MachineStatusNoPart_OpName_Time = new Hashtable();
|
||||
m_MachineStatusNoPart_OpName = new Hashtable();
|
||||
m_MachineStatusBlock_OpName_Time = new Hashtable();
|
||||
m_MachineStatusBlock_OpName = new Hashtable();
|
||||
|
||||
|
||||
|
||||
|
||||
m_WorkStart_OpName_PartMoveDirection = new Hashtable();
|
||||
m_PartPalletStatus_OpName_Time = new Hashtable();
|
||||
m_PartPalletStatus_OpName = new Hashtable();
|
||||
|
||||
hashtable_TagTypeID_OpName_ToTagID = new NameValueCollection();
|
||||
|
||||
|
||||
|
||||
DataTable dt;
|
||||
DateTime dateTime;
|
||||
dateTime = DateTime.Now;
|
||||
dt = BaseDataSystemMES.BaseData_tagTable_All();
|
||||
|
||||
//变量类型代码
|
||||
int TagTypeID;
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
tagID = dt.Rows[i]["TagID"].ToString ();
|
||||
tagName = Convert.ToString(dt.Rows[i]["TagName"]);
|
||||
opNmae = Convert.ToString(dt.Rows[i]["工位号"]);
|
||||
shaftID = Convert.ToString(dt.Rows[i]["测量位置"]);
|
||||
itemVale = Convert.ToString(dt.Rows[i]["测量项目"]);
|
||||
TagTypeID = Convert.ToInt32(dt.Rows[i]["变量类型代码"]);
|
||||
tagItemOrderBy = Convert.ToInt32(dt.Rows[i]["变量排序"]);
|
||||
tagProperty = Convert.ToInt32(dt.Rows[i]["变量特点"]);
|
||||
tagOrderBy = Convert.ToInt32(dt.Rows[i]["列位置"]);
|
||||
|
||||
hashtableTagID_TagName.Add(tagID, tagName);
|
||||
hashtableTagID_OpName.Add(tagID, opNmae);
|
||||
hashtableTagID_ShaftID.Add(tagID, shaftID);
|
||||
hashtableTagID_ItemVale.Add(tagID, itemVale);//列位置
|
||||
hashtable_tagTable_TagID_TagTypeID_All.Add(tagID, TagTypeID);
|
||||
hashtable_tagTable_TagID_TagItemOrderBy.Add(tagID, tagItemOrderBy);
|
||||
hashtable_tagTable_TagID_TagProperty.Add(tagID, tagProperty);
|
||||
hashtable_tagTable_TagID_TagOrderBy.Add(tagID, tagOrderBy);
|
||||
|
||||
|
||||
}
|
||||
dt = BaseDataSystemMES.BaseData_tagTable_OpName();
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
//是否通过监控系统保存数据
|
||||
// 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据
|
||||
hashtable_tagTable_OpName_SaveData.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["是否通过监控系统保存数据"]));
|
||||
|
||||
hashtableOpName_TargetTime.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToString(dt.Rows[i]["目标循环时间"]));
|
||||
hashtableOpName_LineType.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToString(dt.Rows[i]["线体类型"]));
|
||||
hashtableOpName_IsHaveComputer.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToString(dt.Rows[i]["是否有工位计算机"]));
|
||||
//用于LED显示
|
||||
// [MES_计划BOM_工位与名称]
|
||||
// 工位上下线类型
|
||||
//(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线)
|
||||
hashtableOpName_OpType.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["工位上下线类型"]));
|
||||
hashtableOpName_LedID.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕代码"]));
|
||||
m_WorkStart_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
|
||||
m_WorkStart_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
|
||||
|
||||
|
||||
m_MachineStatusPutOn_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
|
||||
m_MachineStatusPutOn_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
|
||||
m_MachineStatusWorkOn_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
|
||||
m_MachineStatusWorkOn_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
|
||||
m_MachineStatusAlarm_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
|
||||
m_MachineStatusAlarm_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
|
||||
m_MachineStatusNoPart_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
|
||||
m_MachineStatusNoPart_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
|
||||
m_MachineStatusBlock_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
|
||||
m_MachineStatusBlock_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
|
||||
|
||||
|
||||
|
||||
m_WorkStart_OpName_PartMoveDirection.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
|
||||
|
||||
|
||||
m_PartPalletStatus_OpName_Time.Add(Convert.ToString(dt.Rows[i]["工位号"]), dateTime);
|
||||
m_PartPalletStatus_OpName.Add(Convert.ToString(dt.Rows[i]["工位号"]), 0);
|
||||
try
|
||||
{
|
||||
hashtableOpName_LedID_Port.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕显示产量端口"]));
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
hashtableOpName_AndonID.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕显示Andon大屏幕代码"]));
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
hashtableOpName_AndonID_Port.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["大屏幕显示Andon端口"]));
|
||||
}
|
||||
catch { }
|
||||
try { hashtableOpName_IsPrinter.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["是否有打印机"])); }
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
hashtableOpName_IsPrinter_Port.Add(Convert.ToString(dt.Rows[i]["工位号"]), Convert.ToInt32(dt.Rows[i]["打印机通讯端口"]));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
|
||||
//20170310 CLB新加
|
||||
dt = BaseDataSystemMES.BaseData_tagTable_OpcServerMES_ALL_CF();
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
hashtable_TagTypeID_OpName_ToTagID.Add(Convert.ToString(dt.Rows[i]["工位号"]) + "_" + Convert.ToString(dt.Rows[i]["变量类型代码"]), Convert.ToString(dt.Rows[i]["TagID"]));
|
||||
//hashtable_TagTypeID_OpName_ToTagID;
|
||||
}
|
||||
catch(Exception err)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
using bizFacade;
|
||||
using DataLinkMesWork;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保养计划
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="MachineType"></param>
|
||||
/// <param name="PlanID"></param>
|
||||
public delegate void MachinePlan_Invoke(string OpName, string MachineType, string PlanID);
|
||||
/// <summary>
|
||||
/// 设备保养计划
|
||||
/// </summary>
|
||||
public MachinePlan_Invoke machinePlan_Invoke;
|
||||
/// <summary>
|
||||
/// 设备保养
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="MachineType">设备保养类型</param>
|
||||
/// <param name="PlanID">工作日历流水号</param>
|
||||
public void MachinePlan(string OpName, string MachineType, string PlanID)
|
||||
{
|
||||
try
|
||||
{
|
||||
string SendMessage;
|
||||
SendMessage = "MES|MachinePlan|" + OpName + "|" + MachineType + "&" + PlanID;
|
||||
asyncSendMessage(SendMessage);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "MachinePlan");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养计划Timer
|
||||
/// </summary>
|
||||
private Timer timer_Machine;
|
||||
/// <summary>
|
||||
/// 初始化设备保养计划
|
||||
/// </summary>
|
||||
public void InitMachinePlan(MachinePlan_Invoke machinePlan_Invoke)
|
||||
{
|
||||
this.machinePlan_Invoke = machinePlan_Invoke;
|
||||
timer_Machine = new Timer();
|
||||
timer_Machine.Interval = 60000;//每隔一分钟查询一次
|
||||
timer_Machine.Tick += new EventHandler(timer_Machine_Tick);
|
||||
timer_Machine.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分钟调度
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void timer_Machine_Tick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ApplicationConfig.Is_MachinePlan == 1)
|
||||
{
|
||||
DataTable dt;
|
||||
string opName;
|
||||
string machineType;//保养类型代码
|
||||
string planID;//工作日历流水号
|
||||
BaseDataSystemMES.MachinePlan_Select(out dt);
|
||||
if (dt != null)
|
||||
{
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
opName = dt.Rows[i]["工位号"].ToString();
|
||||
machineType = dt.Rows[i]["保养类型代码"].ToString();
|
||||
planID = dt.Rows[i]["工作日历流水号"].ToString();
|
||||
BaseDataSystemMES.Rolling_news_Add(opName, opName + "工位有设备保养计划,请相关人员进行保养!!!");
|
||||
BeginInvoke(machinePlan_Invoke, new object[] { opName, machineType, planID });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "timer_Machine_Tick");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,418 @@
|
||||
using System;
|
||||
using SystemFramework;
|
||||
using OpcData;
|
||||
|
||||
namespace MesServerWork
|
||||
{
|
||||
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
public delegate void DemoHandler(object sender, CustomeEvetnArgs e);
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static event DemoHandler OPCTagDataDemo;
|
||||
|
||||
/// <summary>
|
||||
/// 根据tagType,工位号写入PLC对应值
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
static private void Write_TagValueByTagTypeName(string cmd, string opName,object tagValue)
|
||||
{
|
||||
int tagTypeID = 0;
|
||||
string msg;
|
||||
try
|
||||
{
|
||||
tagTypeID = Convert.ToInt32(MesDataFunction.OpcOperation.hashtable_TagType[cmd]);
|
||||
MesDataFunction.OpcOperation.WriteTagValue(tagTypeID, opName, tagValue);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "Write_TagValueByTagTypeName_FUNC");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据TagTypeID,工位号写入PLC对应值
|
||||
/// </summary>
|
||||
/// <param name="TagTypeID"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
static private void Write_TagValueByTagTypeID(int tagTypeID, string opName, object tagValue)
|
||||
{
|
||||
string msg;
|
||||
object tagValueOb;
|
||||
object newTagValue= tagValue;
|
||||
try
|
||||
{
|
||||
MesDataFunction.OpcOperation.WriteTagValue(tagTypeID, opName, tagValue);
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "Write_TagValueByTagTypeID_FUNC");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 通过TagID写入PLC数据
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
static private void Write_TagValueByTagID(string TagID, object tagValue)
|
||||
{
|
||||
string msg;
|
||||
//tagValue = "0";
|
||||
try
|
||||
{
|
||||
MesDataFunction.OpcOperation.WritePLC(TagID, tagValue);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "Write_TagValueByTagID_FUNC");
|
||||
}
|
||||
}
|
||||
|
||||
public static void Write_TagTypeID(int tagTypeID, string opName, object tagValue)
|
||||
{
|
||||
Write_TagValueByTagTypeID(tagTypeID, opName, tagValue);
|
||||
}
|
||||
|
||||
public static void Write_TagID(string TagID, object tagValue)
|
||||
{
|
||||
Write_TagValueByTagID(TagID, tagValue);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 清空MES信号 MES传递机型(5) 允许工作(66) 合格放行(51) 不合格放行(8) 拧紧结束(67) 工作完成(7) 保存完成(20) 加工时间保存完成(54) 匹配完成(68) 默认false
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="false"></param>
|
||||
public static void Write_ClearMesMoby(string opName)
|
||||
{
|
||||
MIS_BASE.Write_EngineTypeGetOver_MES(opName, false);
|
||||
MIS_BASE.Write_FixAllow(opName, false);
|
||||
MIS_BASE.Write_ConfirmOkGo(opName, false);
|
||||
MIS_BASE.Write_FalseGO(opName, false);
|
||||
MIS_BASE.Write_FixOver(opName, false);
|
||||
MIS_BASE.Write_MaterialVerifyOver(opName, false);
|
||||
MIS_BASE.Write_MesReadOver(opName, false);
|
||||
MIS_BASE.Write_MachineTime_ReadOver(opName, false);
|
||||
MIS_BASE.Write_MatchingCompleted(opName, false);
|
||||
}
|
||||
/// <summary>
|
||||
/// 各个工位返修状态(4)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_RepairPathString(string opName, string tagValue)
|
||||
{
|
||||
string cmd = "RepairPathString";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
/// <summary>
|
||||
/// MES保存完数据(必须MIS)(X102.2)(20)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_MesReadOver(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "MesReadOver";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加工时间保存完数据 DBX102.1 (54)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_MachineTime_ReadOver(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "MachineTime_ReadOver";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工位三种状态:在线、离线、屏蔽(0,1,2)(DBB116)(79)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_OnLineState(string opName, int tagValue)
|
||||
{
|
||||
string cmd = "OnLineState";
|
||||
Write_TagValueByTagTypeName(cmd, opName,Convert .ToInt16 ( tagValue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 托盘编号(PLC)(80)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_PalletCode(string opName, int tagValue)
|
||||
{
|
||||
string cmd = "PartPalletCode";
|
||||
Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MES向PLC传递机型(5)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_EngineTypeGetOver_MES(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "EngineTypeGetOverMES";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工作完成(7)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_MaterialVerifyOver(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "MaterialVerifyOver";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合格方式放行(51)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_ConfirmOkGo(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "ConfirmOkGo";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 允许拧紧(66)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_FixAllow(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "FixAllow";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧结束(67)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_FixOver(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "FixOver";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///返修上线,在上线工位,MES依据工件情况,设定为返修件,PLC见到MES设定为1后,将返修标志写入到DBX0.2为1
|
||||
///MES设定完返修返修上线后,MES清空该信号
|
||||
///DBX3.7(72)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_RepairUpline_MES(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "RepairUplineMES";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 匹配完成(68)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_MatchingCompleted(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "MatchingCompleted";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 不合格放行(8)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_FalseGO(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "FalseGo";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 匹配结果(69)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_Match(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "Match";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 变量类型代码=73,机型代码。DBB404~405 机型标志
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_EngineTypeID_MES(string opName, int tagValue)
|
||||
{
|
||||
string cmd = "EngineTypeID_MES";
|
||||
Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue));
|
||||
}
|
||||
/// <summary>
|
||||
/// 变量类型代码=74,零件编号。DBB406~445 发动机编号
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_EngineID_MES(string opName, string tagValue)
|
||||
{
|
||||
string cmd = "EngineID_MES";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
/// <summary>
|
||||
/// 变量类型代码=75,零件机型。DBB446~485 发动机机型
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_EngineType_MES(string opName, string tagValue)
|
||||
{
|
||||
string cmd = "EngineType_MES";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧序号(77)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_ProcessCode(string opName, int tagValue)
|
||||
{
|
||||
string cmd = "ProcessCode";
|
||||
Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 套筒号(88)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_BoltCode(string opName, int tagValue)
|
||||
{
|
||||
string cmd = "BoltCode";
|
||||
Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 空托盘放行(DBX2.2)(6)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_PartPalletGoOver(string opName, int tagValue)
|
||||
{
|
||||
string cmd = "PartPalletGoOver";
|
||||
Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 自动手动申请工件编号,0是自动方式;1:手动方式。切换时,(DBX2.1)(71)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_IsAutoGetEngineID(string opName, int tagValue)
|
||||
{
|
||||
string cmd = "IsAutoGetEngineID";
|
||||
Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 正常拧紧时选择(DBX100.3)(81)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_Normal(string opName, int tagValue)
|
||||
{
|
||||
string cmd = "Normal";
|
||||
Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue));
|
||||
}
|
||||
/// <summary>
|
||||
/// 备用拧紧时选择(DBX100.4)(82)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_UnNormal(string opName, int tagValue)
|
||||
{
|
||||
string cmd = "UnNormal";
|
||||
Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 变量类型代码=52,复位设备(MES)DBX0.6
|
||||
/// 通知PLC复位设备
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_ResetDevice(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "PartLoadFinish";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///托盘状态(22)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_PalletInfo(string opName, int tagValue)
|
||||
{
|
||||
string cmd = "PalletInfo";
|
||||
Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue));
|
||||
}
|
||||
/// <summary>
|
||||
/// 返修标志(93)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_RepairStatusMES(string opName, int tagValue)
|
||||
{
|
||||
string cmd = "RepairStatusMES";
|
||||
Write_TagValueByTagTypeName(cmd, opName, Convert.ToInt16(tagValue));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MES通知PLC修改托盘状态成功
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void Write_UpdatePalletOK(string opName, bool tagValue)
|
||||
{
|
||||
string cmd = "UpdatePalletOK";
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
using BasicData;
|
||||
using bizFacade;
|
||||
using SystemFramework;
|
||||
using System.Configuration;
|
||||
|
||||
namespace MesDataFunctionWebApi
|
||||
{
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 读取质量数据
|
||||
/// </summary>
|
||||
/// <param name="valueList"></param>
|
||||
public static void ReadPLC_Sync_ValueList(string opName, out Hashtable valueList)
|
||||
{
|
||||
valueList = null;
|
||||
ReadPLCData(opName, out valueList);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据工位号 同步读取数据
|
||||
/// </summary>
|
||||
/// <param name="opName">工位号</param>
|
||||
/// <param name="valueList">PLC仅仅值列表</param>
|
||||
private static void ReadPLCData(string opName, out Hashtable valueList)
|
||||
{
|
||||
valueList = new Hashtable();
|
||||
QualityDataType qualityDataType;
|
||||
qualityDataType = new QualityDataType();
|
||||
System.Data.DataTable dt;
|
||||
dt = BaseDataSystemMES.BaseData_tagTable_QualityData_Item_B5A();
|
||||
|
||||
object tagValueStr = "0";
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
if (opName == dt.Rows[i]["工位号"].ToString())
|
||||
{
|
||||
qualityDataType.tagID = dt.Rows[i]["TagID"].ToString ();
|
||||
qualityDataType.tagTypeID = Convert.ToInt32(dt.Rows[i]["TagTypeID"]);//变量类型
|
||||
qualityDataType.opName = opName;//
|
||||
qualityDataType.isGoodBad = 192;//
|
||||
qualityDataType.tagQuality = 192;//
|
||||
qualityDataType.tagValueType = Convert.ToInt32(dt.Rows[i]["变量类型代码"]);
|
||||
qualityDataType.tagOrderBy = Convert.ToInt32(dt.Rows[i]["列位置"]);
|
||||
qualityDataType.tagItemOrderBy = Convert.ToInt32(dt.Rows[i]["变量排序"]);
|
||||
qualityDataType.tagProperty = Convert.ToInt32(dt.Rows[i]["变量特点"]); ;//变量特点
|
||||
|
||||
MIS_BASE.Read_TagID(qualityDataType.tagID, out tagValueStr);
|
||||
|
||||
if (qualityDataType.tagTypeID == 18)
|
||||
{
|
||||
qualityDataType.tagValue = Convert.ToInt32(tagValueStr);//变量值
|
||||
}
|
||||
else
|
||||
{
|
||||
qualityDataType.tagValue = tagValueStr;//变量值
|
||||
}
|
||||
valueList.Add(qualityDataType.tagID, qualityDataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections;
|
||||
using BasicData;
|
||||
using bizFacade;
|
||||
using SystemFramework;
|
||||
using System.Configuration;
|
||||
using MesWork;
|
||||
using MQTTnet.Client.Connecting;
|
||||
using MQTTnet.Client.Disconnecting;
|
||||
using MQTTnet.Client.Receiving;
|
||||
using MQTTnet;
|
||||
|
||||
namespace MesDataFunctionWebApi
|
||||
{
|
||||
public partial class MIS_BASE
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static string MqttTargetTopic = "";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
static new MesWebFun_base.MisWebInterface misWebInterface = new MesWebFun_base.MisWebInterface();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
static readonly Object locker = new Object();
|
||||
/// <summary>
|
||||
/// 发消息给通讯服务器
|
||||
/// </summary>
|
||||
/// <param name="Message"></param>
|
||||
public static string asyncSendMessage(string Message)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
//"MES|MachinePlan|OpName|Value
|
||||
var array = Message.Split('|');
|
||||
var cmd = array[1];
|
||||
var opName = array[2];
|
||||
var topic = $"{MqttTargetTopic}/{opName}";
|
||||
|
||||
Mqtt.Publish(topic, Message);
|
||||
|
||||
var responseStr = misWebInterface.WebSocket_Function(Message);
|
||||
if (responseStr.Length > 0)
|
||||
{
|
||||
|
||||
Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}");
|
||||
}
|
||||
//return responseStr;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static string asyncSendMessageDemo(string Message)
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
//"MES|MachinePlan|OpName|Value
|
||||
var array = Message.Split('|');
|
||||
var cmd = array[1];
|
||||
var opName = array[2];
|
||||
var topic = $"{MqttTargetTopic}/{opName}";
|
||||
|
||||
Mqtt.Publish(topic, Message);
|
||||
|
||||
var responseStr = misWebInterface.WebSocket_Function(Message);
|
||||
if (responseStr.Length > 0)
|
||||
{
|
||||
|
||||
Mqtt.Publish(topic, $"MES|{cmd}_Resources|{opName}|{responseStr}");
|
||||
}
|
||||
return responseStr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using bizFacade;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesDataFunctionWebApi
|
||||
{
|
||||
partial class Function
|
||||
{
|
||||
|
||||
private static void Heartbeat(string opName, string tagValue)
|
||||
{
|
||||
if (tagValue == "1")
|
||||
{
|
||||
Write_TagTypeID(15, opName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Write_TagTypeID(15, opName, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
|
||||
using MesServerWork;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesDataFunctionWebApi
|
||||
{
|
||||
public partial class Function: MIS_BASE
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理MIS逻辑
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public static void MIS_Funtion(object e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int tagType;
|
||||
string opName;
|
||||
string tagValue;
|
||||
int tagid;
|
||||
OpcData.CustomeEvetnArgs msgEvent = (OpcData.CustomeEvetnArgs)e;
|
||||
if (msgEvent.TagValue == null) return;
|
||||
tagType = Convert.ToInt32(msgEvent.TagType);
|
||||
opName = msgEvent.OpName.ToString();
|
||||
tagid = Convert.ToInt32(msgEvent.TagKey);
|
||||
switch (Convert.ToInt32(msgEvent.TagValueType))
|
||||
{
|
||||
case 11:
|
||||
tagValue = (Convert.ToInt32(msgEvent.TagValue)).ToString();
|
||||
break;
|
||||
default:
|
||||
tagValue = msgEvent.TagValue.ToString();
|
||||
break;
|
||||
}
|
||||
///根据信号处理逻辑
|
||||
switch (tagType)
|
||||
{
|
||||
case 19:
|
||||
//允许保存
|
||||
MesRead(opName, tagValue, tagid);
|
||||
break;
|
||||
case 14:
|
||||
//心跳
|
||||
Heartbeat(opName, tagValue);
|
||||
break;
|
||||
case 44://PLC传递机型过后 才允许保存过站信息,否则不允许保存
|
||||
if (tagValue == "1")
|
||||
{
|
||||
IsEngTypeGetOver_Write(opName, true);
|
||||
|
||||
EngineData Enginedata = new EngineData(MesDataFunction.OpcOperation.ReadPLC(10, opName).ToString(), Convert.ToInt32(MesDataFunction.OpcOperation.ReadPLC(80, opName)));
|
||||
//保存产品编号、托盘号 保存过站信息用
|
||||
EngineData_Hash_Write(opName, Enginedata);
|
||||
}
|
||||
break;
|
||||
case 2://工件到位
|
||||
WorkStart(opName, tagValue);
|
||||
break;
|
||||
case 51:
|
||||
if (hashtableOpName_IsHaveComputer[opName].ToString() == "1")
|
||||
{
|
||||
SaveProductLeaveData(opName, 1);
|
||||
}
|
||||
|
||||
break;
|
||||
case 8:
|
||||
if (hashtableOpName_IsHaveComputer[opName].ToString() == "1")
|
||||
{
|
||||
SaveProductLeaveData(opName, 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,408 @@
|
||||
using BasicData;
|
||||
using bizFacade;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesDataFunctionWebApi
|
||||
{
|
||||
partial class Function
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取质量数据Hashtable
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <returns></returns>
|
||||
static public Hashtable ReadPLC_Sync_DataList_MesRead(string opName)
|
||||
{
|
||||
return (Hashtable)MesDataFunctionWebApi.OpcOperation.ReadPLC_Sync_DataList_MesRead(opName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 允许保存(针对半自动和手动压装工位)
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
private static void MesRead(string opName, string tagValue, int tagid)
|
||||
{
|
||||
if (tagValue == "0")
|
||||
{
|
||||
Write_TagTypeID(20, opName, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveQualityData(opName, Convert.ToInt32(tagValue), tagid);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveQualityData(string opName, int tagValue, int tagID)
|
||||
{
|
||||
try
|
||||
{
|
||||
int id_tagCF;
|
||||
int qualityMask = 0;
|
||||
int engineTypeID = 0;
|
||||
string engineID = "";
|
||||
string engineType = "";
|
||||
string engineTraceCode = "";
|
||||
string engineCap = "";
|
||||
string partPallet = "";
|
||||
DataTable dt_WWW;
|
||||
dt_WWW = BaseDataSystemMES.BuildDataTables_WWW();
|
||||
Hashtable valueList;
|
||||
valueList = ReadPLC_Sync_DataList_MesRead(opName);
|
||||
valueList = GetQualityData_GoodBad_Values(valueList);
|
||||
int mes_MustTest = 0;
|
||||
int onLineState = 0;
|
||||
int partMoveDirection = 0;
|
||||
int pressIsOK = 0;
|
||||
int pressIsNoOK = 0;
|
||||
BaseDataSystemMES.GetQualityDataTable_B5A(valueList, opName, BasicDataTagValue,
|
||||
BasicDataTagValueUpDown,
|
||||
out dt_WWW,//数据列表
|
||||
out qualityMask,//工位合格标志
|
||||
out engineTypeID,//发动机类型代码
|
||||
out engineID,//发动机编号
|
||||
out engineType, //发动机型号
|
||||
out partPallet,//托盘编号
|
||||
out engineTraceCode, //发动机条码
|
||||
out engineCap,//缸盖号,
|
||||
hashtable_EngineTypeID,//发动机类型转换表
|
||||
out mes_MustTest, out onLineState, out partMoveDirection, out pressIsOK, out pressIsNoOK);
|
||||
|
||||
|
||||
|
||||
|
||||
// 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据
|
||||
if (Convert.ToInt32(hashtable_tagTable_OpName_SaveData[opName]) != 0)
|
||||
{
|
||||
DateTime lastupdatetime = DateTime.Now;
|
||||
|
||||
BaseDataSystemMES.BaseData_tagTable_QualityData_B5A_IndexInsert(engineID, tagID, engineType, engineTypeID, opName, qualityMask, partPallet, out id_tagCF);
|
||||
BaseDataSystemMES.BaseData_tagTable_QualityData_B5A_Insert(id_tagCF, engineTypeID, engineID, opName, dt_WWW);
|
||||
|
||||
}
|
||||
Write_TagTypeID(20, opName, true);
|
||||
#region
|
||||
//string orderForm = "";
|
||||
//string operatorCode = "";
|
||||
//int shiftCode = 1;
|
||||
//DateTime arrivedTime;
|
||||
//DateTime leavedTime;
|
||||
//int TimeDiff;
|
||||
//int targetTime = 0;
|
||||
//string lineType = "";
|
||||
//string isPass;
|
||||
//int machineWorkOn = 0;
|
||||
//int arrivedOrLeaved = 2;
|
||||
//int cartColorOpName = 0;
|
||||
//int cartColorConfirm = 0;
|
||||
//// int partMoveDirection;
|
||||
//int partGoOver = 0;
|
||||
//if (qualityMask == 1)
|
||||
//{
|
||||
// isPass = "PASS";
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// isPass = "FAIL";
|
||||
//}
|
||||
|
||||
////工位上下线类型
|
||||
////(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线)
|
||||
//int OpNameUpDownType;
|
||||
//OpNameUpDownType = Convert.ToInt32(hashtableOpName_OpType[opName]);
|
||||
//arrivedTime = (DateTime)m_WorkStart_OpName_Time[opName];
|
||||
//leavedTime = DateTime.Now;
|
||||
//TimeDiff = Convert.ToInt32(leavedTime.Subtract(arrivedTime).TotalSeconds);
|
||||
|
||||
//lineType = hashtableOpName_LineType[opName].ToString();
|
||||
|
||||
//string isHaveComputer = hashtableOpName_IsHaveComputer[opName].ToString();
|
||||
////isHaveComputer = MIS_BASE.hashtable_tagTable_OpName_SaveData[opName].ToString();
|
||||
////有计算机的工位,通过工位计算机保存[测量数据发动机在线状态]。
|
||||
//if (Convert.ToInt32(isHaveComputer) == 0)
|
||||
//{
|
||||
// //1->0 工件离开 工件刚刚离开
|
||||
// if (Convert.ToInt32(m_WorkStart_OpName[opName]) == 1)
|
||||
// {
|
||||
|
||||
// //[测量数据发动机在线状态]
|
||||
// QualityDataSystem.WorkStartInsert
|
||||
// (opName, orderForm, engineTypeID, engineType, engineID, partPallet.ToString(), operatorCode, shiftCode,
|
||||
// arrivedTime, leavedTime, TimeDiff, targetTime, lineType, isPass, machineWorkOn,
|
||||
// arrivedOrLeaved, cartColorOpName, cartColorConfirm, partMoveDirection, partGoOver, mes_MustTest, onLineState, OpNameUpDownType);
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
Write_TagTypeID(20, opName, true);
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
}
|
||||
|
||||
}
|
||||
public static void SaveQualityData_Mes(string opName, int tagID)
|
||||
{
|
||||
try
|
||||
{
|
||||
int id_tagCF;
|
||||
int qualityMask = 0;
|
||||
int engineTypeID = 0;
|
||||
string engineID = "";
|
||||
string engineType = "";
|
||||
string engineTraceCode = "";
|
||||
string engineCap = "";
|
||||
string partPallet = "";
|
||||
DataTable dt_WWW;
|
||||
dt_WWW = BaseDataSystemMES.BuildDataTables_WWW();
|
||||
Hashtable valueList;
|
||||
valueList = ReadPLC_Sync_DataList_MesRead(opName);
|
||||
valueList = GetQualityData_GoodBad_Values(valueList);
|
||||
int mes_MustTest = 0;
|
||||
int onLineState = 0;
|
||||
int partMoveDirection = 0;
|
||||
int pressIsOK = 0;
|
||||
int pressIsNoOK = 0;
|
||||
BaseDataSystemMES.GetQualityDataTable_B5A(valueList, opName, BasicDataTagValue,
|
||||
BasicDataTagValueUpDown,
|
||||
out dt_WWW,//数据列表
|
||||
out qualityMask,//工位合格标志
|
||||
out engineTypeID,//发动机类型代码
|
||||
out engineID,//发动机编号
|
||||
out engineType, //发动机型号
|
||||
out partPallet,//托盘编号
|
||||
out engineTraceCode, //发动机条码
|
||||
out engineCap,//缸盖号,
|
||||
hashtable_EngineTypeID,//发动机类型转换表
|
||||
out mes_MustTest, out onLineState, out partMoveDirection, out pressIsOK, out pressIsNoOK);
|
||||
// 1:通过监控系统保存采集的质量数据;0:不通过监控系统保存采集的质量数据
|
||||
if (Convert.ToInt32(hashtable_tagTable_OpName_SaveData[opName]) != 0)
|
||||
{
|
||||
DateTime lastupdatetime = DateTime.Now;
|
||||
BaseDataSystemMES.BaseData_tagTable_QualityData_B5A_IndexInsert(engineID, tagID, engineType, engineTypeID, opName, qualityMask, partPallet, out id_tagCF);
|
||||
//BaseDataSystemMES.BaseData_tagTable_QualityData_B5A_Insert(id_tagCF, engineTypeID, engineID, opName, dt_WWW);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
Write_TagTypeID(20, opName, true);
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 确定合格标志
|
||||
/// </summary>
|
||||
/// <param name="valuList"></param>
|
||||
/// <returns></returns>
|
||||
static public Hashtable GetQualityData_GoodBad_Values(Hashtable valuList)
|
||||
{
|
||||
try
|
||||
{
|
||||
Hashtable valuList_Temp;
|
||||
valuList_Temp = (Hashtable)valuList.Clone();
|
||||
int[] value_GoodBad_New = new int[128];
|
||||
int tagID;
|
||||
QualityDataType value;
|
||||
//1:获得合格标志
|
||||
foreach (DictionaryEntry de in valuList) //ht为一个Hashtable实例
|
||||
{
|
||||
tagID = Convert.ToInt32(de.Key);
|
||||
value = (QualityDataType)de.Value;
|
||||
|
||||
//拧紧数据合格标志
|
||||
if (value.tagProperty == 1)
|
||||
{
|
||||
if (value.tagTypeID == 8203)
|
||||
{
|
||||
value_GoodBad_New = (int[])value.tagValue;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
value_GoodBad_New[value.tagOrderBy - 1] = Convert.ToInt32(value.tagValue);
|
||||
}
|
||||
}
|
||||
//拧紧数据合格标志
|
||||
if (value.tagProperty == 8)
|
||||
{
|
||||
if (value.tagTypeID == 8203)
|
||||
{
|
||||
value_GoodBad_New = (int[])value.tagValue;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
value_GoodBad_New[value.tagOrderBy - 1] = Convert.ToInt32(value.tagValue);
|
||||
}
|
||||
}
|
||||
//压装数据合格标志
|
||||
if (value.tagProperty == 7)
|
||||
{
|
||||
value_GoodBad_New[value.tagOrderBy - 1] = Convert.ToInt32(value.tagValue);
|
||||
}
|
||||
}
|
||||
//将合格标志赋予每个变量
|
||||
foreach (DictionaryEntry de in valuList) //ht为一个Hashtable实例
|
||||
{
|
||||
tagID = Convert.ToInt32(de.Key);
|
||||
value = (QualityDataType)de.Value;
|
||||
//201706061720新加
|
||||
if (value .tagTypeID ==11)
|
||||
{
|
||||
if (value.tagValue.ToString ()=="False")
|
||||
{
|
||||
value.tagValue ="0";
|
||||
}
|
||||
else
|
||||
{
|
||||
value.tagValue = "1";
|
||||
}
|
||||
valuList_Temp[tagID] = value;
|
||||
//value.tagValue = Convert.ToInt32(value.tagValue);
|
||||
}
|
||||
|
||||
|
||||
//测量变量
|
||||
if (value.tagProperty == 2 || value.tagProperty == 6)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (value_GoodBad_New != null)
|
||||
{
|
||||
value.isGoodBad = Convert.ToInt32(value_GoodBad_New[value.tagOrderBy - 1]);
|
||||
valuList_Temp[tagID] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
value.isGoodBad = 0;
|
||||
valuList_Temp[tagID] = value;
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return valuList_Temp;
|
||||
}
|
||||
catch//转换出了故障时
|
||||
{
|
||||
return valuList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 制定工位PLC是否传递过机型 (默认不传递机型不保存过站信息)
|
||||
/// </summary>
|
||||
static Hashtable EngTypeGetOver = new Hashtable();
|
||||
|
||||
static Hashtable EngineData_Hash = new Hashtable(); //保存
|
||||
|
||||
public static void IsEngTypeGetOver_Write(string OpName, bool value)
|
||||
{
|
||||
if (EngTypeGetOver.ContainsKey(OpName))
|
||||
{
|
||||
EngTypeGetOver[OpName] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
EngTypeGetOver.Add(OpName, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool IsEngTypeGetOver_Read(string OpName)
|
||||
{
|
||||
if (EngTypeGetOver.ContainsKey(OpName))
|
||||
{
|
||||
return Convert.ToBoolean(EngTypeGetOver[OpName]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void EngineData_Hash_Write(string OpName, object value)
|
||||
{
|
||||
if (EngineData_Hash.ContainsKey(OpName))
|
||||
{
|
||||
EngineData_Hash[OpName] = value;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
EngineData_Hash.Add(OpName, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static object EngineData_Hash_Read(string OpName)
|
||||
{
|
||||
if (EngineData_Hash.ContainsKey(OpName))
|
||||
{
|
||||
return EngineData_Hash[OpName];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private DataTable ChangeQualificationMark(DataTable dt)
|
||||
{
|
||||
var dtNew = dt.Copy();
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
var 变量排序 = dt.Rows[i]["变量排序"].ToString();
|
||||
if (变量排序 == "0")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return dtNew;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
struct EngineData
|
||||
{
|
||||
public EngineData(string engineID, int pallet)
|
||||
{
|
||||
EngineID = engineID;
|
||||
Pallet = pallet;
|
||||
}
|
||||
|
||||
public string EngineID;//工件编号
|
||||
//public string EngineType;
|
||||
//public int EngineTypeID;
|
||||
public int Pallet;//托盘号
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
using BasicData;
|
||||
using bizFacade;
|
||||
using DataLinkMesWork;
|
||||
using MesServerWork;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MesDataFunctionWebApi
|
||||
{
|
||||
partial class Function
|
||||
{
|
||||
/// <summary>
|
||||
/// 工件到位与离开时,清空MES自身信号
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
private static void WorkStart(string opName, string tagValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
//工位没有工件,或工件刚刚离开 工件离开工位后,清空该工位的发动机号
|
||||
if (tagValue == "0")
|
||||
{
|
||||
Write_TagTypeID(5, opName, false);//MES传递机型
|
||||
Write_TagTypeID(66, opName, false);//允许工作
|
||||
Write_TagTypeID(51, opName, false);//合格放行
|
||||
Write_TagTypeID(8, opName, false);//不合格放行
|
||||
Write_TagTypeID(7, opName, false);//工作完成
|
||||
Write_TagTypeID(20, opName, false);//保存完成
|
||||
|
||||
string isHaveComputer = hashtableOpName_IsHaveComputer[opName].ToString();
|
||||
if (Convert.ToInt32(isHaveComputer) == 0)//自动工位 读合格标志
|
||||
{
|
||||
if (IsEngTypeGetOver_Read(opName))
|
||||
{
|
||||
//PLC未传递机型 不保存过站信息
|
||||
SaveProductLeaveData_AutoWorkStation(opName, Convert.ToInt32(MesDataFunction.OpcOperation.ReadPLC(21, opName)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//清空信号
|
||||
m_WorkStart_OpName[opName] = 0;//清空工件到位标志
|
||||
//通知WEB更新产量
|
||||
SendActuallyCount(opName,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//保存工件到达数据
|
||||
m_WorkStart_OpName_Time[opName] = DateTime.Now;
|
||||
m_WorkStart_OpName[opName] = 1;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存过站信息 (数据库读机型信息)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="QualityMark"></param>
|
||||
static void SaveProductLeaveData(string opName, int QualityMark)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsEngTypeGetOver_Read(opName))
|
||||
{
|
||||
//PLC未传递机型 不保存过站信息
|
||||
return;
|
||||
}
|
||||
IsEngTypeGetOver_Write(opName, false);//清空传递机型标志
|
||||
|
||||
DateTime arrivedTime;
|
||||
DateTime leavedTime;
|
||||
int TimeDiff;
|
||||
int targetTime = 0;
|
||||
string lineType = "";
|
||||
string isPass;
|
||||
if (QualityMark == 1)
|
||||
{
|
||||
isPass = "PASS";
|
||||
}
|
||||
else
|
||||
{
|
||||
isPass = "FAIL";
|
||||
}
|
||||
//工位上下线类型
|
||||
//(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线)
|
||||
int OpNameUpDownType;
|
||||
OpNameUpDownType = Convert.ToInt32(hashtableOpName_OpType[opName]);
|
||||
arrivedTime = (DateTime)m_WorkStart_OpName_Time[opName];
|
||||
leavedTime = DateTime.Now;
|
||||
TimeDiff = Convert.ToInt32(leavedTime.Subtract(arrivedTime).TotalSeconds);
|
||||
lineType = hashtableOpName_LineType[opName].ToString();
|
||||
|
||||
//1->0 工件离开 工件刚刚离开
|
||||
if (Convert.ToInt32(m_WorkStart_OpName[opName]) == 1)
|
||||
{
|
||||
WorkStartInsert(opName, arrivedTime, leavedTime, TimeDiff, targetTime, lineType, isPass, OpNameUpDownType);
|
||||
}
|
||||
//通知WEB更新产量
|
||||
SendActuallyCount(opName, 0);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存过站信息 (数据库读机型信息)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="QualityMark"></param>
|
||||
static void SaveProductLeaveData_AutoWorkStation(string opName, int QualityMark)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsEngTypeGetOver_Read(opName))
|
||||
{
|
||||
//PLC未传递机型 不保存过站信息
|
||||
return;
|
||||
}
|
||||
IsEngTypeGetOver_Write(opName, false);//清空传递机型标志
|
||||
|
||||
DateTime arrivedTime;
|
||||
DateTime leavedTime;
|
||||
int TimeDiff;
|
||||
int targetTime = 0;
|
||||
string lineType = "";
|
||||
string isPass;
|
||||
if (QualityMark == 1)
|
||||
{
|
||||
isPass = "PASS";
|
||||
}
|
||||
else
|
||||
{
|
||||
isPass = "FAIL";
|
||||
}
|
||||
//工位上下线类型
|
||||
//(0普通工位)(1正常上线)(2正常下线)(3返修上线)(4返修下线)
|
||||
int OpNameUpDownType;
|
||||
OpNameUpDownType = Convert.ToInt32(hashtableOpName_OpType[opName]);
|
||||
arrivedTime = (DateTime)m_WorkStart_OpName_Time[opName];
|
||||
leavedTime = DateTime.Now;
|
||||
TimeDiff = Convert.ToInt32(leavedTime.Subtract(arrivedTime).TotalSeconds);
|
||||
lineType = hashtableOpName_LineType[opName].ToString();
|
||||
|
||||
//1->0 工件离开 工件刚刚离开
|
||||
if (Convert.ToInt32(m_WorkStart_OpName[opName]) == 1)
|
||||
{
|
||||
//查询工件编号、托盘号
|
||||
EngineData Enginedata = (EngineData)EngineData_Hash_Read(opName);
|
||||
WorkStartInsert_AutoWorkStation(opName, Enginedata.EngineID, Enginedata.Pallet, arrivedTime, leavedTime, TimeDiff, targetTime, lineType, isPass, OpNameUpDownType);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测量数据发动机在线状态_增加数据
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="arrivedTime"></param>
|
||||
/// <param name="leavedTime"></param>
|
||||
/// <param name="TimeDiff"></param>
|
||||
/// <param name="Target"></param>
|
||||
/// <param name="isPass"></param>
|
||||
static public void WorkStartInsert(string opName, DateTime arrivedTime, DateTime leavedTime, int TimeDiff, int Target, string lineType, string isPass, int OpNameUpDownType)
|
||||
{
|
||||
string procedureName;
|
||||
procedureName = "测量数据发动机在线状态_增加数据";
|
||||
SqlParameter[] thisParms = new SqlParameter[8];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@到达时间", arrivedTime);
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@离开时间", leavedTime);
|
||||
thisParms[3] = new System.Data.SqlClient.SqlParameter("@在线时间", TimeDiff);
|
||||
thisParms[4] = new System.Data.SqlClient.SqlParameter("@目标时间", Target);
|
||||
thisParms[5] = new System.Data.SqlClient.SqlParameter("@线体类型", lineType);
|
||||
thisParms[6] = new System.Data.SqlClient.SqlParameter("@是否合格", isPass);
|
||||
thisParms[7] = new System.Data.SqlClient.SqlParameter("@工位上下线类型", OpNameUpDownType);
|
||||
DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测量数据发动机在线状态_增加数据_自动工位
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="EngineID"></param>
|
||||
/// <param name="Pallet"></param>
|
||||
/// <param name="arrivedTime"></param>
|
||||
/// <param name="leavedTime"></param>
|
||||
/// <param name="TimeDiff"></param>
|
||||
/// <param name="Target"></param>
|
||||
/// <param name="lineType"></param>
|
||||
/// <param name="isPass"></param>
|
||||
/// <param name="OpNameUpDownType"></param>
|
||||
static public void WorkStartInsert_AutoWorkStation(string opName, string EngineID, int Pallet, DateTime arrivedTime, DateTime leavedTime, int TimeDiff, int Target, string lineType, string isPass, int OpNameUpDownType)
|
||||
{
|
||||
string procedureName;
|
||||
procedureName = "测量数据发动机在线状态_增加数据_自动工位";
|
||||
SqlParameter[] thisParms = new SqlParameter[10];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@发动机号", EngineID);
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@托盘编号", Pallet);
|
||||
thisParms[3] = new System.Data.SqlClient.SqlParameter("@到达时间", arrivedTime);
|
||||
thisParms[4] = new System.Data.SqlClient.SqlParameter("@离开时间", leavedTime);
|
||||
thisParms[5] = new System.Data.SqlClient.SqlParameter("@在线时间", TimeDiff);
|
||||
thisParms[6] = new System.Data.SqlClient.SqlParameter("@目标时间", Target);
|
||||
thisParms[7] = new System.Data.SqlClient.SqlParameter("@线体类型", lineType);
|
||||
thisParms[8] = new System.Data.SqlClient.SqlParameter("@是否合格", isPass);
|
||||
thisParms[9] = new System.Data.SqlClient.SqlParameter("@工位上下线类型", OpNameUpDownType);
|
||||
DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 发送在线产量、在线节拍
|
||||
/// </summary>
|
||||
/// <param name="OpName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
static void SendActuallyCount(string OpName, int tagValue)
|
||||
{
|
||||
//当工件离开时,更新在线产量、在线节拍
|
||||
if (tagValue == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
int opNameCount = 0;//在线产量
|
||||
int opNameCountTime = 0;//在线节拍
|
||||
//基本数据_工作日历_班次产量查询_New
|
||||
BaseDataSystemMES.OpNameCount_New(OpName, out opNameCount, out opNameCountTime);
|
||||
|
||||
string SendMessage;
|
||||
SendMessage = "MES|ActuallyCount|" + OpName + "|" + opNameCount.ToString() + "&" + opNameCountTime.ToString();
|
||||
|
||||
MIS_BASE.asyncSendMessage(SendMessage);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, "Function01:SendActuallyCount");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
using BasicData;
|
||||
using MesWork;
|
||||
using OpcBasic;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MesDataFunctionWebApi
|
||||
{
|
||||
|
||||
/*
|
||||
HeartBeatMIS 15
|
||||
EngineTypeGetOverMES 5
|
||||
PartPalletGoOver 6
|
||||
MaterialVerifyOver 7
|
||||
FalseGo 8
|
||||
ConfirmOkGo 51
|
||||
PartLoadFinish 52
|
||||
UnloadCompleted 53
|
||||
MachineTime_ReadOver 54
|
||||
FixAllow 66
|
||||
FixOver 67
|
||||
MatchingCompleted 68
|
||||
Match 69
|
||||
Reserved_1 70
|
||||
IsAutoGetEngineID 71
|
||||
RepairUplineMES 72
|
||||
ProcessCode 77
|
||||
BoltCode 88
|
||||
RepairStatus 93
|
||||
Reserved_3 24
|
||||
Reserved_4 25
|
||||
Reserved_5 26
|
||||
Reserved_6 27
|
||||
Reserved_7 28
|
||||
Reserved_8 29
|
||||
Reserved_9 30
|
||||
Reserved_10 31
|
||||
Reserved_11 32
|
||||
Reserved_12 33
|
||||
Reserved_13 34
|
||||
Reserved_14 35
|
||||
MesReadOver 20
|
||||
Reserved_15 110
|
||||
Reserved_16 111
|
||||
Reserved_17 112
|
||||
OnLineState 79
|
||||
EngineTypeID_MES 73
|
||||
EngineID_MES 74
|
||||
EngineType_MES 75
|
||||
MarkID 42
|
||||
RepairPathString 4
|
||||
SPareint1 113
|
||||
SPareint2 114
|
||||
SPareint3 115
|
||||
Sparestring1 116
|
||||
Sparestring2 117
|
||||
HeartBeatPLC 14
|
||||
WorkStart 2
|
||||
RepairPartStatusPLC 3
|
||||
PartLoad 43
|
||||
EngineTypeGetOverPLC 44
|
||||
PartLoadOK 48
|
||||
Reserved_18 49
|
||||
PalletDown 50
|
||||
Reserved_19 58
|
||||
FixOK 59
|
||||
Reserved_20 76
|
||||
Reserved_21 61
|
||||
Reserved_22 62
|
||||
Reserved_23 63
|
||||
Reserved_24 64
|
||||
Reserved_25 65
|
||||
EngineTypeID 9
|
||||
EngineID 10
|
||||
EngineType 11
|
||||
PartPalletCode 80
|
||||
PalletInfo 22
|
||||
MesRead 19
|
||||
PutOn 1000
|
||||
WorkOn 1001
|
||||
Alarm 1002
|
||||
NoPart 1003
|
||||
Block 1004
|
||||
PartPalletStatus 13
|
||||
TargetTimeRead 16
|
||||
QualityMask 21
|
||||
RepairStatusPLC 23
|
||||
MachineTargetTime 17
|
||||
MachineActualTime 18
|
||||
PLCSPareint1 36
|
||||
PLCSPareint2 37
|
||||
PLCSPareint3 38
|
||||
PLCSarestring1 39
|
||||
PLCSarestring2 40
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public class OpcOperation
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
static readonly object l = new object();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="tagTypeCodeID"></param>
|
||||
/// <param name="opName"></param>
|
||||
/// <returns></returns>
|
||||
public static object ReadPLC(int tagTypeCodeID, string opName)
|
||||
{
|
||||
return PlcLinkForm.ReadPLC(tagTypeCodeID, opName);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="tagID"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void ReadPLC(string tagID, out object tagValue)
|
||||
{
|
||||
tagValue = PlcLinkForm.ReadPLC(tagID);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <returns></returns>
|
||||
public static object ReadPLC_Sync_DataList_MesRead(string opName)
|
||||
{
|
||||
lock (l)
|
||||
{
|
||||
Hashtable ht = new Hashtable();
|
||||
|
||||
var cd = PlcLinkForm.ReadPLC_GroupData(opName);
|
||||
|
||||
foreach (KeyValuePair<string,object> _cd in cd)
|
||||
{
|
||||
var tagID = Convert.ToInt32(_cd.Key);
|
||||
var TF = (TagFormat)_cd.Value;
|
||||
|
||||
QualityDataType qualityDataType;
|
||||
qualityDataType = new QualityDataType();
|
||||
|
||||
qualityDataType.tagID = TF.TagID;
|
||||
qualityDataType.tagTypeID = TF.TagTypeID ;//变量类型
|
||||
qualityDataType.opName = opName;
|
||||
qualityDataType.isGoodBad = 192;
|
||||
int.TryParse(TF.TagQuality, out int TagQuality);
|
||||
qualityDataType.tagQuality = TagQuality;
|
||||
qualityDataType.tagValueType = TF.TagTypeCodeID;
|
||||
int.TryParse(TF.TagOrderBy, out int TagOrderBy);
|
||||
qualityDataType.tagOrderBy = TagOrderBy;
|
||||
int.TryParse(TF.TagItemOrderBy, out int TagItemOrderBy);
|
||||
qualityDataType.tagItemOrderBy = TagItemOrderBy;
|
||||
qualityDataType.tagProperty = TF.TagProperty;//变量特点
|
||||
qualityDataType.tagValue = TF.TagValue;//变量值
|
||||
|
||||
ht.Add(tagID , qualityDataType);
|
||||
}
|
||||
return ht;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="tagTypeCodeID"></param>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void ReadTagValue(string tagID, out string tagValue)
|
||||
{
|
||||
tagValue = "0";
|
||||
var tagValueObj = PlcLinkForm.ReadPLC(tagID);
|
||||
var type = tagValueObj.GetType().Name.ToLower();
|
||||
if (type == "bool" | type == "boolean")
|
||||
{
|
||||
var val = tagValueObj.ToString().ToLower();
|
||||
|
||||
if (val == "true")
|
||||
{
|
||||
tagValue = "1";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tagValue = tagValueObj.ToString();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="tagTypeCodeID"></param>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
public static void ReadTagValue(int tagTypeCodeID, string opName, out string tagValue)
|
||||
{
|
||||
tagValue = "0";
|
||||
var tagValueObj = PlcLinkForm.ReadPLC(tagTypeCodeID, opName);
|
||||
var type = tagValueObj.GetType().Name.ToLower();
|
||||
if (type == "bool" | type == "boolean")
|
||||
{
|
||||
var val = tagValueObj.ToString().ToLower();
|
||||
|
||||
if (val == "true")
|
||||
{
|
||||
tagValue = "1";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tagValue = tagValueObj.ToString();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="tagID"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
/// <returns></returns>
|
||||
public static bool WritePLC(string tagID, object tagValue)
|
||||
{
|
||||
return PlcLinkForm.WritePLC(tagID, tagValue);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="tagTypeCodeID"></param>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
/// <returns></returns>
|
||||
public static bool WritePLC(int tagTypeCodeID, string opName, object tagValue)
|
||||
{
|
||||
return PlcLinkForm.WritePLC(tagTypeCodeID, opName, tagValue);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="tagTypeCodeID"></param>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
/// <returns></returns>
|
||||
public static bool WriteTagValue(int tagTypeCodeID, string opName, object tagValue)
|
||||
{
|
||||
return PlcLinkForm.WritePLC(tagTypeCodeID, opName, tagValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("MesDataFunction")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("MesDataFunction")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//将 ComVisible 设置为 false 将使此程序集中的类型
|
||||
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("0d55e2c7-82a4-4607-b4cc-e6cf2c1d1e4a")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Binary file not shown.
@@ -0,0 +1,848 @@
|
||||
using OpcBasic;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
|
||||
using MesWork;
|
||||
using System.Collections.Concurrent;
|
||||
using DoWhatPlc;
|
||||
using System.Collections;
|
||||
using MesDataFunctionWebApi;
|
||||
|
||||
namespace MesWorkWebApp
|
||||
{
|
||||
|
||||
[RoutePrefix("api/PLC1")]
|
||||
public partial class PLC1Controller : ApiController
|
||||
{
|
||||
[HttpGet]
|
||||
public HttpResponseMessage GetHashtableList()
|
||||
{
|
||||
HashtableList hsList = new HashtableList();
|
||||
hsList.hashtable_MesDll = HashtableList.hashtable_MesDll_Temp;
|
||||
hsList.hashtable_MesServerCode = HashtableList.hashtable_MesServerCode_Temp;
|
||||
hsList.hashtable_TagTypeDataType = HashtableList.hashtable_TagTypeDataType_Temp;
|
||||
hsList.hashtable_TagType = HashtableList.hashtable_TagType_Temp;
|
||||
hsList.hashtable_OpNameRepair = HashtableList.hashtable_OpNameRepair_Temp;
|
||||
hsList.hashtable_TagTypeTagName = HashtableList.hashtable_TagTypeTagName_Temp;
|
||||
|
||||
|
||||
hsList.hashtable_workStepProperty = HashtableList.hashtable_workStepProperty_Temp;
|
||||
hsList.hashtable_QualityMesRead = HashtableList.hashtable_QualityMesRead_Temp;
|
||||
hsList.hashtable_IsAllowWork = HashtableList.hashtable_IsAllowWork_Temp;
|
||||
hsList.hashtable_WorkGroupIndex = HashtableList.hashtable_WorkGroupIndex_Temp;
|
||||
hsList.hashtableOpName_OpType = HashtableList.hashtableOpName_OpType_Temp;
|
||||
hsList.hashtable_tagTable_OpName_SaveData = HashtableList.hashtable_tagTable_OpName_SaveData_Temp;
|
||||
|
||||
|
||||
|
||||
hsList.hashtable_EngineGetOver_EngineID = DoWhatPlc.HashtableList.hashtable_EngineGetOver_EngineID_Temp ;
|
||||
hsList.hashtable_EngineGetOver_EngineTypeID = DoWhatPlc.HashtableList.hashtable_EngineGetOver_EngineTypeID_Temp ;
|
||||
hsList.hashtable_EngineGetOver_EngineType = DoWhatPlc.HashtableList.hashtable_EngineGetOver_EngineType_Temp ;
|
||||
hsList.hashtable_EngineGetOver_OrderForm= DoWhatPlc.HashtableList.hashtable_EngineGetOver_OrderForm_Temp ;
|
||||
|
||||
hsList.BasicDataTagValue = MesServerWork.MIS_BASE.BasicDataTagValue;
|
||||
hsList.BasicDataTagValueUpDown = MesServerWork.MIS_BASE.BasicDataTagValueUpDown;
|
||||
hsList.hashtable_EngineTypeID = MesServerWork.MIS_BASE.hashtable_EngineTypeID;
|
||||
hsList.hashtable_tagTable_OpName_SaveData = MesServerWork.MIS_BASE.hashtable_tagTable_OpName_SaveData;
|
||||
|
||||
|
||||
var pp = JsonConvert.SerializeObject(hsList);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;//
|
||||
}
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadPLC_OpName(string opName)
|
||||
{
|
||||
try
|
||||
{
|
||||
string tagStartAdr = "";
|
||||
ushort tagAdrListMaxLength = 0;
|
||||
PlcLinkForm.GetDbAndMaxLengthByOpName(opName, out tagStartAdr, out tagAdrListMaxLength);
|
||||
var tagAdrListTagFormat = PlcLinkForm.ReadQualityDataList(opName, tagStartAdr, tagAdrListMaxLength);
|
||||
|
||||
var pp = JsonConvert.SerializeObject(tagAdrListTagFormat);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var pp = JsonConvert.SerializeObject(ex.Message);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadPLC_GroupMonitor(string opName)
|
||||
{
|
||||
List<TagIDTagFormat> TagIDTagFormatList = new List<TagIDTagFormat>();
|
||||
var cd = MesWork.PlcLinkForm.ReadPLC_GroupMonitor(opName);
|
||||
foreach (KeyValuePair<string, object> _cd in cd)
|
||||
{
|
||||
var tagID = _cd.Key;
|
||||
|
||||
var pp1 = JsonConvert.SerializeObject(_cd.Value);
|
||||
var pp2 = JsonConvert.DeserializeObject<DoWhatPlc.TagFormat>(pp1);
|
||||
TagIDTagFormat TagTF = new TagIDTagFormat(tagID, pp2);
|
||||
|
||||
TagIDTagFormatList.Add(TagTF);
|
||||
}
|
||||
var pp = JsonConvert.SerializeObject(TagIDTagFormatList);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadPLC_GroupData_Qd(string opName)
|
||||
{
|
||||
List<TagIDTagFormat> TagIDTagFormatList = new List<TagIDTagFormat>();
|
||||
var cd = MesWork.PlcLinkForm.ReadPLC_GroupData_Qd(opName);
|
||||
foreach (KeyValuePair<string, object> _cd in cd)
|
||||
{
|
||||
var tagID = _cd.Key;
|
||||
var pp1 = JsonConvert.SerializeObject(_cd.Value);
|
||||
var pp2 = JsonConvert.DeserializeObject<DoWhatPlc.TagFormat>(pp1);
|
||||
TagIDTagFormat TagTF = new TagIDTagFormat(tagID, pp2);
|
||||
|
||||
TagIDTagFormatList.Add(TagTF);
|
||||
}
|
||||
var pp = JsonConvert.SerializeObject(TagIDTagFormatList);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadPLC_GroupData(string opName)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<TagIDTagFormat> TagIDTagFormatList = new List<TagIDTagFormat>();
|
||||
var cd = MesWork.PlcLinkForm.ReadPLC_GroupData(opName);
|
||||
foreach (KeyValuePair<string, object> _cd in cd)
|
||||
{
|
||||
var tagID = _cd.Key;
|
||||
|
||||
var pp1 = JsonConvert.SerializeObject(_cd.Value);
|
||||
var pp2 = JsonConvert.DeserializeObject<DoWhatPlc.TagFormat>(pp1);
|
||||
TagIDTagFormat TagTF = new TagIDTagFormat(tagID, pp2);
|
||||
|
||||
TagIDTagFormatList.Add(TagTF);
|
||||
}
|
||||
var pp = JsonConvert.SerializeObject(TagIDTagFormatList);
|
||||
|
||||
//var rtList = JsonConvert.DeserializeObject<List<TagIDTagFormat>>(pp);
|
||||
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
catch(Exception err)
|
||||
{
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据tagType,工位号写入PLC对应值
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_TagValueByTagTypeName(string cmd, string opName, string tagValue)
|
||||
{
|
||||
int tagTypeID = 0;
|
||||
string msg;
|
||||
try
|
||||
{
|
||||
var rvValue = JsonConvert.DeserializeObject<ReturnValueString>(tagValue);
|
||||
ReturnValueObject ro = rvValue.ReturnValueToObject();
|
||||
|
||||
tagTypeID = Convert.ToInt32(MesDataFunction.OpcOperation.hashtable_TagType[cmd]);
|
||||
MesDataFunction.OpcOperation.WriteTagValue(tagTypeID, opName, ro.TagValue);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据tagType,工位号写入PLC对应值
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_TagValueByTagTypeNameList(string cmd, string opName, string tagValue)
|
||||
{
|
||||
int tagTypeID = 0;
|
||||
string msg;
|
||||
var cmd_List = JsonConvert.DeserializeObject<List<string>>(cmd);
|
||||
var opName_List = JsonConvert.DeserializeObject<List<string>>(opName);
|
||||
var tagValue_List = JsonConvert.DeserializeObject<List<string>>(tagValue);
|
||||
try
|
||||
{
|
||||
for(int i=0;i< cmd_List.Count;i++)
|
||||
{
|
||||
Write_TagValueByTagTypeName(cmd, opName, tagValue);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过TagTypeName读取PLC数据 列表
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_TagValueByTagTypeNameList(string cmd, string opName)
|
||||
{
|
||||
object tagValue;
|
||||
List<ReturnValueString> rvList = new List<ReturnValueString>();
|
||||
tagValue = "-1";
|
||||
int tagTypeID;
|
||||
var cmd_List = JsonConvert.DeserializeObject<List<string>>(cmd);
|
||||
var opName_List = JsonConvert.DeserializeObject<List<string>>(opName);
|
||||
|
||||
try
|
||||
{
|
||||
for(int i = 0; i < cmd_List.Count; i++)
|
||||
{
|
||||
cmd = cmd_List[i];
|
||||
opName = opName_List[i];
|
||||
tagTypeID = Convert.ToInt32(MesDataFunction.OpcOperation.hashtable_TagType[cmd]);
|
||||
tagValue = PlcLinkForm.ReadPLC(tagTypeID, opName);
|
||||
ReturnValueString rv = new ReturnValueString();
|
||||
rv.CmdPlcReadWrite = cmd;
|
||||
rv.OpName = opName;
|
||||
rv.TagValue = tagValue.ToString();
|
||||
rv.TagTypeID = tagTypeID.ToString();
|
||||
rv.ValueType = tagValue.GetType().Name.ToLower();
|
||||
|
||||
rvList.Add(rv);
|
||||
}
|
||||
|
||||
var pp = JsonConvert.SerializeObject(rvList);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
var pp = JsonConvert.SerializeObject(err);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过TagTypeName读取PLC数据
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_TagValueByTagTypeName(string cmd, string opName)
|
||||
{
|
||||
object tagValue = "-1";
|
||||
int tagTypeID;
|
||||
try
|
||||
{
|
||||
tagTypeID = Convert.ToInt32(MesDataFunction.OpcOperation.hashtable_TagType[cmd]);
|
||||
tagValue = PlcLinkForm.ReadPLC(tagTypeID, opName);
|
||||
ReturnValueString rv = new ReturnValueString();
|
||||
rv.CmdPlcReadWrite = cmd;
|
||||
rv.OpName = opName;
|
||||
rv.TagValue = tagValue.ToString();
|
||||
rv.TagTypeID = tagTypeID.ToString();
|
||||
rv.ValueType = tagValue.GetType().Name.ToLower();
|
||||
var pp = JsonConvert.SerializeObject(rv);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
var pp = JsonConvert.SerializeObject(err);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// http://localhost:41180/api/PLC/ReadAllTagValue?opname=OP1010
|
||||
/// </summary>
|
||||
/// <param name="tagID"></param>
|
||||
/// <returns>ReturnValue</returns>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadAllTagValue(string opname)
|
||||
{
|
||||
var objValue = PlcLinkForm.ReadAllTagValue(opname);
|
||||
|
||||
var pp = JsonConvert.SerializeObject(objValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// http://localhost:41180/api/PLC/Get_opNameList
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Get_opNameList()
|
||||
{
|
||||
|
||||
var pp = JsonConvert.SerializeObject(PlcLinkForm.opNameList);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// http://localhost:41180/api/PLC/Get_ipList
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Get_ipList()
|
||||
{
|
||||
|
||||
var pp = JsonConvert.SerializeObject(PlcLinkForm.ipList);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Get_cd_Cache_IpGroupMonitorList()
|
||||
{
|
||||
var cd_Cache_IpGroupMonitorList = PlcLinkForm.DriverCache[CacheType.Cache_IpGroupMonitorList];
|
||||
var pp = JsonConvert.SerializeObject(cd_Cache_IpGroupMonitorList);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Get_TagAdrListTagFormat(string ip,string group)
|
||||
{
|
||||
ConcurrentDictionary<string, object> TagAdrListTagFormat;
|
||||
PlcLinkForm.Driver.ReadIpGroupDataList(ip, group, out TagAdrListTagFormat);
|
||||
|
||||
var pp = JsonConvert.SerializeObject(TagAdrListTagFormat);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadTagValue_tagAdrListTagFormat(string readWhat, string opOrIp)
|
||||
{
|
||||
ConcurrentDictionary<string, object> tagAdrListTagFormat = null;
|
||||
|
||||
switch (readWhat)
|
||||
{
|
||||
case "OpAllTag"://OP所有点
|
||||
tagAdrListTagFormat = PlcLinkForm.ReadPLC_GroupData(opOrIp);
|
||||
break;
|
||||
case "OpMonitorTag"://OP监控点
|
||||
tagAdrListTagFormat = PlcLinkForm.ReadPLC_GroupMonitor(opOrIp);
|
||||
break;
|
||||
case "IpAllTag"://IP所有点
|
||||
tagAdrListTagFormat = PlcLinkForm.ReadPLC_IpTag(opOrIp);
|
||||
break;
|
||||
case "IpMonitorTag"://IP监控点
|
||||
tagAdrListTagFormat = PlcLinkForm.ReadPLC_IpMonitorTag(opOrIp);
|
||||
break;
|
||||
case "RegionRead"://按区域读取(起始地址 + 长度)
|
||||
string tagStartAdr = "";
|
||||
ushort tagAdrListMaxLength = 0;
|
||||
PlcLinkForm.GetDbAndMaxLengthByOpName(opOrIp, out tagStartAdr, out tagAdrListMaxLength);
|
||||
tagAdrListTagFormat = PlcLinkForm.ReadQualityDataList(opOrIp, tagStartAdr, tagAdrListMaxLength);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
var pp = JsonConvert.SerializeObject(tagAdrListTagFormat);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
|
||||
}
|
||||
//
|
||||
/// <summary>
|
||||
/// http://localhost:41180/api/PLC/ReadPLC?opname=AOPOP001
|
||||
/// </summary>
|
||||
/// <param name="tagID"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadPLC(string tagID)
|
||||
{
|
||||
var tagValue = PlcLinkForm.ReadPLC(tagID);
|
||||
ReturnValueString rv = new ReturnValueString();
|
||||
rv.CmdPlcReadWrite = "";
|
||||
rv.OpName = "";
|
||||
rv.TagValue = tagValue.ToString();
|
||||
rv.TagID = tagID;
|
||||
rv.ValueType = tagValue.GetType().Name.ToLower();
|
||||
|
||||
var pp = JsonConvert.SerializeObject(rv);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadByteData_Op(string OpName,string Adr, string Length)
|
||||
{
|
||||
ushort LengthValue = Convert .ToUInt16(Length);
|
||||
var tagValue = PlcLinkForm.ReadByteData_Op(OpName, Adr, LengthValue); ;
|
||||
ReturnValueString rv = new ReturnValueString();
|
||||
rv.CmdPlcReadWrite = "";
|
||||
rv.OpName = "";
|
||||
rv.TagValue = System.Text.Encoding.UTF8.GetString(tagValue);
|
||||
rv.TagID = "";
|
||||
rv.ValueType = tagValue.GetType().Name.ToLower();
|
||||
|
||||
var pp = JsonConvert.SerializeObject(rv);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadByteData_Ip(string Ip, string Adr, string Length)
|
||||
{
|
||||
ushort LengthValue = Convert.ToUInt16(Length);
|
||||
|
||||
var tagValue = PlcLinkForm.ReadByteData_Op(Ip, Adr, LengthValue); ;
|
||||
ReturnValueString rv = new ReturnValueString();
|
||||
rv.CmdPlcReadWrite = "";
|
||||
rv.OpName = "";
|
||||
rv.TagValue = System.Text.Encoding.UTF8.GetString(tagValue);
|
||||
rv.TagID = "";
|
||||
rv.ValueType = tagValue.GetType().Name.ToLower();
|
||||
|
||||
var pp = JsonConvert.SerializeObject(rv);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public HttpResponseMessage WritePLC_Bytes_Op(string OpName, string Adr, string bytes)
|
||||
{
|
||||
byte[] bytesValue = JsonToByte(bytes);
|
||||
var tagValue = PlcLinkForm.WritePLC_Bytes_Op(OpName, Adr, bytesValue);
|
||||
ReturnValueString rv = new ReturnValueString();
|
||||
rv.CmdPlcReadWrite = "";
|
||||
rv.OpName = "";
|
||||
rv.TagValue = tagValue.ToString();
|
||||
rv.TagID = "";
|
||||
rv.ValueType = tagValue.GetType().Name.ToLower();
|
||||
|
||||
var pp = JsonConvert.SerializeObject(rv);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public HttpResponseMessage WritePLC_Bytes_Ip(string Ip, string Adr, string bytes)
|
||||
{
|
||||
byte[] bytesValue = JsonToByte(bytes);
|
||||
var tagValue = PlcLinkForm.WritePLC_Bytes_Ip(Ip, Adr, bytesValue); ;
|
||||
ReturnValueString rv = new ReturnValueString();
|
||||
rv.CmdPlcReadWrite = "";
|
||||
rv.OpName = "";
|
||||
rv.TagValue = tagValue.ToString();
|
||||
rv.TagID = "";
|
||||
rv.ValueType = tagValue.GetType().Name.ToLower();
|
||||
|
||||
var pp = JsonConvert.SerializeObject(rv);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
public string ByteToJson(byte[] bytes)
|
||||
{
|
||||
string convertJson = System.Text.Encoding.UTF8.GetString(bytes);
|
||||
return convertJson;
|
||||
}
|
||||
|
||||
public byte[] JsonToByte(string strjson)
|
||||
{
|
||||
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(strjson);
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
// case DoWhat.ReadByteData_Op://按区域读取(起始地址 + 长度)
|
||||
// {
|
||||
// //string tagStartAdr = "DB411.10";
|
||||
// //ushort tagAdrListMaxLength = 100;
|
||||
// result = PlcLinkForm.ReadByteData_Op(opOrIp, tagStartAdr, tagAdrListMaxLength);
|
||||
// }
|
||||
// break;
|
||||
// case DoWhat.ReadByteData_Ip://按区域读取(起始地址 + 长度)
|
||||
// {
|
||||
// //string tagStartAdr = "DB411.10";
|
||||
// //ushort tagAdrListMaxLength = 100;
|
||||
// result = PlcLinkForm.ReadByteData_Ip(opOrIp, tagStartAdr, tagAdrListMaxLength);
|
||||
// }
|
||||
// break;
|
||||
// case DoWhat.WritePLC_Bytes_Op://按区域读取(起始地址 + 长度)
|
||||
// {
|
||||
// //string tagStartAdr = "DB411.10";
|
||||
// result = PlcLinkForm.WritePLC_Bytes_Op(opOrIp, tagStartAdr, new byte[1024]);
|
||||
// }
|
||||
// break;
|
||||
// case DoWhat.WritePLC_Bytes_Ip://按区域读取(起始地址 + 长度)
|
||||
// {
|
||||
// //string tagStartAdr = "DB411.10";
|
||||
// result = PlcLinkForm.WritePLC_Bytes_Ip(opOrIp, tagStartAdr, new byte[1024]);
|
||||
// }
|
||||
// break;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// http://localhost:41180/api/PLC/ReadPLCList?tagID=["AOPOP001","AOPOP002"]
|
||||
/// </summary>
|
||||
/// <param name="tagID"> List<string></param>
|
||||
/// <returns>ReturnValue</returns>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadPLCList(string tagID)
|
||||
{
|
||||
|
||||
List<ReturnValueString> tagValeList = new List<ReturnValueString>();
|
||||
var tagID_List = JsonConvert.DeserializeObject<List<string>>(tagID);
|
||||
foreach (var tagID1 in tagID_List)
|
||||
{
|
||||
var objValue = PlcLinkForm.ReadPLC(tagID1);
|
||||
|
||||
object tagValue = PlcLinkForm.ReadPLC(tagID1);
|
||||
ReturnValueString rv = new ReturnValueString();
|
||||
rv.CmdPlcReadWrite = "";
|
||||
rv.OpName = "";
|
||||
rv.TagValue = tagValue.ToString();
|
||||
rv.TagID = tagID1;
|
||||
rv.ValueType = tagValue.GetType().Name.ToLower();
|
||||
|
||||
//ReturnValueString rs = new ReturnValueString(tagID1, objValue);
|
||||
tagValeList.Add(rv);
|
||||
}
|
||||
|
||||
var pp = JsonConvert.SerializeObject(tagValeList);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// http://localhost:41180/api/PLC/WritePLC?tagID=AOPOP001&tagValue=222
|
||||
/// </summary>
|
||||
/// <param name="tagID"> List<string></param>
|
||||
/// <param name="tagValue"> List<string></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public bool WritePLC(string tagID, string tagValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var rs = JsonConvert.DeserializeObject<ReturnValueString>(tagValue);
|
||||
var ro = rs.ReturnValueToObject();
|
||||
var objValue = PlcLinkForm.WritePLC(tagID, ro.TagValue);
|
||||
return objValue;
|
||||
}
|
||||
catch
|
||||
(Exception ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// http://localhost:41180/api/PLC/WritePLCList?tagID=["AOPOP001","AOPOP002"]&tagValue=["222","111"]
|
||||
/// </summary>
|
||||
/// <param name="tagID"> List<string></param>
|
||||
/// <param name="tagValue"> List<string></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public bool WritePLCList(string tagID, string tagValue)
|
||||
{
|
||||
var tagID_List = JsonConvert.DeserializeObject<List<string>>(tagID);
|
||||
var tagValue_List = JsonConvert.DeserializeObject<List<string>>(tagValue);
|
||||
bool objValue = false;
|
||||
for (int i = 0; i < tagID_List.Count; i++)
|
||||
{
|
||||
string tagID1 = tagID_List[i];
|
||||
var rs = JsonConvert.DeserializeObject<ReturnValueString>(tagValue_List[i]);
|
||||
var ro = rs.ReturnValueToObject();
|
||||
|
||||
objValue = PlcLinkForm.WritePLC(tagID1, ro.TagValue);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// http://localhost:41180/api/PLC/ReadPLC_TagTypeCodeID?tagTypeCodeID=10&opName=OP1010
|
||||
/// </summary>
|
||||
/// <param name="tagTypeCodeID"></param>
|
||||
/// <param name="opName"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadPLC_TagTypeCodeID(string tagTypeCodeID, string opName)
|
||||
{
|
||||
|
||||
var tagValue = PlcLinkForm.ReadPLC( Convert.ToInt32(tagTypeCodeID) , opName);
|
||||
ReturnValueString rv = new ReturnValueString();
|
||||
rv.CmdPlcReadWrite = "";
|
||||
rv.OpName = opName;
|
||||
rv.TagValue = tagValue.ToString();
|
||||
rv.TagTypeID = tagTypeCodeID.ToString();
|
||||
rv.ValueType = tagValue.GetType().Name.ToLower();
|
||||
var pp = JsonConvert.SerializeObject(rv);
|
||||
|
||||
//ReturnValueString rs = new ReturnValueString("", objValue, opName, tagTypeCodeID);
|
||||
//var pp = JsonConvert.SerializeObject(rs);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="tagTypeCodeID">List<string></param>
|
||||
/// <param name="opName">List<string></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadPLC_TagTypeCodeIDList(string tagTypeCodeID, string opName)
|
||||
{
|
||||
var tagTypeCodeID_List = JsonConvert.DeserializeObject<List<string>>(tagTypeCodeID);
|
||||
var opName_List = JsonConvert.DeserializeObject<List<string>>(opName);
|
||||
List<ReturnValueString> ReturnValueList = new List<ReturnValueString>();
|
||||
|
||||
|
||||
for (int i = 0; i < tagTypeCodeID_List.Count; i++)
|
||||
{
|
||||
string tagTypeCodeI1 = tagTypeCodeID_List[i];
|
||||
string opName1 = opName_List[i];
|
||||
var tagValue = PlcLinkForm.ReadPLC(Convert.ToInt32(tagTypeCodeI1), opName1);
|
||||
|
||||
ReturnValueString rv = new ReturnValueString();
|
||||
rv.CmdPlcReadWrite = "";
|
||||
rv.OpName = opName;
|
||||
rv.TagValue = tagValue.ToString();
|
||||
rv.TagTypeID = tagTypeCodeI1.ToString();
|
||||
rv.ValueType = tagValue.GetType().Name.ToLower();
|
||||
rv.TagTypeCodeID = tagTypeCodeI1;
|
||||
ReturnValueList.Add(rv);
|
||||
}
|
||||
var pp = JsonConvert.SerializeObject(ReturnValueList);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// http://localhost:41180/api/PLC/ReadPLC_TagTypeCodeID?tagTypeCodeID=10&opName=OP1010&tagValue=111
|
||||
/// </summary>
|
||||
/// <param name="tagTypeCodeID"></param>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public bool WritePLC_TagTypeCodeID(string tagTypeCodeID, string opName,string tagValue)
|
||||
{
|
||||
var rs = JsonConvert.DeserializeObject<ReturnValueString>(tagValue);
|
||||
var ro = rs.ReturnValueToObject();
|
||||
|
||||
var objValue = PlcLinkForm.WritePLC(Convert.ToInt32(tagTypeCodeID), opName, ro.TagValue);
|
||||
return objValue;
|
||||
}
|
||||
///// <summary>
|
||||
///// http://localhost:41180/api/PLC/ReadPLC_GroupData?opName=OP1010
|
||||
///// </summary>
|
||||
///// <param name="opOrIp"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//public HttpResponseMessage ReadPLC_GroupData(string opName)
|
||||
//{
|
||||
// List<ReturnValueString> rvList = new List<ReturnValueString>();
|
||||
// var objValue = PlcLinkForm.ReadPLC_GroupData(opName);
|
||||
// //得到工位信号列表
|
||||
// foreach (KeyValuePair<string, object> de in objValue)
|
||||
// {
|
||||
// DoWhatPlc.TagFormat TF = (DoWhatPlc.TagFormat)de.Value;
|
||||
// ReturnValueString rs = new ReturnValueString(TF.TagID, TF.TagValue, TF.OpName);
|
||||
// rvList.Add(rs);
|
||||
// }
|
||||
// //ReturnValue rv = new ReturnValue("", objValue, opOrIp);
|
||||
// var pp = JsonConvert.SerializeObject(rvList);
|
||||
// HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
// return result;
|
||||
//}
|
||||
///// <summary>
|
||||
///// http://localhost:41180/api/PLC/ReadPLC_GroupMonitor?opName=OP1010
|
||||
///// </summary>
|
||||
///// <param name="opName"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet]
|
||||
//public HttpResponseMessage ReadPLC_GroupMonitor(string opName)
|
||||
//{
|
||||
// List<ReturnValueString> rvList = new List<ReturnValueString>();
|
||||
// var objValue = PlcLinkForm.ReadPLC_GroupMonitor(opName);
|
||||
// foreach (KeyValuePair<string, object> de in objValue)
|
||||
// {
|
||||
// DoWhatPlc.TagFormat TF = (DoWhatPlc.TagFormat)de.Value;
|
||||
// ReturnValueString rs = new ReturnValueString(TF.TagID, TF.TagValue, TF.OpName);
|
||||
// rvList.Add(rs);
|
||||
// }
|
||||
// var pp = JsonConvert.SerializeObject(rvList);
|
||||
// HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
// return result;
|
||||
//}
|
||||
/// <summary>
|
||||
/// http://localhost:41180/api/PLC/ReadPLC_IpTag?ip=127.0.0.1
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadPLC_IpTag(string ip)
|
||||
{
|
||||
List<ReturnValueString> rvList = new List<ReturnValueString>();
|
||||
var objValue = PlcLinkForm.ReadPLC_IpTag(ip);
|
||||
foreach (KeyValuePair<string, object> de in objValue)
|
||||
{
|
||||
DoWhatPlc.TagFormat TF = (DoWhatPlc.TagFormat)de.Value;
|
||||
ReturnValueString rs = new ReturnValueString();
|
||||
rs.TagID = TF.TagID;
|
||||
rs.TagValue = TF.TagValue.ToString();
|
||||
rs.OpName = TF.OpName;
|
||||
rs.ValueType = TF.TagValue.GetType().Name.ToLower();
|
||||
rvList.Add(rs);
|
||||
}
|
||||
var pp = JsonConvert.SerializeObject(rvList);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// http://localhost:41180/api/PLC/ReadPLC_IpTag?ip=127.0.0.1
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadPLC_IpMonitorTag(string ip)
|
||||
{
|
||||
List<ReturnValueString> rvList = new List<ReturnValueString>();
|
||||
var objValue = PlcLinkForm.ReadPLC_IpMonitorTag(ip);
|
||||
foreach (KeyValuePair<string, object> de in objValue)
|
||||
{
|
||||
DoWhatPlc.TagFormat TF = (DoWhatPlc.TagFormat)de.Value;
|
||||
ReturnValueString rs = new ReturnValueString();
|
||||
rs.TagID = TF.TagID;
|
||||
rs.TagValue = TF.TagValue.ToString();
|
||||
rs.OpName = TF.OpName;
|
||||
rs.ValueType = TF.TagValue.GetType().Name.ToLower();
|
||||
rvList.Add(rs);
|
||||
}
|
||||
var pp = JsonConvert.SerializeObject(rvList);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 读写取方法
|
||||
/// </summary>
|
||||
/// <param name="readWhat"></param>
|
||||
/// <param name="opOrIp"></param>
|
||||
//[HttpGet]
|
||||
//private void ReadWritePLC(string doWhat, DoWhatPlc.TagFormat tf)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
|
||||
|
||||
// string opName = tf.OpName;//."OP1010";
|
||||
// object tagValue = tf.TagValue;
|
||||
// object result ;
|
||||
// string opOrIp = tf.IP;
|
||||
// string tagID = tf.TagID;
|
||||
// int tagTypeCodeID = tf.TagTypeCodeID;
|
||||
// string tagStartAdr = tf.TagOPCAdrStr;
|
||||
// ushort tagAdrListMaxLength =(ushort) tf.Length;
|
||||
|
||||
|
||||
// ConcurrentDictionary<string, object> tagAdrListTagFormat = null;
|
||||
|
||||
// switch (doWhat)
|
||||
// {
|
||||
// case DoWhat.ReadPLC_TagID:
|
||||
// tagValue = PlcLinkForm.ReadPLC(tagID);
|
||||
// break;
|
||||
// case DoWhat.WritePLC_TagID:
|
||||
// result = PlcLinkForm.WritePLC(tagID, tagValue);
|
||||
// break;
|
||||
|
||||
// case DoWhat.ReadPLC_TagTypeCodeID:
|
||||
// tagValue = PlcLinkForm.ReadPLC(tagTypeCodeID, opName);
|
||||
// break;
|
||||
// case DoWhat.WritePLC_TagTypeCodeID:
|
||||
// result = PlcLinkForm.WritePLC(tagTypeCodeID, opName, tagValue);
|
||||
// break;
|
||||
// case DoWhat.ReadPLC_GroupData://OP所有点
|
||||
// tagAdrListTagFormat = PlcLinkForm.ReadPLC_GroupData(opOrIp);
|
||||
// break;
|
||||
// case DoWhat.ReadPLC_GroupMonitor://OP监控点
|
||||
// tagAdrListTagFormat = PlcLinkForm.ReadPLC_GroupMonitor(opOrIp);
|
||||
// break;
|
||||
// case DoWhat.ReadPLC_IpTag://IP所有点
|
||||
// tagAdrListTagFormat = PlcLinkForm.ReadPLC_IpTag(opOrIp);
|
||||
// break;
|
||||
// case DoWhat.ReadPLC_IpMonitorTag://IP监控点
|
||||
// tagAdrListTagFormat = PlcLinkForm.ReadPLC_IpMonitorTag(opOrIp);
|
||||
// break;
|
||||
// case DoWhat.ReadQualityDataList://按区域读取(起始地址 + 长度)
|
||||
// {
|
||||
// //string tagStartAdr = "DB411.10";
|
||||
// //ushort tagAdrListMaxLength = 100;
|
||||
// PlcLinkForm.GetDbAndMaxLengthByOpName(opOrIp, out tagStartAdr, out tagAdrListMaxLength);
|
||||
// tagAdrListTagFormat = PlcLinkForm.ReadQualityDataList(opOrIp, tagStartAdr, tagAdrListMaxLength);
|
||||
// }
|
||||
// break;
|
||||
// case DoWhat.ReadByteData_Op://按区域读取(起始地址 + 长度)
|
||||
// {
|
||||
// //string tagStartAdr = "DB411.10";
|
||||
// //ushort tagAdrListMaxLength = 100;
|
||||
// result = PlcLinkForm.ReadByteData_Op(opOrIp, tagStartAdr, tagAdrListMaxLength);
|
||||
// }
|
||||
// break;
|
||||
// case DoWhat.ReadByteData_Ip://按区域读取(起始地址 + 长度)
|
||||
// {
|
||||
// //string tagStartAdr = "DB411.10";
|
||||
// //ushort tagAdrListMaxLength = 100;
|
||||
// result = PlcLinkForm.ReadByteData_Ip(opOrIp, tagStartAdr, tagAdrListMaxLength);
|
||||
// }
|
||||
// break;
|
||||
// case DoWhat.WritePLC_Bytes_Op://按区域读取(起始地址 + 长度)
|
||||
// {
|
||||
// //string tagStartAdr = "DB411.10";
|
||||
// result = PlcLinkForm.WritePLC_Bytes_Op(opOrIp, tagStartAdr, new byte[1024]);
|
||||
// }
|
||||
// break;
|
||||
// case DoWhat.WritePLC_Bytes_Ip://按区域读取(起始地址 + 长度)
|
||||
// {
|
||||
// //string tagStartAdr = "DB411.10";
|
||||
// result = PlcLinkForm.WritePLC_Bytes_Ip(opOrIp, tagStartAdr, new byte[1024]);
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
// //得到工位信号列表
|
||||
// foreach (System.Collections.Generic.KeyValuePair<string, object> de in tagAdrListTagFormat)
|
||||
// {
|
||||
// DoWhatPlc.TagFormat TF = (DoWhatPlc.TagFormat)de.Value;
|
||||
// string recResult = TF.OpName + " (" + TF.TagTypeCodeID + ")" + TF.TagValue.ToString(); ;
|
||||
// }
|
||||
|
||||
// }
|
||||
// catch (System.Exception err)
|
||||
// {
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,990 @@
|
||||
using OpcBasic;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
|
||||
using MesWork;
|
||||
using System.Collections.Concurrent;
|
||||
using DoWhatPlc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MesWorkWebApp
|
||||
{
|
||||
|
||||
|
||||
public partial class PLC1Controller : ApiController
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// http://localhost:41186/api/PLC/ReadAllTagValue?opname=OP1010
|
||||
/// </summary>
|
||||
/// <param name="tagID"></param>
|
||||
/// <returns>ReturnValue</returns>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadAllTagValue1(string opname)
|
||||
{
|
||||
var objValue = PlcLinkForm.ReadAllTagValue(opname);
|
||||
|
||||
var pp = JsonConvert.SerializeObject(objValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MES保存完数据(必须MIS)(X102.2)(20)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_MesReadOver(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_MesReadOver(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发动机到位(X0.1)(2)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_WorkStart(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_WorkStart(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发动机机型标志(INT4)(9)
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_EngineTypeID(string opName)
|
||||
{
|
||||
|
||||
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_EngineTypeID(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 发动机ID(STRING6.38)(10)
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_EngineID(string opName)
|
||||
{
|
||||
string tagValue;
|
||||
PlcLinkForm.Read_EngineID(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 发动机型号(STRING46.38)(11)
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_EngineType(string opName)
|
||||
{
|
||||
string tagValue;
|
||||
PlcLinkForm.Read_EngineType(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工位直通(X101.6)(1006)
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PartGoOver(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_PartGoOver(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 托盘到位(1)托盘离开(0) (DBX101.5)(13)
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PartPalletStatus(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_PartPalletStatus(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加工时间变量目标时间 (DINT 106)(17)
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_MachineTime_TargetTime(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_MachineTime_TargetTime(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 加工时间变量实际时间 (DINT 110)(18)
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_MachineTime_ActualTime(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_MachineTime_TargetTime(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 质量数据总成合格标志(INT104)(21)
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_QualityMask(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_QualityMask(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 机体流向标志(1 BYTE):
|
||||
/// 0普通工位:
|
||||
/// 1:上线(发动机上线);
|
||||
/// 2:下线(发动机下线);(INT114)(41)
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PartMoveDirection(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_PartMoveDirection(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 强制MES(X103.0)(78)
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_Mes_MustTest(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_Mes_MustTest(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 工位三种状态:在线、离线、屏蔽(0,1,2)(DBB116)(79)
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_OnLineState(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_OnLineState(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 变量类型代码=44 CF0.4
|
||||
/// PLC向MES传递机型,机型代码,零件编号完成,通知PLC。
|
||||
/// 机型可读
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_EngineGetOver_PLC(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_EngineGetOver_PLC(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// X100.2允许保存质量数据(19)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_QualityData_Read_CF(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_QualityData_Read_CF(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MES向PLC传递机型(DBX2.1)(5)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_EngineTypeGetOver_MES(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_EngineTypeGetOver_MES(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// X2.3 工作完成
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_MaterialVerifyOver(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_MaterialVerifyOver(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 申请上线(DBX0.3)(43)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PartLoad(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_PartLoad(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上线完成(DBX0.3)(48)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PartLoad_OK(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_PartLoad_OK(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合格放行(51)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_ConfirmOkGo(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_ConfirmOkGo(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧结束(DBX1.1)(59)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_FixOK(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_FixOK(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 蘑菇按钮(DBX1.3)(61)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_NextPushButton(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_NextPushButton(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 允许拧紧(DBX3.1)(66)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_FixAllow(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_FixAllow(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧结束确认(DBX3.2)(67)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_FixOver(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_FixOver(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///返修上线,在上线工位,MES依据工件情况,设定为返修件,PLC见到MES设定为1后,将返修标志写入到DBX0.2为1
|
||||
///MES设定完返修返修上线后,MES清空该信号
|
||||
///DBX3.7(72)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_RepairUpline_MES(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_RepairUpline_MES(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 匹配结果(DBX3.4)(69)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_Match(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_Match(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发动机机型代码(DBB404)(73)[false]
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="EngineTypeID"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_EngineTypeID_MES(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_EngineTypeID_MES(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发动机机型(DBB446)(75)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="EngineType"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_EngineType_MES(string opName)
|
||||
{
|
||||
string tagValue;
|
||||
PlcLinkForm.Read_EngineType_MES(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发动机号(DBB406)(74)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="EngineID"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_EngineID_MES(string opName)
|
||||
{
|
||||
string tagValue;
|
||||
PlcLinkForm.Read_EngineID_MES(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧序号(拧紧或者称重的顺序)(DBB88)(77)[false]
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_OrderBy(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_OrderBy(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工步属性(工作性质)(DBB90)(88)[false]
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_ProcessCode(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_ProcessCode(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 套筒号、子程序代码子程序(DBB26)(2025)[false]
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_BoltCode(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_BoltCode(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 托盘代码(DBB86)(80)
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PalletCode(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_PalletCode(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获得机型,零件编号,机型代码,托盘号,(从PLC)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="EngineTypeID"></param>
|
||||
/// <param name="EngineType"></param>
|
||||
/// <param name="EngineID"></param>
|
||||
/// <param name="PartPallet_Code"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage GetEngineTypeFromPLC(string opName)
|
||||
{
|
||||
int EngineTypeID;
|
||||
string EngineType;
|
||||
string EngineID;
|
||||
int PartPallet_Code;
|
||||
PlcLinkForm.GetEngineTypeFromPLC(opName, out EngineTypeID, out EngineType, out EngineID, out PartPallet_Code);
|
||||
|
||||
EngineValue ev = new EngineValue();
|
||||
ev.OpName = opName;
|
||||
ev.EngineID = EngineID;
|
||||
ev.EngineTypeID = EngineTypeID;
|
||||
ev.EngineType = EngineType;
|
||||
ev.PalletCode = PartPallet_Code;
|
||||
//PlcLinkForm.Read_EngineTypeID(opName, out EngineTypeID);
|
||||
//PlcLinkForm.Read_EngineType(opName, out EngineType);
|
||||
//PlcLinkForm.Read_EngineID(opName, out EngineID);
|
||||
//PlcLinkForm.Read_PalletCode(opName, out PartPallet_Code);
|
||||
|
||||
//JObject jObj = new JObject();
|
||||
//jObj["EngineTypeID"] = EngineTypeID;
|
||||
//jObj["EngineType"] = EngineType;
|
||||
//jObj["EngineID"] = EngineID;
|
||||
//jObj["PartPallet_Code"] = PartPallet_Code;
|
||||
|
||||
var pp = JsonConvert.SerializeObject(ev);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得机型,零件编号,机型代码,托盘号,(从DB)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="EngineTypeID"></param>
|
||||
/// <param name="EngineType"></param>
|
||||
/// <param name="EngineID"></param>
|
||||
/// <param name="PartPallet_Code"></param>
|
||||
//public static void GetEngineTypeFromDB(string opName, out int EngineTypeID, out string EngineType, out string EngineID, out int PartPallet_Code)
|
||||
//{
|
||||
// string orderForm = "";
|
||||
// int isRepair = 0;
|
||||
// string repairCode = "";
|
||||
// string palletCode = "0";
|
||||
// BaseDataSystemMES.OpName_MIS_Moby_Select(opName,
|
||||
// out orderForm, out EngineTypeID, out EngineType,
|
||||
// out EngineID, out palletCode, out isRepair, out repairCode);
|
||||
// PartPallet_Code = Convert.ToInt32(palletCode);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 0:不修改;1:可以修改。(上线工位)通知PLC。(DBX1.2)(76)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PartPalletCode_PLC_ToMES(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_PartPalletCode_PLC_ToMES(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通知写入托盘号(DBX3.5)(70)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PartPalletCode_PLC(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_PartPalletCode_PLC(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 变量类型代码=86,打印第一行(机型),用于线首打印机。STRING 486 .38
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PrintBarCode1_MES(string opName)
|
||||
{
|
||||
string tagValue;
|
||||
PlcLinkForm.Read_PrintBarCode1_MES(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 变量类型代码=87,打印第二行(流水号),用于线首打印机。STRING 526 .38
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PrintBarCode2_MES(string opName)
|
||||
{
|
||||
string tagValue;
|
||||
PlcLinkForm.Read_PrintBarCode2_MES(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 上线工位。0:正常工作;1:空托盘放行(DBX2.2)(6)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PartPalletGoOver(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_PartPalletGoOver(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动手动申请工件编号,0是自动方式;1:手动方式。切换时,(DBX2.1)(71)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_IsAutoGetEngineID(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_IsAutoGetEngineID(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 正常拧紧时选择(DBX100.3)(81)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_Normal(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_Normal(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 备用拧紧时选择(DBX100.4)(82)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_UnNormal(string opName)
|
||||
{
|
||||
|
||||
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_UnNormal(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 允许拧紧2(DBX100.5)(83)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_FixAllow_2(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_FixAllow_2(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧结束2(DBX100.6)(84)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_FixOK_2(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_FixOK_2(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧结束确认2(DBX100.7)(85)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_FixOver_2(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_FixOver_2(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧顺序2(DBX101.7)(1007)
|
||||
/// MES通知PLC开始拧紧顺序(0为其他位,1为第一位置)(必须MES)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_WriteShaft_2(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_WriteShaft_2(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 返修上线(DBX2.6)(52)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PartLoadFinish(string opName)
|
||||
{
|
||||
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_PartLoadFinish(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返修上线后,PLC确认(DBX1.0)(58)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PartLoadOver(string opName)
|
||||
{
|
||||
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_PartLoadOver(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 变量类型代码=22,读取托盘信息 DBW126
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PalletInfo(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_PalletInfo(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 变量类型代码=23,读取托盘信息 DBW194
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_RepairStatus_PLC(string opName)
|
||||
{
|
||||
int tagValue;
|
||||
PlcLinkForm.Read_RepairStatus_PLC(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PLC将MOBY信息成功写入到了对应的DB,然后通知MES(DBX1.5)(63)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PalletMobyReadOver(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_PalletMobyReadOver(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 在线返修状态(DBX4.0)(91)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_OnlineRepair(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_OnlineRepair(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离线返修状态(DBX4.1)(92)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_OutLineRepair(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_OutLineRepair(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MES通知PLC修改托盘状态成功(DBX4.2)(93)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_UpdatePalletOK(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_UpdatePalletOK(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// MES向PLC要求申请下线(DBX0.7)(50)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_PalletDown(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_PalletDown(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 物料检测(99)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
//public static void Read_CheckMaterial(string opName, out object tagValue)
|
||||
//{
|
||||
|
||||
|
||||
// bool tagValue;
|
||||
// PlcLinkForm.Read_CheckMaterial(opName, out tagValue);
|
||||
// var pp = JsonConvert.SerializeObject(tagValue);
|
||||
// HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
// return result;
|
||||
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 备用功能是否启用(95)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_BakOpNameIsWork(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_BakOpNameIsWork(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 质量呼叫(DBX301.2)(2011)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_QualityCall(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_QualityCall(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物料呼叫(DBX301.3)(2012)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_MaterialCall(string opName)
|
||||
{
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_MaterialCall(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 故障呼叫(DBX301.4)(2013)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Read_FaultCall(string opName)
|
||||
{
|
||||
|
||||
bool tagValue;
|
||||
PlcLinkForm.Read_FaultCall(opName, out tagValue);
|
||||
var pp = JsonConvert.SerializeObject(tagValue);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using OpcBasic;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
|
||||
using MesWork;
|
||||
using System.Collections.Concurrent;
|
||||
using DoWhatPlc;
|
||||
using System.Collections;
|
||||
using MisDataFunction;
|
||||
|
||||
namespace MesWorkWebApp
|
||||
{
|
||||
|
||||
|
||||
public partial class PLC1Controller : ApiController
|
||||
{
|
||||
//http://localhost:41186/api/PLC1/ReadPLC_Sync_DataList_MesRead/?opName=OP030
|
||||
//ReadPLC_Sync_DataList_MesRead
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ReadPLC_Sync_DataList_MesRead(string opName)
|
||||
{
|
||||
// public class QualityDataSaveList
|
||||
//{
|
||||
// Hashtable valuList;
|
||||
// DataTable BasicDataTagValue;
|
||||
// DataTable BasicDataTagValueUpDown;
|
||||
// Hashtable hashtable_EngineTypeID;
|
||||
//}
|
||||
QualityDataSaveList qualityDataSaveList = new QualityDataSaveList();
|
||||
qualityDataSaveList.BasicDataTagValue = MesServerWork.MIS_BASE.BasicDataTagValue;
|
||||
qualityDataSaveList.BasicDataTagValueUpDown = MesServerWork.MIS_BASE.BasicDataTagValueUpDown;
|
||||
qualityDataSaveList.hashtable_EngineTypeID = MesServerWork.MIS_BASE.hashtable_EngineTypeID;
|
||||
qualityDataSaveList.hashtable_tagTable_OpName_SaveData = MesServerWork.MIS_BASE.hashtable_tagTable_OpName_SaveData;
|
||||
//List<TagIDQualityDataType> TagIDQualityDataTypeList = new List<TagIDQualityDataType>();
|
||||
var valuList = (Hashtable)MesDataFunction.OpcOperation.ReadPLC_Sync_DataList_MesRead(opName);
|
||||
qualityDataSaveList.valuList = valuList;
|
||||
|
||||
|
||||
//string tagID;
|
||||
//QualityDataType value;
|
||||
//foreach (DictionaryEntry de in valuList) //ht为一个Hashtable实例
|
||||
//{
|
||||
// tagID = de.Key.ToString();
|
||||
// value = JsonConvert.DeserializeObject<QualityDataType>(JsonConvert.SerializeObject(de.Value));
|
||||
// TagIDQualityDataType td = new TagIDQualityDataType(tagID, value);
|
||||
// TagIDQualityDataTypeList.Add(td);
|
||||
//}
|
||||
var pp = JsonConvert.SerializeObject(qualityDataSaveList);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
[HttpGet]
|
||||
public HttpResponseMessage SaveQualityData_ByOnlyDataGroup(string opName,string tagID)
|
||||
{
|
||||
|
||||
bool rt= Function.SaveQualityData_ByOnlyDataGroup(opName, tagID);
|
||||
|
||||
var pp = JsonConvert.SerializeObject(rt);
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
using OpcBasic;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
|
||||
using MesWork;
|
||||
using System.Collections.Concurrent;
|
||||
using DoWhatPlc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace MesWorkWebApp
|
||||
{
|
||||
|
||||
|
||||
public partial class PLC1Controller : ApiController
|
||||
{
|
||||
/// <summary>
|
||||
/// MES保存完数据(必须MIS)(X102.2)(20)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_MesReadOver(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_MesReadOver(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加工时间保存完数据 DBX102.1 (54)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_MachineTime_ReadOver(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_MachineTime_ReadOver(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工位三种状态:在线、离线、屏蔽(0,1,2)(DBB116)(79)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_OnLineState(string opName, int tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_OnLineState(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 托盘编号(PLC)(80)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public static void Write_PalletCode(string opName, int tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_PalletCode(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MES向PLC传递机型(5)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_EngineTypeGetOver_MES(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_EngineTypeGetOver_MES(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工作完成(7)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_MaterialVerifyOver(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_MaterialVerifyOver(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合格方式放行(51)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_ConfirmOkGo(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_ConfirmOkGo(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 允许拧紧(66)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_FixAllow(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_FixAllow(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧结束(67)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_FixOver(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_FixOver(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///返修上线,在上线工位,MES依据工件情况,设定为返修件,PLC见到MES设定为1后,将返修标志写入到DBX0.2为1
|
||||
///MES设定完返修返修上线后,MES清空该信号
|
||||
///DBX3.7(72)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_RepairUpline_MES(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_RepairUpline_MES(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 匹配完成(68)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_MatchingCompleted(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_MatchingCompleted(opName, tagValue);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 不合格放行(8)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_FalseGO(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_FalseGO(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 匹配结果(69)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_Match(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_Match(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 变量类型代码=73,机型代码。DBB404~405 机型标志
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_EngineTypeID_MES(string opName, int tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_EngineTypeID_MES(opName, tagValue);
|
||||
}
|
||||
/// <summary>
|
||||
/// 变量类型代码=74,零件编号。DBB406~445 发动机编号
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_EngineID_MES(string opName, string tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_EngineID_MES(opName, tagValue);
|
||||
}
|
||||
/// <summary>
|
||||
/// 变量类型代码=75,零件机型。DBB446~485 发动机机型
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_EngineType_MES(string opName, string tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_EngineType_MES(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拧紧序号(77)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_ProcessCode(string opName, int tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_ProcessCode(opName, tagValue);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 套筒号(88)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_BoltCode(string opName, int tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_BoltCode(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 空托盘放行(DBX2.2)(6)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_PartPalletGoOver(string opName, int tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_PartPalletGoOver(opName, tagValue);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 自动手动申请工件编号,0是自动方式;1:手动方式。切换时,(DBX2.1)(71)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_IsAutoGetEngineID(string opName, int tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_IsAutoGetEngineID(opName, tagValue);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 正常拧紧时选择(DBX100.3)(81)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_Normal(string opName, int tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_Normal(opName, tagValue);
|
||||
}
|
||||
/// <summary>
|
||||
/// 备用拧紧时选择(DBX100.4)(82)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_UnNormal(string opName, int tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_UnNormal(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 变量类型代码=52,复位设备(MES)DBX0.6
|
||||
/// 通知PLC复位设备
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_ResetDevice(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_ResetDevice(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///托盘状态(22)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_PalletInfo(string opName, int tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_PalletInfo(opName, tagValue);
|
||||
}
|
||||
/// <summary>
|
||||
/// 返修标志(93)
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_RepairStatusMES(string opName, int tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_RepairStatusMES(opName, tagValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MES通知PLC修改托盘状态成功
|
||||
/// </summary>
|
||||
/// <param name="opName"></param>
|
||||
/// <param name="tagValue"></param>
|
||||
[HttpGet]
|
||||
public void Write_UpdatePalletOK(string opName, bool tagValue)
|
||||
{
|
||||
PlcLinkForm.Write_UpdatePalletOK(opName, tagValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
//using DTTest;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using DataLinkMesWork;
|
||||
//using static DTTest.SqlOperation;
|
||||
using System.Collections.Specialized;
|
||||
using System.Data.SqlClient;
|
||||
using System.Configuration;
|
||||
|
||||
namespace WinformApiApp.Controller
|
||||
{
|
||||
|
||||
[RoutePrefix("api/SQLCommon")]
|
||||
public class SQLCommonController : ApiController
|
||||
{
|
||||
public static string PP_ConnectionStr = ConfigurationManager.AppSettings["ConnectionString_MES"];
|
||||
/// <summary>
|
||||
/// http://localhost:41181/api/SQLCommon/ExecuteNonQuery?sql=sqlStr
|
||||
/// http://localhost:41181/api/SQLCommon/ExecuteDataset?sql=sqlStr
|
||||
/// http://localhost:41181/api/SQLCommon/ExecuteNonQuery?sql=sqlStr
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public string ExecuteNonQuery1(string sql)
|
||||
{
|
||||
StringCollection sql1 = JsonConvert.DeserializeObject<StringCollection>(sql);
|
||||
|
||||
string errorMessage;
|
||||
return SQLCommon.ExecuteNonQuery(sql1, PP_ConnectionStr, out errorMessage).ToString();
|
||||
}
|
||||
[HttpGet]
|
||||
public string ExecuteNonQuery(string sql)
|
||||
{
|
||||
string errorMessage;
|
||||
return SQLCommon.ExecuteNonQuery(sql, PP_ConnectionStr, out errorMessage).ToString();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string ExecuteOutNum(string sql)
|
||||
{
|
||||
int count;
|
||||
string errorMessage;
|
||||
SQLCommon.ExecuteOutNum( sql, PP_ConnectionStr, out count, out errorMessage);
|
||||
return count.ToString();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ExecuteDataset(string sql)
|
||||
{
|
||||
DataSet ds;
|
||||
string errorMessage;
|
||||
SQLCommon.ExecuteDataset(sql, PP_ConnectionStr, out ds, out errorMessage);
|
||||
var pp = JsonConvert.SerializeObject(ds);
|
||||
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ExecuteDataTable(string sql)
|
||||
{
|
||||
DataTable dt;
|
||||
string errorMessage;
|
||||
SQLCommon.ExecuteDataTable(sql, PP_ConnectionStr, out dt, out errorMessage);
|
||||
var pp = JsonConvert.SerializeObject(dt);
|
||||
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ExecuteDataReader(string sql)
|
||||
{
|
||||
SqlDataReader dr;
|
||||
string errorMessage;
|
||||
SQLCommon.ExecuteDataReader(sql, PP_ConnectionStr, out dr, out errorMessage);
|
||||
var pp = JsonConvert.SerializeObject(dr);
|
||||
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行SQL语句,增、删、改,无返回
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="connectionString"></param>
|
||||
/// <param name="errorMessage"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public string ExecuteSql(string sql)
|
||||
{
|
||||
string errorMessage;
|
||||
return SQLCommon.ExecuteSql( sql, PP_ConnectionStr, out errorMessage).ToString();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 执行SQL语句,查询,返回表
|
||||
/// </summary>
|
||||
/// <param name="sql"></param>
|
||||
/// <param name="connectionString"></param>
|
||||
/// <param name="dt"></param>
|
||||
/// <param name="errorMessage"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public HttpResponseMessage ExecuteSqlDataTable(string sql)
|
||||
{
|
||||
DataTable dt;
|
||||
string errorMessage;
|
||||
SQLCommon.ExecuteSql(sql, PP_ConnectionStr, out dt, out errorMessage);
|
||||
var pp = JsonConvert.SerializeObject(dt);
|
||||
|
||||
HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(pp, Encoding.GetEncoding("UTF-8"), "application/json") };
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.Cors;
|
||||
using System.Web.Http.SelfHost;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
public class WebApi
|
||||
{
|
||||
HttpSelfHostConfiguration config = null;
|
||||
HttpSelfHostServer server = null;
|
||||
public void InitWebApi()
|
||||
{
|
||||
string Url_WebApi = System.Configuration.ConfigurationManager.AppSettings["Url_WebApi"];
|
||||
|
||||
InitWebApi(Url_WebApi);
|
||||
|
||||
|
||||
|
||||
//config = new HttpSelfHostConfiguration(Url_WebApi);
|
||||
|
||||
|
||||
//var json = config.Formatters.JsonFormatter;
|
||||
//// 解决json序列化时的循环引用问题
|
||||
//json.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
|
||||
//// 移除XML序列化器
|
||||
//config.Formatters.Remove(config.Formatters.XmlFormatter);
|
||||
//// 设置序列化方式为驼峰命名法
|
||||
//var jsonFormatter = config.Formatters.OfType<System.Net.Http.Formatting.JsonMediaTypeFormatter>().First();
|
||||
//jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
|
||||
|
||||
|
||||
//config.Routes.MapHttpRoute("API Default", "api/{controller}/{action}/{id}", new { id = RouteParameter.Optional });
|
||||
|
||||
//server = new HttpSelfHostServer(config);
|
||||
|
||||
//server.OpenAsync().Wait();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void InitWebApi(string url)
|
||||
{
|
||||
config = new HttpSelfHostConfiguration(url);
|
||||
|
||||
// 跨域设置
|
||||
config.EnableCors();
|
||||
config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
|
||||
|
||||
var json = config.Formatters.JsonFormatter;
|
||||
// 解决json序列化时的循环引用问题
|
||||
json.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
|
||||
// 移除XML序列化器
|
||||
config.Formatters.Remove(config.Formatters.XmlFormatter);
|
||||
// 设置序列化方式为驼峰命名法
|
||||
var jsonFormatter = config.Formatters.OfType<System.Net.Http.Formatting.JsonMediaTypeFormatter>().First();
|
||||
jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
|
||||
// Web API 路由
|
||||
config.MapHttpAttributeRoutes();
|
||||
config.Routes.MapHttpRoute("API Default", "api/{controller}/{action}/{id}", new { id = RouteParameter.Optional });
|
||||
|
||||
server = new HttpSelfHostServer(config);
|
||||
server.OpenAsync().Wait();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>
|
||||
@@ -0,0 +1,5 @@
|
||||
SCC = This is a Source Code Control file
|
||||
|
||||
[MesDataFunction.csproj]
|
||||
SCC_Aux_Path = "\\192.168.0.100\vss\MES4.0"
|
||||
SCC_Project_Name = "$/MisData/MisData/MisData/MesDataFunction", YJHAAAAA
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
|
||||
</packages>
|
||||
Binary file not shown.
Reference in New Issue
Block a user