Exemplo n.º 1
0
        public bool EscribePLC(PLC.TipoDato Tipo, string Variable, string Valor)
        {
            if (Valor != null)
            {
                OperateResult operateResult = new OperateResult();
                try
                {
                    switch (Tipo)
                    {
                    case PLC.TipoDato.Entero:
                        operateResult = ((NetworkDeviceBase <MelsecQnA3EBinaryMessage, RegularByteTransform>) this.keyence_net).Write(Variable, int.Parse(Valor));
                        break;

                    case PLC.TipoDato.Texto:
                        operateResult = ((NetworkDeviceBase <MelsecQnA3EBinaryMessage, RegularByteTransform>) this.keyence_net).Write(Variable, Valor);
                        break;

                    case PLC.TipoDato.Flotante:
                        operateResult = ((NetworkDeviceBase <MelsecQnA3EBinaryMessage, RegularByteTransform>) this.keyence_net).Write(Variable, float.Parse(Valor, (IFormatProvider)CultureInfo.InvariantCulture));
                        break;
                    }
                    return(operateResult.IsSuccess);
                }
                catch (Exception ex)
                {
                    this.PrimaryLog("EscribePLC", string.Format("{0}", (object)ex.Message), EventLogEntryType.Error, true);
                    return(false);
                }
            }
            else
            {
                this.PrimaryLog("EscribePLC", "Error de null", EventLogEntryType.Error, true);
                return(false);
            }
        }
Exemplo n.º 2
0
        public string LeePLC(PLC.TipoDato dato, string Variable)
        {
            string str = "";

            switch (dato)
            {
            case PLC.TipoDato.Entero:
                str = PLC.ReadResultRender <int>(this.keyence_net.ReadInt32(Variable));
                break;

            case PLC.TipoDato.Texto:
                str = PLC.ReadResultRender <string>(this.keyence_net.ReadString(Variable, (ushort)2));
                break;

            case PLC.TipoDato.Flotante:
                str = PLC.ReadResultRender <float>(this.keyence_net.ReadFloat(Variable));
                break;
            }
            return(str);
        }