/// <summary> /// 往指定的地址里写入bool数据对象 /// </summary> /// <param name="address">西门子的地址信息</param> /// <param name="value">值</param> /// <returns>是否成功的结果</returns> public OperateResult Write(string address, bool value) { OperateResult <S7AddressData> analysis = S7AddressData.ParseFrom(address); if (!analysis.IsSuccess) { return(analysis); } switch (analysis.Content.DataCode) { case 0x81: inputBuffer.SetBool(value, analysis.Content.AddressStart); return(OperateResult.CreateSuccessResult( )); case 0x82: outputBuffer.SetBool(value, analysis.Content.AddressStart); return(OperateResult.CreateSuccessResult( )); case 0x83: memeryBuffer.SetBool(value, analysis.Content.AddressStart); return(OperateResult.CreateSuccessResult( )); case 0x84: dbBlockBuffer.SetBool(value, analysis.Content.AddressStart); return(OperateResult.CreateSuccessResult( )); default: return(new OperateResult(StringResources.Language.NotSupportedDataType)); } }
/// <summary> /// 读取指定地址的bool数据对象 /// </summary> /// <param name="address">西门子的地址信息</param> /// <returns>带有成功标志的结果对象</returns> public OperateResult <bool> ReadBool(string address) { OperateResult <S7AddressData> analysis = S7AddressData.ParseFrom(address); if (!analysis.IsSuccess) { return(OperateResult.CreateFailedResult <bool>(analysis)); } switch (analysis.Content.DataCode) { case 0x81: return(OperateResult.CreateSuccessResult(inputBuffer.GetBool(analysis.Content.AddressStart))); case 0x82: return(OperateResult.CreateSuccessResult(outputBuffer.GetBool(analysis.Content.AddressStart))); case 0x83: return(OperateResult.CreateSuccessResult(memeryBuffer.GetBool(analysis.Content.AddressStart))); case 0x84: return(OperateResult.CreateSuccessResult(dbBlockBuffer.GetBool(analysis.Content.AddressStart))); default: return(new OperateResult <bool>(StringResources.Language.NotSupportedDataType)); } }