public override bool Write(string itemName, object state) { OPCItem item = GetItem(itemName); WriteToLog("ItemName:" + itemName + " Value: " + state.ToString()); return(item.Write(state)); }
public bool Write(string groupName, string itemID, object val) { bool re = false; try { OPCGroup myGroup = myServer.OPCGroups.GetOPCGroup(groupName); if (myGroup == null) { return(false); } OPCItem myItem = myGroup.OPCItems.Item(itemID); if (myItem == null) { return(false); } myItem.Write(val); re = true; } catch (System.Exception ex) { re = false; } return(re); }
private void SetToolOffsetArray(double dropOffset, double grabOffset) { ToolOffsetArray.Write(new object[] { dropOffset, grabOffset }); }
public static void write(int i, string value) { if (i > opc_group.OPCItems.Count) { MessageBox.Show("无法找到标签,写入失败"); return; } OPCItem OPC_item = opc_group.OPCItems.Item(i); OPC_item.Write(value); }
/// <summary> /// 写PLC中的值 /// </summary> /// <param name="itemName"></param> /// <param name="plc"></param> /// <returns></returns> public bool SetPlcValue(string itemName, PlcValue plc) { lock (o2) { OPCItem opcitem = dic[itemName]; if (opcitem != null) { opcitem.Write(plc.Value); return(true); } return(false); } }
public void WriteTagValue(string TagName, string TagValue) { foreach (TIRAPOPCTagItem tagItem in tags) { if (tagItem.TagName == TagName) { OPCItem item = kepItems.GetOPCItem(tagItem.ServerHandle); if (item != null) { item.Write(TagValue); } break; } } }
public bool Writte(string group, string item, object value) { Branch b = GetBranch(group); try { if (b.Leafs.Exists(x => x.Name == item)) { OPCItem i = (b.Leafs.Where(x => x.Name == item).First()).OPCItem; i.Write(value); return(true); } } catch (Exception e) { } return(false); }
/// <summary> /// 为item指定BOOL(1Bit)类型的值 /// </summary> /// <param name="block">ITEM名称</param> /// <param name="value">指定的值</param> public bool SetValue(string block, bool value) { // 获取要更新的item OPCItem bItem = null; try { bItem = _items.GetOPCItem(_itemServerHandles[block]); } catch (Exception ex) { log.Error("获取opcitem " + block + "出错: " + ex.Message); } // 检查item的连接品质 if (bItem.Quality != (int)OPCQualities.Good) { log.Warn("地址块 " + block + " 的连接品质为 " + ((OPCQualities)bItem.Quality).ToString() + " 更新可能无法写入"); OnBadBlockDetected(block, bItem.Quality); } // 3次尝试更新item int writeCount = 0; do { try { bItem.Write(value ? "1" : "0"); } catch (Exception ex) { log.Error("将值" + value + " 写入 " + block + " 时出错:" + ex.Message); return(false); } writeCount += 1; log.Debug("正在尝试第 " + writeCount + " 次写入opc " + block); } while ((bItem.Value.ToString() == "1") != value && writeCount < _writeCount); return(true); }
public void WriteValue(object aValue) { if (aValue == null) { throw new ArgumentNullException("aValue"); } if (!IsActive) { throw new OpcValueException( "Параметр OPC не активирован, но предпринята попытка его записи: " + Name); } try { opcItem.Write(aValue); } catch (Exception ex) { throw new OpcValueException(string.Format("Ошибка при записи " + "значения тега {0} : {1}", Name, ex.Message)); } }
public void WriteVariableValue(VarItem varItem, bool value) { try { if (this.OPCServerName.Contains("Simulation")) { int servHandle = varItem.servHandle; OPCItem opc_item_s = this.myOPCGroup.OPCItems.GetOPCItem(servHandle); opc_item_s.Write(value); } else { this.eXX_DO_Write(varItem.MXIO_ipAddr, 502, 300, Convert.ToByte(varItem.MXIO_channel), Convert.ToUInt32(value), varItem.MXIO_moduleType); } } catch (Exception ex) { this.myLog.LogAlert(AlertType.Error, this.id.ToString(), this.GetType().ToString(), "WriteVariableValue()", ex.Message, "system"); } }
// 手动写入OPC public void WriteItemInt(int iValue) { try { if (Cfg.Main.IsUseConfig) { // 配置为自动写入的话,仅写入ItemIDComplete,用于调试 KepItemArr[0].Write(iValue); // 延时0.5秒复位0 Thread.Sleep(500); KepItemArr[0].Write(0); } else { KepItem.Write(iValue); } } catch (Exception err) { Console.WriteLine("手动写入项出错:" + err.Message); Log.TraceError("手动写入项出错:" + err.Message); } }
/// <summary> /// Plc Item에 값을 쓴다.. /// </summary> /// <param name="strItem">ItemName</param> /// <param name="lngValue">Writing Value</param> public void Item_Write(string strItem, int intValue) { object ItemName = string.Empty; try { ItemName = strTopicName + strItem; OPCItem Item = OpcGrp.OPCItems.Item(ItemName); object objValue = intValue; Item.Write(objValue); string strChanged = string.Format("[{0}] WorteValue : {1}", strItem, intValue); WroteAddressValue(strChanged, null, null); } catch (System.Runtime.InteropServices.ExternalException ex) { //activex이기 때문에 에러 발생이 제대로 되지 않아 몇가지만... throw ComException(ex, ItemName.ToString()); } catch (Exception ex) { throw ex; } }
/// <summary> /// 延迟10ms写,以免冲突,暂时不用 /// </summary> /// <param name="?"></param> void WriteLater(byte[] data) { System.Threading.Thread.Sleep(10); item_out.Write(data); }
public override bool Write(string itemName, object state) { OPCItem item = GetItem(itemName); return(item.Write(state)); }
public void StartDraw() { Draw.Write(true); }
private void RunClearAllProcedure() { ClearAll.Write(true); }
private void SetGrabEraser() { GrabEraser.Write(true); }
private void SetGrabMarker() { GrabMarker.Write(true); }
private void RunChangeToolProcedure() { ChangeTool.Write(true); }
public void itemWrite(OPCItem item, object value) { item.Write(value); }