Ejemplo n.º 1
0
        public int GetOutput(string outputName)
        {
            this.ValidateEditor();
            if (string.IsNullOrEmpty(outputName))
            {
                throw new ArgumentNullException(nameof(outputName));
            }
            OutputPinSocket pin = this.socket.Outputs.FirstOrDefault(o => o.Pin.Name == outputName);

            if (pin == null)
            {
                throw new CircuitException(Cause.UserError,
                                           string.Format(CultureInfo.InvariantCulture, "Output pin {0} not found on Logical Circuit {1}", outputName, this.logicalCircuitName)
                                           );
            }
            int value;

            if (FunctionProbe.ToInt(pin.Function.Pack(), pin.Pin.BitWidth, out value))
            {
                return(value);
            }
            throw new CircuitException(Cause.UserError,
                                       string.Format(CultureInfo.InvariantCulture,
                                                     "Output value cannot be represented by number because it contains bit(s) in high impedance state: {0}. Use GetStateOutput instead.",
                                                     pin.Function.ToText()
                                                     )
                                       );
        }
Ejemplo n.º 2
0
        public long GetStateOutput(string outputName)
        {
            this.ValidateEditor();
            if (string.IsNullOrEmpty(outputName))
            {
                throw new ArgumentNullException(nameof(outputName));
            }
            OutputPinSocket pin = this.socket.Outputs.First(o => o.Pin.Name == outputName);

            if (pin == null)
            {
                throw new CircuitException(Cause.UserError,
                                           string.Format(CultureInfo.InvariantCulture, "Output pin {0} not found on Logical Circuit {1}", outputName, this.logicalCircuitName)
                                           );
            }
            return(pin.Function.Pack());
        }