public OpcClient() { xmlSettings = new XMLSettings(); m_productionInfoDao = new ProductionInfoDao(); m_statusInfoDao = new StatusInfoDao(); m_uaClient = new UaClient(); db203Site_KeyValue = new Dictionary <string, string>(); xmlSettings.ReadXMLSettings(); db203Site_KeyValue.Add("Heartbeat", xmlSettings.Heartbeat); db203Site_KeyValue.Add("WorkpieceType", xmlSettings.WorkpieceType); db203Site_KeyValue.Add("PrimerColor", xmlSettings.PrimerColor); db203Site_KeyValue.Add("PrimerCraft", xmlSettings.PrimerCraft); db203Site_KeyValue.Add("PrimerFirm", xmlSettings.PrimerFirm); db203Site_KeyValue.Add("PigmentedCoatingColor", xmlSettings.PigmentedCoatingColor); db203Site_KeyValue.Add("PigmentedCoatingCraft", xmlSettings.PigmentedCoatingCraft); db203Site_KeyValue.Add("PigmentedCoatingFirm", xmlSettings.PigmentedCoatingFirm); db203Site_KeyValue.Add("VarnishColor", xmlSettings.VarnishColor); db203Site_KeyValue.Add("VarnishCraft", xmlSettings.VarnishCraft); db203Site_KeyValue.Add("VarnishFirm", xmlSettings.VarnishFirm); db203Site_KeyValue.Add("BatchNo", xmlSettings.BatchNo); db203Site_KeyValue.Add("Receive_1", xmlSettings.Receive_1); db203Site_KeyValue.Add("Receive_2", xmlSettings.Receive_2); db203Site_KeyValue.Add("Receive_3", xmlSettings.Receive_3); db203Site_KeyValue.Add("Receive_4", xmlSettings.Receive_4); db203Site_KeyValue.Add("Receive_5", xmlSettings.Receive_5); db203Site_KeyValue.Add("Receive_6", xmlSettings.Receive_6); db203Site_KeyValue.Add("Receive_7", xmlSettings.Receive_7); db203Site_KeyValue.Add("Receive_8", xmlSettings.Receive_8); db203Site_KeyValue.Add("Receive_9", xmlSettings.Receive_9); db203Site_KeyValue.Add("Receive_10", xmlSettings.Receive_10); db203Site_KeyValue.Add("TotalNum", xmlSettings.TotalNum); //m_uaClient = new OpcUaClient.UaClient(); }
/// <summary> /// 设置DB203站点接受是否完成 /// </summary> /// <param name="i"></param> /// <param name="data"></param> /// <returns></returns> public bool WriteDataToOpcServer(int i, byte data) { OpcUaClient.UaClient uaClient = new OpcUaClient.UaClient(); bool isContected = uaClient.ConnectOpcServerWithPwd(xmlSettings.URL, xmlSettings.UserName, xmlSettings.Password); bool retVal = false; string nodeId = ""; switch (i) { case 1: nodeId = xmlSettings.Receive_1; break; case 2: nodeId = xmlSettings.Receive_2; break; case 3: nodeId = xmlSettings.Receive_3; break; case 4: nodeId = xmlSettings.Receive_4; break; case 5: nodeId = xmlSettings.Receive_5; break; case 6: nodeId = xmlSettings.Receive_6; break; case 7: nodeId = xmlSettings.Receive_7; break; case 8: nodeId = xmlSettings.Receive_8; break; case 9: nodeId = xmlSettings.Receive_9; break; case 10: nodeId = xmlSettings.Receive_10; break; } if (isContected && !string.IsNullOrEmpty(nodeId)) { retVal = uaClient.WriteDataToOpcServer <byte>(nodeId, data); } return(retVal); }