Esempio n. 1
0
 private static void GetItem_Binary_ValueAsString(StringBuilder sb, SecsItemBinary item)
 {
     if (item.Value != null)
     {
         byte val;
         for (int i = 0; i < item.Value.Length; i++)
         {
             val = item.Value[i];
             if (i == 0)
             {
                 sb.Append(val.ToString("X2"));
             }
             else
             {
                 sb.Append(" " + val.ToString("X2"));
             }
         }
     }
 }
Esempio n. 2
0
        public static SecsItem Create(string name, FormatCode format)
        {
            SecsItem item = null;

            switch (format)
            {
            case FormatCode.ASCII:
                item = new SecsItemAscii(name);
                break;

            case FormatCode.Binary:
                item = new SecsItemBinary(name);
                break;

            case FormatCode.Boolean:
                item = new SecsItemBoolean(name);
                break;

            case FormatCode.MC:
                break;

            case FormatCode.F4:
                item = new SecsItemF4(name);
                break;

            case FormatCode.F8:
                item = new SecsItemF8(name);
                break;

            case FormatCode.I1:
                item = new SecsItemI1(name);
                break;

            case FormatCode.I2:
                item = new SecsItemI2(name);
                break;

            case FormatCode.I4:
                item = new SecsItemI4(name);
                break;

            case FormatCode.I8:
                item = new SecsItemI8(name);
                break;

            case FormatCode.JIS8:
                break;

            case FormatCode.LIST:
                item = new SecsItemList(name);
                break;

            case FormatCode.U1:
                item = new SecsItemU1(name);
                break;

            case FormatCode.U2:
                item = new SecsItemU2(name);
                break;

            case FormatCode.U4:
                item = new SecsItemU4(name);
                break;

            case FormatCode.U8:
                item = new SecsItemU8(name);
                break;

            default:
                throw new Exception("Not support item format code");
            }

            return(item);
        }