Example #1
0
        /// <summary>
        /// Intercambia un comando con el controlador fiscal.
        /// </summary>
        ///
        /// <param name="cmd">El comando a enviar</param>
        /// <returns>La respuesta recibida</returns>
        public MOutput ExchangePacket(CMD_Generic cmd)
        {
            LastError = null;
            var cmdBin = ((MInput)cmd.InputObject).GetCommand();
            var mo     = (MOutput)cmd.OutputObject;

            if (!cancelling)
            {
                var rcvBin = ExchangePacketBin(cmdBin);
                if (rcvBin == null)
                {
                    cancelling = true;
                }

                if (!cancelling)
                {
                    mo.SetFromCommand(rcvBin);
                    if (mo.ErrorCodeInt != 0)
                    {
                        LastError = $"Error {mo.ErrorCodeInt.ToString("X").PadLeft(4, '0')}-'{mo.ErrorCode}'\nComando: {cmd}";
                        return(null);
                    }
                }
            }
            return(cancelling? null: mo);
        }
Example #2
0
        /// <summary>
        /// Devuelve el equivalente en hexadecimal de un comando.
        /// </summary>
        ///
        /// <param name="cmd"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static bool ToHexaCommand(this CMD_Generic cmd, out string msg)
        {
            var mi = (MInput)cmd.InputObject;

            return(mi.ToHexaCommand(out msg));
        }