init: 导入项目到 meswork Gitea
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user