using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ButcherFactory.Controls
{
  internal class CombineWeightDataFormat : DataFormatBase
  {

    public override int DataLength
    {
      get { return 17; }
    }

    public override char Beginchar
    {
      get { return (char)0x02; }
    }

    public override char Endchar
    {
      get { return (char)0x6B; }
    }

    public override short Bufsize
    {
      get { return 17; }
    }

    public override string ParseData(string buf, out bool isStatic)
    {
      isStatic = true; // 默认 为 稳定
      return buf.Substring(9, 7).Trim();
    }

    public override bool ParseAscii(string buf, out string weight, out bool isStatic)
    {
      isStatic = false;
      weight = FindDataFrame(buf, DataLength);

      if (string.IsNullOrEmpty(weight))
      {
        return false;
      }

      weight = ParseData(weight, out isStatic);

      return true;
    }

    public override bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr)
    {
      isStatic = false;
      weight = "0";
      subStr = "";
      return true;
    }
  }
}
