Browse Source

新称型号

master
yibo 5 years ago
parent
commit
627825f0d6
3 changed files with 24 additions and 4 deletions
  1. +1
    -1
      ButcherFactory.Form/Controls/Utils/DataFormatBase.cs
  2. +22
    -2
      ButcherFactory.Form/Controls/Utils/JST2018SDataFormat.cs
  3. +1
    -1
      ButcherFactory.Form/Controls/WeightControl.cs

+ 1
- 1
ButcherFactory.Form/Controls/Utils/DataFormatBase.cs View File

@ -36,7 +36,7 @@ namespace ButcherFactory.Controls
public const short BUFSIZE = 36;
// 根据开始字符找出 一个完整的数据帧
public string FindDataFrame(string buf, int fSize)
public virtual string FindDataFrame(string buf, int fSize)
{
var bufSize = buf.Length;
if (fSize > bufSize)


+ 22
- 2
ButcherFactory.Form/Controls/Utils/JST2018SDataFormat.cs View File

@ -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');


+ 1
- 1
ButcherFactory.Form/Controls/WeightControl.cs View File

@ -193,7 +193,7 @@ namespace ButcherFactory.Controls
_dataStrBuilder.Clear();
_dataStrBuilder.Append(c);
}
else if (c == _dataFormat.Endchar || _dataStrBuilder.Length > _dataFormat.Bufsize)
else if (c == _dataFormat.Endchar || _dataStrBuilder.Length >= _dataFormat.Bufsize)
{
_dataStrBuilder.Append(c);
bool isStatic;


Loading…
Cancel
Save