FROM https://skyhappyblog.wordpress.com/2021/07/20/c-secs/
範例
if (msg.F == 33)//
{
var item = msg.SecsItem;
if (item.Format == SecsFormat.ASCII) {
var kk = item.GetString();
}
else if (item.Format == SecsFormat.Binary)
{
// var kk = item.GetVue();
}
else if (item.Format == SecsFormat.List)
{
foreach (var data in item.Items) {
var list = data.GetValues();
}
//OK
}
}
FROM https://csharp.hotexamples.com/examples/Secs4Net/SecsMessage/-/php-secsmessage-class-examples.html
FROM https://www.nuomiphp.com/github/5f7042aaada65164e8441a7f.html
secs4net
Project Description
SECS-II/HSMS-SS/GEM implementation on .NET. This library provide easy way to communicate with SEMI standard compatible device.
1. Send message to device
try
{
//await secondary message
var s3f18 = await device.SendAsync(s3f17);
//access item value
byte b1 = (byte)s3f18.SecsItem.Items[0];
byte b2 = s3f18.SecsItem.Items[0].GetValue<byte>();
string str = s3f18.SecsItem.Items[0].GetString();
// LINQ query
var query =
from a in s3f18.SecsItem.Items[3].Items
select new {
num = a.GetValue<int>(),
};
}
catch(SecsException)
{
// exception when
// T3 timeout
// device reply SxF0
// device reply S9Fx
}
2. Handle primary message from device
secsGem.PrimaryMessageReceived += async (sender, messageWrapper) =>
{
try
{
//do something for primaryMsg
var primaryMsg = messageWrapper.Message;
// reply secondary msg to device
await messageWrapper.ReplyAsync( secondaryMsg );
}
catch (Exception ex)
{
}
};
3. SecsMessage/Item construction is also LINQ friendly
using static Secs4Net.Item;
var s16f15 =
new SecsMessage(16, 15, "CreateProcessJob"
L(
U4(0),
L(from pj in tx.ProcessJobs select
L(
A(pj.Id),
B(0x0D),
L(from carrier in pj.Carriers select
L(
A(carrier.Id),
L(from slotInfo in carrier.SlotMap select
U1(slotInfo.SlotNo)))),
L(
U1(1),
A(pj.RecipeId),
L()),
Boolean(true),
L()))));
留言
張貼留言