Browse Source

需求单No.3208

qdwf_2864
Robin_PC\robin 2 days ago
parent
commit
4d93d99451
5 changed files with 78 additions and 1 deletions
  1. +1
    -0
      ButcherFactory.Form/ButcherFactory.Form.csproj
  2. +3
    -0
      ButcherFactory.Form/Controls/Utils/JST2018SDataFormat.cs
  3. +70
    -0
      ButcherFactory.Form/Controls/Utils/JST8180DataFormat.cs
  4. +3
    -0
      ButcherFactory.Form/Controls/WeightControl.cs
  5. +1
    -1
      ButcherFactory.Form/Controls/WeightSettingFrom.cs

+ 1
- 0
ButcherFactory.Form/ButcherFactory.Form.csproj View File

@ -117,6 +117,7 @@
<DependentUpon>UserControl1.cs</DependentUpon> <DependentUpon>UserControl1.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Controls\Utils\AoHaoSi3000DataFormat.cs" /> <Compile Include="Controls\Utils\AoHaoSi3000DataFormat.cs" />
<Compile Include="Controls\Utils\JST8180DataFormat.cs" />
<Compile Include="Controls\Utils\DataFormatBase.cs" /> <Compile Include="Controls\Utils\DataFormatBase.cs" />
<Compile Include="Controls\Utils\IND560DataFormat.cs" /> <Compile Include="Controls\Utils\IND560DataFormat.cs" />
<Compile Include="Controls\Utils\JST2018SDataFormat.cs" /> <Compile Include="Controls\Utils\JST2018SDataFormat.cs" />


+ 3
- 0
ButcherFactory.Form/Controls/Utils/JST2018SDataFormat.cs View File

@ -8,6 +8,9 @@ namespace ButcherFactory.Controls
{ {
internal class JST2018SDataFormat : DataFormatBase internal class JST2018SDataFormat : DataFormatBase
{ {
// 00007RX: FF 43 78 40 00 10 00 00 00 37
// 00009RX: FF 43 88 40 00 10 00 00 00 37
public override int DataLength public override int DataLength
{ {
get { return 8; } get { return 8; }


+ 70
- 0
ButcherFactory.Form/Controls/Utils/JST8180DataFormat.cs View File

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ButcherFactory.Controls
{
internal class JST8180DataFormat : DataFormatBase
{
public override int DataLength => 8;
public override char Beginchar => (char)0x3D; // = 开头
public override char Endchar => (char)0xFF;
public override short Bufsize => 7;
public override string ParseData(string buf, out bool isStatic)
{
// 3D 34 39 2E 36 30 30 30
// 6.94
isStatic = true;
try
{
// 1. 去掉 = 和 . 例:=49.6000 → 496000
string raw = buf.TrimStart('=').Replace(".", "");
// 2. 反转数字 496000 → 000694
char[] arr = raw.ToCharArray();
Array.Reverse(arr);
string reversed = new string(arr);
// 3. 插入小数点(固定2位小数)
decimal weight = decimal.Parse(reversed) / 100m;
// 4. 输出仪表显示值
return weight.ToString("0.00");
}
catch
{
return "0.00";
}
}
public override bool ParseAscii(string buf, out string weight, out bool isStatic)
{
weight = string.Empty;
isStatic = false;
string frame = FindDataFrame(buf, DataLength);
if (string.IsNullOrEmpty(frame)) return false;
weight = ParseData(frame, out isStatic);
return true;
}
public override string FindDataFrame(string buf, int fSize)
{
if (buf == null || buf.Length < fSize) return "";
int idx = buf.IndexOf(Beginchar);
if (idx < 0 || idx + fSize > buf.Length) return "";
return buf.Substring(idx, fSize);
}
public override bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr)
{
weight = ""; isStatic = false; subStr = ""; return false;
}
}
}

+ 3
- 0
ButcherFactory.Form/Controls/WeightControl.cs View File

@ -145,6 +145,9 @@ namespace ButcherFactory.Controls
case "JST2018S": case "JST2018S":
_dataFormat = new JST2018SDataFormat(); _dataFormat = new JST2018SDataFormat();
break; break;
case "JST8180":
_dataFormat = new JST8180DataFormat();
break;
case "一体称"://02 10 53 54 2C 47 53 3A 20 30 30 30 31 2E 37 31 6B 67 A8 FE 00 49 01 00 AC 99 A8 FE 00 case "一体称"://02 10 53 54 2C 47 53 3A 20 30 30 30 31 2E 37 31 6B 67 A8 FE 00 49 01 00 AC 99 A8 FE 00
_dataFormat = new CombineWeightDataFormat(); _dataFormat = new CombineWeightDataFormat();
break; break;


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

@ -12,7 +12,7 @@ namespace ButcherFactory.Controls
{ {
public partial class WeightSettingFrom : Form public partial class WeightSettingFrom : Form
{ {
List<string> weight = new List<string> { "IND560", "Xk3124", "Xk3190A9", "Xk3190D10", "IND231", "AHS3000", "JST2018S", "一体称" };
List<string> weight = new List<string> { "IND560", "Xk3124", "Xk3190A9", "Xk3190D10", "IND231", "AHS3000", "JST2018S", "一体称" , "JST8180" };
List<string> com = new List<string> { "COM1", "COM2", "COM3", "COM4", "COM5" }; List<string> com = new List<string> { "COM1", "COM2", "COM3", "COM4", "COM5" };
List<string> rate = new List<string> { "1200", "2400", "4800", "7200", "9600" }; List<string> rate = new List<string> { "1200", "2400", "4800", "7200", "9600" };
List<string> bit = new List<string> { "5", "6", "7", "8" }; List<string> bit = new List<string> { "5", "6", "7", "8" };


Loading…
Cancel
Save