public SCADAAnalogChangedNotificationResponse SCADAAnalogChangedNotification(SCADAAnalogChangedNotificationRequest request) { LogInfo("SCADAAnalogChangedNotification() Entered"); String message = String.Empty; SCADAAnalogChangedNotificationResponse response = new SCADAAnalogChangedNotificationResponse(); try { if (_UdpClient == null) { String path = @"C:\\DCSystems\Logs\"; ConfigurationList cl = new ConfigurationList(); cl.Add("Process Name", "MockNotServerService"); cl.Add("Log Output Directory", path); _Logger = new Logger(cl); LogInfo("()"); _UdpClient = new UdpClient(); _UdpClient.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7373)); } for (int i = 0; i < request.scadaAnalogs.Length; i++) { if (i == 0) { message += String.Format("{0},{1:0.000} {2} {3} GMT", request.scadaAnalogs[i].objectID, request.scadaAnalogs[i].value.Value, request.scadaAnalogs[i].value.units, request.scadaAnalogs[i].timeStamp); } else { message += String.Format(";{0},{1:0.000} {2} {3} GMT", request.scadaAnalogs[i].objectID, request.scadaAnalogs[i].value.Value, request.scadaAnalogs[i].value.units, request.scadaAnalogs[i].timeStamp); } } Byte[] sendBytes = Encoding.ASCII.GetBytes(message); _UdpClient.Send(sendBytes, sendBytes.Length); response.MultiSpeakMsgHeader = new MultiSpeakMsgHeader(); response.MultiSpeakMsgHeader.TimeStampSpecified = true; response.MultiSpeakMsgHeader.TimeStamp = DateTime.Now; response.SCADAAnalogChangedNotificationResult = null; return(response); } catch (Exception ex) { LogError(String.Format("SCADAAnalogChangedNotification() ex:{0}", ex)); response.SCADAAnalogChangedNotificationResult = new errorObject[1]; response.SCADAAnalogChangedNotificationResult[0] = new errorObject(); response.SCADAAnalogChangedNotificationResult[0].Value = ex.Message; return(response); } }
public PingURLResponse PingURL(PingURLRequest request) { LogInfo("PingURL() Entered"); PingURLResponse response = new PingURLResponse(); try { if (_UdpClient == null) { String path = @"C:\\DCSystems\Logs\"; ConfigurationList cl = new ConfigurationList(); cl.Add("Process Name", "MockNotServerService"); cl.Add("Log Output Directory", path); _Logger = new Logger(cl); LogInfo("()"); _UdpClient = new UdpClient(); _UdpClient.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7373)); } Byte[] sendBytes = Encoding.ASCII.GetBytes("PingURL,OK"); _UdpClient.Send(sendBytes, sendBytes.Length); response.MultiSpeakMsgHeader = new MultiSpeakMsgHeader(); response.MultiSpeakMsgHeader.MinorVersion = "4"; response.MultiSpeakMsgHeader.MinorVersion = "1"; response.MultiSpeakMsgHeader.Build = "8"; response.MultiSpeakMsgHeader.BuildString = BuildDescriptor.Release; response.MultiSpeakMsgHeader.AppName = "DCSystems"; response.MultiSpeakMsgHeader.TimeStamp = DateTime.Now; response.MultiSpeakMsgHeader.TimeStampSpecified = true; //errorObject[] eObject = new errorObject[1]; //eObject[0] = new errorObject(); //eObject[0].eventTime = DateTime.Now; //eObject[0].eventTimeSpecified = true; //response.PingURLResult = eObject; return(response); } catch (Exception ex) { LogError(String.Format("PingURL() ex:{0}", ex)); response.PingURLResult = new errorObject[1]; response.PingURLResult[0].objectID = "DCSystem"; response.PingURLResult[0].errorString = ex.Message; return(response); } }
public GetMethodsResponse GetMethods(GetMethodsRequest request) { LogInfo("GetMethods() Entered"); GetMethodsResponse response = null; try { if (_UdpClient == null) { String path = @"C:\\DCSystems\Logs\"; ConfigurationList cl = new ConfigurationList(); cl.Add("Process Name", "MockNotServerService"); cl.Add("Log Output Directory", path); _Logger = new Logger(cl); LogInfo("()"); _UdpClient = new UdpClient(); _UdpClient.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7373)); } Byte[] sendBytes = Encoding.ASCII.GetBytes("GetURL,OK"); _UdpClient.Send(sendBytes, sendBytes.Length); response = new GetMethodsResponse(); response.MultiSpeakMsgHeader = new MultiSpeakMsgHeader(); response.MultiSpeakMsgHeader.TimeStampSpecified = true; response.MultiSpeakMsgHeader.TimeStamp = DateTime.Now; response.GetMethodsResult = new string[4]; response.GetMethodsResult[0] = "GetMethods"; response.GetMethodsResult[1] = "PingURL"; response.GetMethodsResult[2] = "SCADAAnalogChangedNotification"; response.GetMethodsResult[3] = "SCADAStatusChangedNotification"; return(response); } catch (Exception ex) { LogError(String.Format("GetMethods() ex:{0}", ex)); response.GetMethodsResult = new string[1]; errorObject[] eObject = new errorObject[1]; eObject[0] = new errorObject(); eObject[0].Value = ex.Message; response.GetMethodsResult[0] = ex.Message; return(response); } }
static void init() { string asm; if (!_didInit) { _didInit = true; /* * _OutputDirectory = m_config.getValue("Log Output Directory", @"c:\Colt\\Logs\"); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(199): m_doubleBuffer = m_config.getValue("double Buffer", false); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(204): m_rollingSizeMessageCount = 10000 * m_config.getValue("Log File Bytes", 10); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(205): m_logCount = m_config.getValue("Log Archive Depth", 80); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(209): _ProcessName = m_config.getValue("Process Name", "Unknown Process"); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(210): m_logLevel = m_config.getValue("File Logging Enabled", 3); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(211): m_format = m_config.getValue("Log Format", "{ticks} {Timestamp:MM-dd-yyyy HH:mm:ss.ffff} ({Thread}) - [{LevelName}] {Message}"); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(213): m_matchSCLineFormat = m_config.getValue("Match SC Line Format", false); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(231): string tmp = m_config.getValue("Log To Trace", "false"); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(301): m_logLevel = m_config.getValue("File Logging Enabled", 3); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(317): m_logCount = m_config.getValue("Log Archive Depth", DEFAULT_LOG_DEPTH); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(318): int logFileBytes = m_config.getValue("Log File Bytes", 3); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(320): _ProcessName = m_config.getValue("Process Name", "Unknown Process"); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(327): _OutputDirectory = m_config.getValue("Log Output Directory", @"c:\Colt\Logs\"); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(331): m_format = m_config.getValue("Log Format", "{ticks} {Timestamp:MM-dd-yyyy HH:mm:ss.ffff} ({Thread}) - [{LevelName}] {Message}"); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(333): m_matchSCLineFormat = m_config.getValue("Match SC Line Format", false); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(680): _ProcessName = m_config.getValue("Process Name", "Unknown Process"); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(687): m_format = m_config.getValue("Log Format", "{ticks} {Timestamp:MM-dd-yyyy HH:mm:ss.ffff} ({Thread}) - [{LevelName}] {Message}"); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(689): m_matchSCLineFormat = m_config.getValue("Match SC Line Format", false); * C:\Users\RTCOUSENS\colt\NewProjects\Colt3\Colt3\Logger.cs(692): outfile.WriteLine(_ProcessName + ": Log initialized - Log Level: " + logLevelName() + ", Log File Bytes: " + m_config.getValue("Log F * */ _cfg = new ConfigurationList(); asm = Assembly.GetEntryAssembly().GetName().Name; #if DEBUG _cfg.Add("File Logging Enabled", "5"); #endif _cfg.Add("Log To Trace", "true"); _cfg.Add("Process Name", asm); _cfg.Add("Log Output Directory", Path.Combine( @"\\appdeploy\APPDEPLOY\Colt Software\Logs", asm)); _logger = new Logger(_cfg); } }
ImmutableStack <InternalObject> InsertPlaceholderTags(List <InternalObject> objects, CancellationToken cancellationToken) { // Calculate indentation levels in front of the tags: int[] indentationBeforeTags = new int[objects.Count]; int pos = 0; for (int i = 0; i < objects.Count; i++) { if (objects[i] is InternalTag) { indentationBeforeTags[i] = GetIndentationBefore(pos); } pos += objects[i].Length; } // Create initial configuration: ConfigurationList listA = ConfigurationList.Create(); ConfigurationList listB = ConfigurationList.Create(); listA.Add(new Configuration(new OpenTagStack(), ImmutableStack <InternalObject> .Empty, 0)); for (int i = 0; i < indentationBeforeTags.Length; i++) { cancellationToken.ThrowIfCancellationRequested(); ProcessObject(objects[i], indentationBeforeTags[i], listA, ref listB); Swap(ref listA, ref listB); } Configuration cheapestConfiguration = new Configuration(null, null, InfiniteCost); for (int i = 0; i < listA.count; i++) { Configuration c = listA.configurations[i]; if (c.Cost < cheapestConfiguration.Cost) { while (!c.OpenTags.IsEmpty) { c = new Configuration(c.OpenTags.Pop(), c.Document.Push(EndTagPlaceholder), c.Cost + MissingEndTagCost); } if (c.Cost < cheapestConfiguration.Cost) { cheapestConfiguration = c; } } } Log.WriteLine("Best configuration has cost {0}", cheapestConfiguration.Cost); return(cheapestConfiguration.Document); }
void ProcessObject(InternalObject obj, int indentationLevel, ConfigurationList oldConfigurations, ref ConfigurationList newConfigurations) { newConfigurations.Clear(); InternalTag tag = obj as InternalTag; for (int i = 0; i < oldConfigurations.count; i++) { Configuration c = oldConfigurations.configurations[i]; if (c.Cost == InfiniteCost) { continue; } if (tag != null && tag.IsStartTag) { // Push start tag newConfigurations.Add( c.OpenTags.Push(tag.Name, indentationLevel), c.Document.Push(obj), c.Cost ); } else if (tag != null && tag.IsEndTag) { // We can ignore this end tag newConfigurations.Add( c.OpenTags, c.Document.Push(StartTagPlaceholder).Push(obj), c.Cost + IgnoreEndTagCost ); // We can match this end tag with one of the currently open tags var openTags = c.OpenTags; var documentWithInsertedEndTags = c.Document; uint newCost = c.Cost; while (!openTags.IsEmpty) { uint matchCost = 0; if (openTags.IndentationLevel >= 0 && indentationLevel >= 0) { matchCost += (uint)Math.Abs(openTags.IndentationLevel - indentationLevel); } if (openTags.Name != tag.Name) { matchCost += MismatchedNameCost; } newConfigurations.Add( openTags.Pop(), documentWithInsertedEndTags.Push(obj), newCost + matchCost ); newCost += MissingEndTagCost; openTags = openTags.Pop(); documentWithInsertedEndTags = documentWithInsertedEndTags.Push(EndTagPlaceholder); } } else { newConfigurations.Add( c.OpenTags, c.Document.Push(obj), c.Cost ); } } }
void ProcessObject(InternalObject obj, int indentationLevel, ConfigurationList oldConfigurations, ref ConfigurationList newConfigurations) { newConfigurations.Clear(); InternalTag tag = obj as InternalTag; for (int i = 0; i < oldConfigurations.count; i++) { Configuration c = oldConfigurations.configurations[i]; if (c.Cost == InfiniteCost) continue; if (tag != null && tag.IsStartTag) { // Push start tag newConfigurations.Add( c.OpenTags.Push(tag.Name, indentationLevel), c.Document.Push(obj), c.Cost ); } else if (tag != null && tag.IsEndTag) { // We can ignore this end tag newConfigurations.Add( c.OpenTags, c.Document.Push(StartTagPlaceholder).Push(obj), c.Cost + IgnoreEndTagCost ); // We can match this end tag with one of the currently open tags var openTags = c.OpenTags; var documentWithInsertedEndTags = c.Document; uint newCost = c.Cost; while (!openTags.IsEmpty) { uint matchCost = 0; if (openTags.IndentationLevel >= 0 && indentationLevel >= 0) matchCost += (uint)Math.Abs(openTags.IndentationLevel - indentationLevel); if (openTags.Name != tag.Name) matchCost += MismatchedNameCost; newConfigurations.Add( openTags.Pop(), documentWithInsertedEndTags.Push(obj), newCost + matchCost ); newCost += MissingEndTagCost; openTags = openTags.Pop(); documentWithInsertedEndTags = documentWithInsertedEndTags.Push(EndTagPlaceholder); } } else { newConfigurations.Add( c.OpenTags, c.Document.Push(obj), c.Cost ); } } }
private void AddNewGroup() { ConfigurationList.Add(new ConfigurationGroup("New Group", null, TimeSpan.Zero)); }