private void btnConnAIS_Click(object sender, EventArgs e) { DeviceEntry entry = new DeviceEntry(); entry[DeviceEntry.Name] = new StringValue("AIS"); entry[DeviceEntry.Identity] = new StringValue("Scada.AIS"); entry[DeviceEntry.Path] = new StringValue(""); entry[DeviceEntry.Version] = new StringValue("0.9"); entry["IPADDR"] = new StringValue("192.168.0.6"); this.aisDevice = new AISDevice(entry); this.aisDevice.Start("S7200.OPCServer"); this.aisDevice.Send(Encoding.ASCII.GetBytes("connect"), default(DateTime)); }
private ReadLineResult ParseLine(string line, ref SectionType secType, out string key, out IValue value) { key = string.Empty; value = null; // Comment int commentStart = line.IndexOf("#"); if (commentStart == 0) { secType = SectionType.Comment; return ReadLineResult.OK; } // Title int leftBracketPos = line.IndexOf("["); if (leftBracketPos == 0) { int rightBracketPos = line.IndexOf("]"); if (rightBracketPos > 0) { string content = line.Substring(leftBracketPos + 1, rightBracketPos - leftBracketPos - 1); content = content.Trim(); if (IsValidKey(content)) { secType = SectionType.Title; key = content; return ReadLineResult.OK; } } return ReadLineResult.Error; } // Assignment int assignPos = line.IndexOf("="); if (assignPos > 0) { string assignBefore = line.Substring(0, assignPos).Trim(); if (IsValidKey(assignBefore)) { key = assignBefore; string assignAfter = line.Substring(assignPos + 1).Trim(); if (assignAfter.StartsWith("[") && assignAfter.EndsWith("]")) { this.ParseArray(assignAfter, out value); return ReadLineResult.Error; } else if (assignAfter.StartsWith("{") && assignAfter.EndsWith("}")) { return ReadLineResult.Error; } else { if (assignAfter.StartsWith("<<")) { string delimiter = assignAfter.Substring(2).Trim(); StringBuilder sb = new StringBuilder(); string oneLine = streamReader.ReadLine(); while (oneLine != null) { if (oneLine != delimiter) { sb.Append(oneLine).Append('\n'); oneLine = streamReader.ReadLine(); } else { break; } } value = new StringValue(sb.ToString()); secType = SectionType.KeyWithStringValue; return ReadLineResult.OK; } else { if (assignAfter.StartsWith("\"") && assignAfter.EndsWith("\"")) { assignAfter = assignAfter.Substring(1, assignAfter.Length - 2); } value = new StringValue(assignAfter); secType = SectionType.KeyWithStringValue; return ReadLineResult.OK; } } } return ReadLineResult.Error; } return ReadLineResult.Error; }