本文介绍了参考&在VB.NET C#中intouch读/写标签的工具包详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
to read/write tag of Intouch in VB.NET C#
do we required to install wonderwaretoolkits??
where will be getting this toolkit??
now where to write this code??
Do Visual Sudio there in wonderware setup or in toolkit??
How to call the code in Wonderware project???
toolkits function will be able to read/write the value??
Which refrences need to be added??
m having ASCII printer .
The printer code is in C#.
M using Wonderware 2014.
i got wwheap.dll, ptacc.dll, Incouch.vb & ptacc.vb
i copied both dll & .vb files in project Folder
Please reply ASAP..waiting for ur reply..
我尝试过:
im无法使用
What I have tried:
i m unable to use
string SB = null;
Intouch IntouchToolkit = default(Intouch);
IntouchToolkit = new Intouch(0, 0);
SB = IntouchToolkit.ReadString("SBuffer", 132);
Intouch上的错误
Error is on Intouch
推荐答案
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using System;
//using System.Text;
using System.Net;
using System.Net.Sockets;
using InTouchTagDictionaryLib;
using InTouchMultiTagDictionaryLib;
using INTOUCHPROXYPACKAGESERVERLib;
using INTOUCHTAGBROWSERLib;
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using aaGRAccessApp;
//using InTouchTagDictionaryLib;
using WWAPPINTLib;
using WWANIMATIONLib;
using WWAPPCNTXLib;
using WWPROVIDERREGLib;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
string SB = null;
Intouch IntouchToolkit = default(GRAccessApp);
IntouchToolkit = new GRAccessApp();
SB = IntouchToolkit.ReadString("SBuffer", 132);
sendToPrinter("10.1.10.40", "GEA AUTOMATION", 9100);
}
public static Boolean sendToPrinter(String server, String message, Int32 port)
{
string hexOutput = "";
try
{
string commandStart = "1b 4f 45 30 30 30";// 31 34"; // Start command
string commandEnd = "04"; // End command
string input = message;
string messageLength = input.Length.ToString();
input = messageLength + input;
string hexString = "";
char[] values = input.ToCharArray();
foreach (char letter in values)
{
// Get the integral value of the character.
int value = Convert.ToInt32(letter);
// Convert the decimal value to a hexadecimal value in string form.
hexOutput = String.Format("{0:X}", value);
hexString = hexString + hexOutput + " ";
Console.WriteLine("Hexadecimal value of {0} is {1}", letter, hexOutput);
}
input = commandStart + " " + hexString + commandEnd;
Console.WriteLine(input);
byte[] data = input.Split().Select(s => Convert.ToByte(s, 16)).ToArray();
TcpClient client = new TcpClient(server, port);
NetworkStream stream = client.GetStream();
stream.Write(data, 0, data.Length);
Console.WriteLine("Sent: {0}", message);
data = new Byte[256];
String responseData = String.Empty;
Int32 bytes = stream.Read(data, 0, data.Length);
responseData = System.Text.Encoding.UTF8.GetString(data, 0, bytes);
Console.WriteLine("Received: {0}", responseData);
// Close everything.
stream.Close();
client.Close();
}
catch (ArgumentNullException e)
{
Console.WriteLine("ArgumentNullException: {0}", e);
return false;
}
catch (SocketException e)
{
Console.WriteLine("SocketException: {0}", e);
return false;
}
return true;
}
}
}
这篇关于参考&在VB.NET C#中intouch读/写标签的工具包详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!