|
|
|
@ -25,7 +25,7 @@ namespace ButcherFactory.Controls |
|
|
|
|
|
|
|
public override short Bufsize |
|
|
|
{ |
|
|
|
get { return 36; } |
|
|
|
get { return 9; } |
|
|
|
} |
|
|
|
|
|
|
|
public override string ParseData(string buf, out bool isStatic) |
|
|
|
@ -45,7 +45,7 @@ namespace ButcherFactory.Controls |
|
|
|
// buffer[1] 符号位
|
|
|
|
if (buf[5] == 0x01) |
|
|
|
{ |
|
|
|
weight = (Convert.ToDecimal(weight) / 1000).ToString("#0.0"); |
|
|
|
weight = (Convert.ToDecimal(weight) / 1000).ToString("#0.0000"); |
|
|
|
} |
|
|
|
if ((buf[1] & 0x20) == 1) |
|
|
|
weight = "-" + weight; |
|
|
|
@ -72,6 +72,26 @@ namespace ButcherFactory.Controls |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
public override string FindDataFrame(string buf, int fSize) |
|
|
|
{ |
|
|
|
var bufSize = buf.Length; |
|
|
|
if (fSize > bufSize) |
|
|
|
{ |
|
|
|
return string.Empty; |
|
|
|
} |
|
|
|
|
|
|
|
int index = buf.IndexOf(Beginchar); // 查找开始字符的索引
|
|
|
|
|
|
|
|
if (index < 0 || (index + fSize) > bufSize) |
|
|
|
{ |
|
|
|
return string.Empty; |
|
|
|
} |
|
|
|
|
|
|
|
string data = buf.Substring(index, fSize); |
|
|
|
|
|
|
|
return data; |
|
|
|
} |
|
|
|
|
|
|
|
private static string InsertDot(string weight, int dotBits) |
|
|
|
{ |
|
|
|
var rst = weight.Insert(weight.Length - dotBits, ".").Trim('0'); |
|
|
|
|