-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
code-recipes
committed
Jul 30, 2017
1 parent
34af9eb
commit cc9276d
Showing
58 changed files
with
2,870 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2017 Carlos Gamez | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# xDGA | ||
|
||
**xDGA** is an Excel add-in that gives you the capability to apply Dissolved Gases Analysis (DGA) algorithms from all the major international guidelines. | ||
|
||
**xDGA** helps the user to use their existing DGA data and be able to quicly run assessments algorithms from any of the major international guidelines and industry best practices. | ||
|
||
In it's current version, **xDGA** implements only the recommendations contained in the IEC 60599 ed.3 2015. | ||
|
||
## Usage | ||
|
||
The add-in is activated by opening the **xDGA.ADDIN64.xll** or **xDGA.ADDIN.xll** file, depending on your architecture. Both files are in the **Distribution** folder and they are stand-alone (i.e. don't need other files or libraries to run). | ||
|
||
The formulas can then be applied to any Excel spreadsheet with DGA data. | ||
|
||
At the moment there are two main functions implemented. | ||
|
||
* SERIALIZEDGA() | ||
* IEC_60599() | ||
|
||
The SERIALIZEDGA() function accepts the date and the nine gases that constitute one DGA instance. The function produces a string with the JSON serialised version of the data. | ||
|
||
<p align="center"> | ||
<img src="Distribution/SERIALIZEDGA.PNG" alt="SERIALIZEDGA()" width="70%" /> | ||
</p> | ||
|
||
This is a helper function that prepares the date that can then be fed into the IEC_60599() funciton. | ||
|
||
The IEC_60599() function takes in the Current and the Previous DGA as well as a boolean value indicating whether the transformer has an On-Load Tap Changer (OLTC) and the volume of oil in the tank in litres. | ||
|
||
<p align="center"> | ||
<img src="Distribution/IEC_60599.PNG" alt="IEC_60599()" width="70%" /> | ||
</p> | ||
|
||
The IEC_60599() function returns a string with all the outputs and results of running the rules outlined in the guideline. | ||
|
||
<p align="center"> | ||
<img src="Distribution/IEC_60599-Output.PNG" alt="IEC_60599-Output" width="95%" /> | ||
</p> | ||
|
||
Explore the example file to get a better understanding of how these two functions work together. | ||
|
||
More guidelines are being implemented and will be released in the future, including IEEE and CIGRE guidelines. | ||
|
||
xDGA uses these great Open Source libraries: | ||
* [ExcelDna](https://excel-dna.net/) | ||
* [Json.NET](http://www.newtonsoft.com/json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# xDGA | ||
|
||
## Version 0.1 | ||
|
||
* First version released | ||
* Includes two functions: SERIALIZEDGA() and IEC_60599() | ||
* Uses [ExcelDna](https://excel-dna.net/) and [Json.NET](http://www.newtonsoft.com/json) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2017 Carlos Gamez | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
using ExcelDna.Integration; | ||
using System; | ||
using xDGA.CORE.Models; | ||
using xDGA.CORE.Algorithms; | ||
using System.Text; | ||
|
||
namespace xDGA.ADDIN | ||
{ | ||
public class AlgorithmFunctions | ||
{ | ||
[ExcelFunction(Description = "Returns a string with the JSON serialised version of the Dissolved Gas Analysis data.")] | ||
public static object SERIALIZEDGA(object samplingDate, double hydrogen, double methane, double ethane, | ||
double ethylene, double acetylene, double carbonMonoxide, double carbonDioxide, double oxygen, | ||
double nitrogen) | ||
{ | ||
DateTime date = Optional.Check(samplingDate, DateTime.MinValue); | ||
|
||
if (date == DateTime.MinValue) return ExcelError.ExcelErrorNull; | ||
|
||
var dga = new DissolvedGasAnalysis(date, hydrogen, methane, ethane, ethylene, acetylene, carbonMonoxide, carbonDioxide, oxygen, nitrogen); | ||
|
||
return dga.ToSerialisedJson(); | ||
} | ||
|
||
[ExcelFunction(Description = "Executes the assessment algorithms as recommended by the IEC60599 guidelines.")] | ||
public static object IEC_60599( | ||
[ExcelArgument(Description = "The JSON serialised string representing the latest Dissolved Gas Analysis data.")] | ||
string currentDga, | ||
[ExcelArgument(Description = "The JSON serialised string representing the previous Dissolved Gas Analysis data.")] | ||
object previousDga, | ||
[ExcelArgument(Description = "The oil volume of the transformer in litres.")] | ||
double oilVolume, | ||
[ExcelArgument(Description = "A boolean flag that indicates whether the transformer has an On-Load Tap Changer that communicates with the main tank or not.")] | ||
bool hasCommunicatingOltc = false) | ||
{ | ||
try | ||
{ | ||
string prevDga = Optional.Check(previousDga, string.Empty); | ||
|
||
var algo = new IEC60599Algorithm(currentDga, prevDga, oilVolume, hasCommunicatingOltc); | ||
algo.Execute(); | ||
|
||
var output = new StringBuilder(); | ||
|
||
foreach (var item in algo.Outputs) | ||
{ | ||
output.AppendLine($"[ {item.Name} => {item.Description} ]"); | ||
} | ||
|
||
return output.ToString(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return ex.Message; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2017 Carlos Gamez | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
using ExcelDna.Integration; | ||
using System; | ||
|
||
namespace xDGA.ADDIN | ||
{ | ||
/// <summary> | ||
/// This is a helper class that is used to deal with missing or optional | ||
/// Excel function parameters. | ||
/// </summary> | ||
public static class Optional | ||
{ | ||
internal static string Check(object arg, string defaultValue) | ||
{ | ||
if (arg is string) | ||
return (string)arg; | ||
else if (arg is ExcelMissing || arg is ExcelEmpty || arg is ExcelError) | ||
return defaultValue; | ||
else | ||
return arg.ToString(); | ||
} | ||
|
||
internal static DateTime Check(object arg, DateTime defaultDate) | ||
{ | ||
if (arg is double) | ||
return DateTime.FromOADate((double)arg); | ||
else if (arg is string) | ||
return DateTime.Parse((string)arg); | ||
else if (arg is ExcelMissing || arg is ExcelEmpty) | ||
return defaultDate; | ||
else | ||
throw new ArgumentException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("xDGA.ADDIN")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("xDGA.ADDIN")] | ||
[assembly: AssemblyCopyright("Copyright © 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("ed357eea-74f5-4078-9826-abb022aaee3e")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="ExcelDnaProps"> | ||
<!-- | ||
If you change properties in this file, they may not come into effect until you: | ||
* Rebuild the solution/project | ||
or | ||
* Close Visual Studio | ||
* Delete .vs folder, if exists | ||
* Delete ProjectName.csproj.user (or equivalent for VB, F#, etc.), if exists | ||
* Delete SolutionName.suo, if exists | ||
* Open your solution/project again in Visual Studio | ||
--> | ||
|
||
<!-- | ||
Configuration properties for building .dna files | ||
--> | ||
<PropertyGroup> | ||
<!-- | ||
Enable/Disable automatic generation of platform-specific versions of .dna files | ||
--> | ||
<ExcelDnaCreate32BitAddIn Condition="'$(ExcelDnaCreate32BitAddIn)' == ''">true</ExcelDnaCreate32BitAddIn> | ||
<ExcelDnaCreate64BitAddIn Condition="'$(ExcelDnaCreate64BitAddIn)' == ''">true</ExcelDnaCreate64BitAddIn> | ||
|
||
<!-- | ||
Define the suffix used for each platform-specific file e.g. MyAddIn64.dna | ||
--> | ||
<ExcelDna32BitAddInSuffix Condition="'$(ExcelDna32BitAddInSuffix)' == ''"></ExcelDna32BitAddInSuffix> | ||
<ExcelDna64BitAddInSuffix Condition="'$(ExcelDna64BitAddInSuffix)' == ''">64</ExcelDna64BitAddInSuffix> | ||
</PropertyGroup> | ||
|
||
<!-- | ||
Configuration properties for packing .dna files | ||
--> | ||
<PropertyGroup> | ||
<!-- | ||
Enable/Disable packing of .dna files | ||
--> | ||
<RunExcelDnaPack Condition="'$(RunExcelDnaPack)' == ''">true</RunExcelDnaPack> | ||
|
||
<!-- | ||
Suffix used for packed .xll files e.g. MyAddIn-packed.xll | ||
--> | ||
<ExcelDnaPackXllSuffix Condition="'$(ExcelDnaPackXllSuffix)' == ''">-packed</ExcelDnaPackXllSuffix> | ||
</PropertyGroup> | ||
</Project> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="ExcelDna.AddIn" version="0.34.6" targetFramework="net452" /> | ||
<package id="ExcelDna.Integration" version="0.34.6" targetFramework="net452" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<DnaLibrary Name="xDGA.ADDIN Add-In" RuntimeVersion="v4.0"> | ||
<ExternalLibrary Path="xDGA.ADDIN.dll" ExplicitExports="false" LoadFromBytes="true" Pack="true" /> | ||
<Reference Path="xDGA.CORE.dll" Pack="true" /> | ||
<Reference Path="Newtonsoft.Json.dll" Pack="true" /> | ||
|
||
<!-- | ||
The RuntimeVersion attribute above allows two settings: | ||
* RuntimeVersion="v2.0" - for .NET 2.0, 3.0 and 3.5 | ||
* RuntimeVersion="v4.0" - for .NET 4 and 4.5 | ||
|
||
Additional referenced assemblies can be specified by adding 'Reference' tags. | ||
These libraries will not be examined and registered with Excel as add-in libraries, | ||
but will be packed into the -packed.xll file and loaded at runtime as needed. | ||
For example: | ||
|
||
<Reference Path="Another.Library.dll" Pack="true" /> | ||
|
||
Excel-DNA also allows the xml for ribbon UI extensions to be specified in the .dna file. | ||
See the main Excel-DNA site at http://excel-dna.net for downloads of the full distribution. | ||
--> | ||
|
||
</DnaLibrary> |
Oops, something went wrong.