public bool EscribePLC(Pokayoke.TipoDato Tipo, string Variable, string Valor) { if (Valor != null) { OperateResult operateResult = new OperateResult(); try { switch (Tipo) { case Pokayoke.TipoDato.Entero: operateResult = ((NetworkDeviceBase <MelsecQnA3EBinaryMessage, RegularByteTransform>) this.keyence_net).Write(Variable, int.Parse(Valor)); break; case Pokayoke.TipoDato.Texto: operateResult = ((NetworkDeviceBase <MelsecQnA3EBinaryMessage, RegularByteTransform>) this.keyence_net).Write(Variable, Valor); break; case Pokayoke.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); } }
public string LeePLC(Pokayoke.TipoDato dato, string Variable) { string str = ""; switch (dato) { case Pokayoke.TipoDato.Entero: str = Pokayoke.ReadResultRender <int>(this.keyence_net.ReadInt32(Variable)); break; case Pokayoke.TipoDato.Texto: str = Pokayoke.ReadResultRender <string>(this.keyence_net.ReadString(Variable, (ushort)2)); break; case Pokayoke.TipoDato.Flotante: str = Pokayoke.ReadResultRender <float>(this.keyence_net.ReadFloat(Variable)); break; } return(str); }