Esempio n. 1
0
        private void SetConfigRequest(ConfigType type, object value)
        {
            var builder = new UsbPacket.Builder();

            builder.Cmd(Cmd.SETCONFIG)
            .PacketNumber(++packetNumber)
            .Type(PacketType.Request)
            .Put((byte)0x01)
            .Put((byte)type);

            switch (type)
            {
            case ConfigType.DateTime:
                builder.PutLong((long)value);
                break;

            case ConfigType.AutoPowerOffTime:
                builder.PutShort((short)value);
                break;

            case ConfigType.AutoPowerOn:
            case ConfigType.PenCapOff:
            case ConfigType.Beep:
            case ConfigType.SaveOfflineData:
            case ConfigType.DownSampling:
                builder.Put((byte)((bool)value ? 0x01 : 0x00));
                break;
            }

            byte[] result = builder.Build().ToArray();

            _serialPort?.Write(result, 0, result.Length);
        }