金南瓜SECS Driver是最适合应用于模板行业,已经被京东方、华星光电、天马等大厂大量应用
年初出机量数千套,价格非常的优惠实在
更多中文资料 www.secsgem.cn
发送S1F1消息
private void button1_Click(object sender, EventArgs e)
{
int nTransaction = 0;
// 数据对象
JngDataEx pData = new JngDataEx();
string x = "122323这是中文";
pData.AddAscii(x);
// 发送数据
m_pSecs.SendAsyncData(1, 1, true, ref nTransaction, pData);
// 记录LOG
ShowMsg("\r\n异步消息ID:" + nTransaction.ToString() + "发送完成");
ShowSML(1, 1, pData, true);
}
发送S1F13
private void button2_Click(object sender, EventArgs e)
{
int nTransaction = 0;
// 数据内容
JngDataEx pData = new JngDataEx();
pData.AddList(0);
ShowSML(1, 13, pData, true);
// 发送数据
m_pSecs.SendAsyncData(1, 13, true, ref nTransaction, pData);
}

简单易懂的数据操作对象
// SECS 数据类
public class JngDataEx
{
IntPtr m_pJsData;
int m_nPos;
bool m_bDataEnd;
public JngDataEx()
{
m_nPos = 0;
m_pJsData = JngHightSpeedSecsExport.JS_CreateDataObject();
}
~JngDataEx()
{
JngHightSpeedSecsExport.JS_DelereDataObject(m_pJsData);
}
// 添加单个指定数据
public void AddList(int nSize)
{
JngHightSpeedSecsExport.JS_DataItemAddList(m_pJsData, nSize);
}
// ASCII字符串
public void AddAscii(string pData)
{
IntPtr pAddr = Marshal.AllocHGlobal(pData.Length);
try
{
byte[] pASCII = Encoding.ASCII.GetBytes(pData);
Marshal.Copy(pASCII, 0, pAddr, pASCII.Length);
JngHightSpeedSecsExport.JS_DataItemAdd(m_pJsData, (Int32)pData.Length, SECS_TYPE._ASCII, pAddr);
}
catch
{
}
Marshal.FreeHGlobal(pAddr);
}
// ASCII字符串
public void AddAscii(char[] pData)
{
IntPtr pAddr = Marshal.AllocHGlobal(pData.Length);
try
{
byte[] pASCII = Encoding.ASCII.GetBytes(pData);
Marshal.Copy(pASCII, 0, pAddr, pASCII.Length);
JngHightSpeedSecsExport.JS_DataItemAdd(m_pJsData, (Int32)pData.Length, SECS_TYPE._ASCII, pAddr);
}
catch
{
}
Marshal.FreeHGlobal(pAddr);
}
// ASCII字符串,支持中文
public void AddAscii(string pData)
{
try
{

161万+

被折叠的 条评论
为什么被折叠?



