Aggiunta progetto LogParser

This commit is contained in:
Samuele E. Locatelli
2018-09-20 18:42:46 +02:00
parent e56c3e645d
commit ae812f2dea
7 changed files with 18982 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2019
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogParser", ".\LogParser\LogParser.csproj", "{A49A795D-11BD-4CC9-9EEE-CC995696608B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A49A795D-11BD-4CC9-9EEE-CC995696608B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A49A795D-11BD-4CC9-9EEE-CC995696608B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A49A795D-11BD-4CC9-9EEE-CC995696608B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A49A795D-11BD-4CC9-9EEE-CC995696608B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {37E62FCE-44DF-48DA-8B57-C4B2253B0B2C}
EndGlobalSection
EndGlobal
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
</configuration>
+58
View File
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{A49A795D-11BD-4CC9-9EEE-CC995696608B}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ANTLR_LogParser</RootNamespace>
<AssemblyName>ANTLR_LogParser</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="Resources\example.csv" />
<None Include="Resources\rawDataFull.log" />
<None Include="rawData.log">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+83
View File
@@ -0,0 +1,83 @@
using System;
using System.IO;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
namespace ANTLR_LogParser
{
class Program
{
static void Main(string[] args)
{
string fileInName = "rawData.log";
string fileOutName = "dataStream.csv";
bool doWrite = false;
Console.WriteLine("--------------------------------------------");
Console.WriteLine("SOUR LOG CONVERTER");
Console.WriteLine("--------------------------------------------");
Console.WriteLine(string.Format("Conversione file: {0} --> {1}", fileInName, fileOutName));
// carica da file...
StreamReader fileIn = new StreamReader(fileInName);
StreamWriter fileOut = new StreamWriter(fileOutName);
// leggo 1 linea alla volta...
string linea;
string[] words;
while ((linea = fileIn.ReadLine()) != null)
{
if (linea.Length > 10)
{
words = linea.Split(' ');
// switch su 6° blocco...
if (words.Length > 6)
{
switch (words[5])
{
case ">>>>":
// INIZIO ALLARME
Console.WriteLine(linea);
if (doWrite)
{
fileOut.WriteLine(linea);
}
break;
case "<<<<":
// FINE ALLARME
Console.WriteLine(linea);
if (doWrite)
{
fileOut.WriteLine(linea);
}
break;
case "DATA":
// variazione valore
Console.WriteLine(linea);
if (doWrite)
{
fileOut.WriteLine(linea);
}
break;
default:
// commenti o altro, non faccio nulla
break;
}
}
//// SOLO SE è una riga con dati pertineti la scrivo...
//if (words[5] == ">>>>>")
//{
// Console.WriteLine(linea);
//}
}
}
// chiudo file
fileIn.Close();
fileOut.Flush();
fileOut.Close();
}
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Le informazioni generali relative a un assembly sono controllate dal seguente
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
// associate a un assembly.
[assembly: AssemblyTitle("ANTLR-LogParser")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ANTLR-LogParser")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
// COM, impostare su true l'attributo ComVisible per tale tipo.
[assembly: ComVisible(false)]
// Se il progetto viene esposto a COM, il GUID seguente verrà utilizzato come ID della libreria dei tipi
[assembly: Guid("a49a795d-11bd-4cc9-9eee-cc995696608b")]
// Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori:
//
// Versione principale
// Versione secondaria
// Numero di build
// Revisione
//
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,25 @@
Nota da Fabrizio Morroia
Questo è il set minimo di informazioni che servono ad MSIM per creare il DB del player.
BrowseName viene preso dal campo Channel
il campo DataValues contiene un JSON serializzato diverso nel caso di allarmi o variabili.
Nel caso degli allarmi viene preso:
* ts (timstamp)
* conditionName
* v (messaggio di errore)
* severity
* activeState
Nel caso delle vaiabili viene preso:
* st (server time)
* v (valore della variabile)
Potremmo pensare di abbondonare il CSV con JSON serializzato per un JSON puro.
Teniamo presente che se passiamo al JSON puro perdiamo la compatibilità con i log Cloud Plugs,
sempre perchè avere più formati e più parser a seconda del punto di registrazione non ci sembra
una buona soluzione.
Saluti.
Fabrizio
File diff suppressed because it is too large Load Diff