├── README_IMGS ├── 1.png └── 2.png ├── Scripter ├── bin │ └── Release │ │ ├── Scripter.exe │ │ ├── __RMS.cmd │ │ └── __RMSN.cmd ├── Properties │ └── AssemblyInfo.cs ├── Scripter.csproj └── Program.cs ├── readme.md ├── Scripter.sln └── license /README_IMGS/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samuel-oldra/BarkhausenScripter/HEAD/README_IMGS/1.png -------------------------------------------------------------------------------- /README_IMGS/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samuel-oldra/BarkhausenScripter/HEAD/README_IMGS/2.png -------------------------------------------------------------------------------- /Scripter/bin/Release/Scripter.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samuel-oldra/BarkhausenScripter/HEAD/Scripter/bin/Release/Scripter.exe -------------------------------------------------------------------------------- /Scripter/bin/Release/__RMS.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo I: %date% %time% 3 | for %%f in (*.lvm) do _Scripter.exe /RMS %%f 4 | echo F: %date% %time% -------------------------------------------------------------------------------- /Scripter/bin/Release/__RMSN.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo I: %date% %time% 3 | for %%f in (*.rms) do _Scripter.exe /RMSN %%f 4 | echo F: %date% %time% -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 |

2 | Barkhausen Scripter 3 |

4 |

5 | Ajuda • 6 | Executar 7 |

8 | 9 | # Ajuda 10 | ![alt text](https://raw.githubusercontent.com/samuel-oldra/BarkhausenScripter/main/README_IMGS/1.png) 11 | # Executar 12 | ![alt text](https://raw.githubusercontent.com/samuel-oldra/BarkhausenScripter/main/README_IMGS/2.png) -------------------------------------------------------------------------------- /Scripter.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scripter", "Scripter\Scripter.csproj", "{95FB0302-E0F9-4438-80B5-911DF53E16E7}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|x86 = Debug|x86 9 | Release|x86 = Release|x86 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {95FB0302-E0F9-4438-80B5-911DF53E16E7}.Debug|x86.ActiveCfg = Debug|x86 13 | {95FB0302-E0F9-4438-80B5-911DF53E16E7}.Debug|x86.Build.0 = Debug|x86 14 | {95FB0302-E0F9-4438-80B5-911DF53E16E7}.Release|x86.ActiveCfg = Release|x86 15 | {95FB0302-E0F9-4438-80B5-911DF53E16E7}.Release|x86.Build.0 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2012 Samuel B. Oldra 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Scripter/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | 8 | [assembly: AssemblyTitle("Scripter")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Scripter")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | 25 | [assembly: Guid("e2b816b0-02de-4ea5-9189-2d35390d79a5")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Build and Revision Numbers 35 | // by using the '*' as shown below: 36 | // [assembly: AssemblyVersion("1.0.*")] 37 | 38 | [assembly: AssemblyVersion("1.0.0.0")] 39 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /Scripter/Scripter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {95FB0302-E0F9-4438-80B5-911DF53E16E7} 9 | Exe 10 | Properties 11 | Scripter 12 | Scripter 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | x86 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | x86 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 51 | -------------------------------------------------------------------------------- /Scripter/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | 6 | namespace Scripter 7 | { 8 | internal class Program 9 | { 10 | #region Private Fields 11 | 12 | private static readonly List ItensRms = new List(); 13 | 14 | #endregion Private Fields 15 | 16 | #region Private Methods 17 | 18 | private static double CalcularMediaRms(List lista) 19 | { 20 | double total = lista.Sum(item => Math.Pow(item, 2)); 21 | return Math.Sqrt(total / lista.Count); 22 | } 23 | 24 | private static void GerarArquivoPico(string filePath, int margem = 2000) 25 | { 26 | int count = 1; 27 | int maiorIndice = 0; 28 | double maiorValor = 0; 29 | 30 | using (var writer = new StreamWriter(string.Concat(filePath, "p"), false)) 31 | { 32 | string linha; 33 | StreamReader reader = null; 34 | using (reader = new StreamReader(filePath)) 35 | { 36 | while ((linha = reader.ReadLine()) != null) 37 | { 38 | if (string.IsNullOrEmpty(linha)) continue; 39 | string[] colunas = linha.Split('\t'); 40 | 41 | if (colunas.Length < 3) continue; 42 | double sec = Convert.ToDouble(colunas[2].Replace('.', ',')); 43 | 44 | if (sec > maiorValor) 45 | { 46 | maiorValor = sec; 47 | maiorIndice = count; 48 | } 49 | count++; 50 | } 51 | } 52 | 53 | count = 1; 54 | int stopIndice = maiorIndice + margem; 55 | int startIndice = maiorIndice - margem; 56 | 57 | using (reader = new StreamReader(filePath)) 58 | { 59 | while ((linha = reader.ReadLine()) != null) 60 | { 61 | if (string.IsNullOrEmpty(linha)) continue; 62 | string[] colunas = linha.Split('\t'); 63 | 64 | if (colunas.Length < 3) continue; 65 | double pri = Convert.ToDouble(colunas[1].Replace('.', ',')); 66 | double sec = Convert.ToDouble(colunas[2].Replace('.', ',')); 67 | 68 | if (count > startIndice && count <= stopIndice) 69 | GravarArquivo(writer, pri, sec); 70 | count++; 71 | } 72 | } 73 | } 74 | } 75 | 76 | private static void GerarArquivoRms(string filePath, int passo = 10, int janela = 100) 77 | { 78 | ItensRms.Clear(); 79 | 80 | using (var writer = new StreamWriter(filePath.Replace(".lvm", ".rms"), false)) 81 | { 82 | using (var reader = new StreamReader(filePath)) 83 | { 84 | string linha; 85 | while ((linha = reader.ReadLine()) != null) 86 | { 87 | if (string.IsNullOrEmpty(linha)) continue; 88 | string[] colunas = linha.Split('\t'); 89 | 90 | if (colunas.Length < 3) continue; 91 | double pri = Convert.ToDouble(colunas[1].Replace('.', ',')); 92 | double sec = Convert.ToDouble(colunas[2].Replace('.', ',')); 93 | 94 | GravarArquivoRms(writer, pri, sec, passo, janela); 95 | } 96 | } 97 | } 98 | } 99 | 100 | private static void GerarArquivoRmsn(string filePath) 101 | { 102 | int count = 1; 103 | double total = 0; 104 | double media = 0; 105 | 106 | using (var writer = new StreamWriter(filePath.Replace(".rms", ".rmsn"), false)) 107 | { 108 | string linha; 109 | StreamReader reader = null; 110 | using (reader = new StreamReader(filePath)) 111 | { 112 | while ((linha = reader.ReadLine()) != null) 113 | { 114 | if (string.IsNullOrEmpty(linha)) continue; 115 | string[] colunas = linha.Split('\t'); 116 | 117 | if (colunas.Length < 3) continue; 118 | double sec = Convert.ToDouble(colunas[2].Replace('.', ',')); 119 | 120 | if (count > 5000) 121 | { 122 | media = total / 5000; 123 | break; 124 | } 125 | total += sec; 126 | count++; 127 | } 128 | } 129 | 130 | using (reader = new StreamReader(filePath)) 131 | { 132 | while ((linha = reader.ReadLine()) != null) 133 | { 134 | if (string.IsNullOrEmpty(linha)) continue; 135 | string[] colunas = linha.Split('\t'); 136 | 137 | if (colunas.Length < 3) continue; 138 | double pri = Convert.ToDouble(colunas[1].Replace('.', ',')); 139 | double sec = Convert.ToDouble(colunas[2].Replace('.', ',')); 140 | 141 | GravarArquivo(writer, pri - media, sec - media); 142 | } 143 | } 144 | } 145 | } 146 | 147 | private static void GerarArquivoRmsnm(string[] args) 148 | { 149 | int count = 0; 150 | int files = 0; 151 | var itensRmsnmPri = new double[500000]; 152 | var itensRmsnmSec = new double[500000]; 153 | 154 | foreach (string arg in args) 155 | { 156 | if (!new FileInfo(arg).Exists) continue; 157 | files++; 158 | 159 | count = 0; 160 | using (var reader = new StreamReader(arg)) 161 | { 162 | string linha; 163 | while ((linha = reader.ReadLine()) != null) 164 | { 165 | if (string.IsNullOrEmpty(linha)) continue; 166 | string[] colunas = linha.Split('\t'); 167 | 168 | if (colunas.Length < 3) continue; 169 | double pri = Convert.ToDouble(colunas[1].Replace('.', ',')); 170 | double sec = Convert.ToDouble(colunas[2].Replace('.', ',')); 171 | 172 | itensRmsnmPri[count] += pri; 173 | itensRmsnmSec[count] += sec; 174 | 175 | count++; 176 | } 177 | } 178 | } 179 | 180 | if (files > 0) 181 | using (var writer = new StreamWriter(args[1].Replace(".rmsn", ".rmsnm"), false)) 182 | for (int i = 0; i < count; i++) 183 | GravarArquivo(writer, itensRmsnmPri[i] / files, itensRmsnmSec[i] / files); 184 | } 185 | 186 | private static void GravarArquivo(StreamWriter writer, double pri, double sec) 187 | { 188 | writer.WriteLine(string.Format("\t{0:F6}\t{1:F6}", pri, sec).Replace(',', '.')); 189 | } 190 | 191 | private static void GravarArquivoRms(StreamWriter writer, double pri, double sec, int passo, int janela) 192 | { 193 | ItensRms.Add(sec); 194 | 195 | if (ItensRms.Count < janela) return; 196 | GravarArquivo(writer, pri, CalcularMediaRms(ItensRms)); 197 | ItensRms.RemoveRange(0, passo); 198 | } 199 | 200 | private static void Main(string[] args) 201 | { 202 | string script = string.Empty; 203 | if (args.Length >= 1) 204 | script = args[0]; 205 | 206 | switch (script) 207 | { 208 | case "/RMS": 209 | if (args.Length == 2) 210 | GerarArquivoRms(args[1]); 211 | else if (args.Length == 3) 212 | GerarArquivoRms(args[2], Convert.ToInt32(args[1])); 213 | else if (args.Length == 4) 214 | GerarArquivoRms(args[3], Convert.ToInt32(args[1]), Convert.ToInt32(args[2])); 215 | break; 216 | 217 | case "/RMSN": 218 | if (args.Length == 2) 219 | GerarArquivoRmsn(args[1]); 220 | break; 221 | 222 | case "/RMSNM": 223 | if (args.Length >= 2) 224 | GerarArquivoRmsnm(args); 225 | break; 226 | 227 | case "/PICO": 228 | if (args.Length == 2) 229 | GerarArquivoPico(args[1]); 230 | if (args.Length == 3) 231 | GerarArquivoPico(args[2], Convert.ToInt32(args[1])); 232 | break; 233 | 234 | default: 235 | MostrarHelp(); 236 | //Console.ReadKey(); 237 | break; 238 | } 239 | } 240 | 241 | private static void MostrarHelp() 242 | { 243 | Console.WriteLine(); 244 | Console.WriteLine(" SCRIPTS:"); 245 | Console.WriteLine(); 246 | Console.WriteLine(" /RMS - Gerar arquivo de RMS"); 247 | Console.WriteLine(" Scripter.exe /RMS [nome_arquivo_lvm]"); 248 | Console.WriteLine(" Scripter.exe /RMS [passo] [nome_arquivo_lvm]"); 249 | Console.WriteLine(" Scripter.exe /RMS [passo] [janela] [nome_arquivo_lvm]"); 250 | Console.WriteLine(" Ex.: Scripter.exe /RMS teste.lvm"); 251 | Console.WriteLine(" Ex.: Scripter.exe /RMS 10 teste.lvm"); 252 | Console.WriteLine(" Ex.: Scripter.exe /RMS 10 100 teste.lvm"); 253 | Console.WriteLine(); 254 | Console.WriteLine(" /RMSN - Gerar arquivo de RMSN (Normalizado)"); 255 | Console.WriteLine(" Scripter.exe /RMSN [nome_arquivo_rms]"); 256 | Console.WriteLine(" Ex.: Scripter.exe /RMSN teste.rms"); 257 | Console.WriteLine(); 258 | Console.WriteLine(" /RMSNM - Gerar arquivo de RMSNM"); 259 | Console.WriteLine(" Scripter.exe /RMSNM [nome_arq_rmsn] [nome_arq_rmsn] ... [nome_arq_rmsn]"); 260 | Console.WriteLine(" Ex.: Scripter.exe /RMSNM teste1.rmsn teste2.rmsn ... testen.rmsn"); 261 | Console.WriteLine(); 262 | Console.WriteLine(" /PICO - Gerar arquivo de PICO"); 263 | Console.WriteLine(" Scripter.exe /PICO [nome_arq_lvm|nome_arq_rms|nome_arq_rmsn]"); 264 | Console.WriteLine(" Scripter.exe /PICO [margem] [nome_arq_lvm|nome_arq_rms|nome_arq_rmsn]"); 265 | Console.WriteLine(" Ex.: Scripter.exe /PICO teste.rms"); 266 | Console.WriteLine(" Ex.: Scripter.exe /PICO 2000 teste.rms"); 267 | Console.WriteLine(); 268 | } 269 | 270 | #endregion Private Methods 271 | } 272 | } --------------------------------------------------------------------------------