Skip to content

Commit

Permalink
Compile as 64 bit with ANY cpu works now. Solved the sqlite interrop …
Browse files Browse the repository at this point in the history
…problem i hope....

64-bit under 64 bit os finally.
  • Loading branch information
Robert Wahlström committed Jan 15, 2016
1 parent 9697e50 commit 324a41a
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 110 deletions.
19 changes: 19 additions & 0 deletions EDDiscovery.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,36 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6EE10D92-E3E4-44D9-8E6B-851801B0B510}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6EE10D92-E3E4-44D9-8E6B-851801B0B510}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6EE10D92-E3E4-44D9-8E6B-851801B0B510}.Debug|x64.ActiveCfg = Debug|x64
{6EE10D92-E3E4-44D9-8E6B-851801B0B510}.Debug|x64.Build.0 = Debug|x64
{6EE10D92-E3E4-44D9-8E6B-851801B0B510}.Debug|x86.ActiveCfg = Debug|x86
{6EE10D92-E3E4-44D9-8E6B-851801B0B510}.Debug|x86.Build.0 = Debug|x86
{6EE10D92-E3E4-44D9-8E6B-851801B0B510}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6EE10D92-E3E4-44D9-8E6B-851801B0B510}.Release|Any CPU.Build.0 = Release|Any CPU
{6EE10D92-E3E4-44D9-8E6B-851801B0B510}.Release|x64.ActiveCfg = Release|x64
{6EE10D92-E3E4-44D9-8E6B-851801B0B510}.Release|x64.Build.0 = Release|x64
{6EE10D92-E3E4-44D9-8E6B-851801B0B510}.Release|x86.ActiveCfg = Release|x86
{6EE10D92-E3E4-44D9-8E6B-851801B0B510}.Release|x86.Build.0 = Release|x86
{C4452886-6A1B-4AFD-9E76-AB0E5D8AABA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4452886-6A1B-4AFD-9E76-AB0E5D8AABA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4452886-6A1B-4AFD-9E76-AB0E5D8AABA5}.Debug|x64.ActiveCfg = Debug|x64
{C4452886-6A1B-4AFD-9E76-AB0E5D8AABA5}.Debug|x64.Build.0 = Debug|x64
{C4452886-6A1B-4AFD-9E76-AB0E5D8AABA5}.Debug|x86.ActiveCfg = Debug|x86
{C4452886-6A1B-4AFD-9E76-AB0E5D8AABA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4452886-6A1B-4AFD-9E76-AB0E5D8AABA5}.Release|Any CPU.Build.0 = Release|Any CPU
{C4452886-6A1B-4AFD-9E76-AB0E5D8AABA5}.Release|x64.ActiveCfg = Release|x64
{C4452886-6A1B-4AFD-9E76-AB0E5D8AABA5}.Release|x64.Build.0 = Release|x64
{C4452886-6A1B-4AFD-9E76-AB0E5D8AABA5}.Release|x86.ActiveCfg = Release|x86
{C4452886-6A1B-4AFD-9E76-AB0E5D8AABA5}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
13 changes: 9 additions & 4 deletions EDDiscovery/App.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="EDDiscovery.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<userSettings>
<EDDiscovery.Properties.Settings>
Expand All @@ -18,4 +18,9 @@
</setting>
</EDDiscovery.Properties.Settings>
</userSettings>
</configuration>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data></configuration>
1 change: 1 addition & 0 deletions EDDiscovery/DB/DistanceClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public static List<DistanceClass> ParseEDSM(string json, ref string date)

// date = edscdata["date"].Value<string>();
date = maxdate.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
edsm = null;

return listDistances;
}
Expand Down
72 changes: 55 additions & 17 deletions EDDiscovery/EDDiscovery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
Expand Down Expand Up @@ -75,15 +77,49 @@
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Noesis.Javascript, Version=0.0.0.0, Culture=neutral, processorArchitecture=x86" Condition="'$(PlatformTarget)' == 'x86'">
<HintPath>..\packages\Noesis.Javascript.0.7.1.0\lib\net40\x86\Noesis.Javascript.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OpenTK">
<HintPath>..\packages\OpenTK.1.1.1589.5942\lib\NET40\OpenTK.dll</HintPath>
</Reference>
Expand All @@ -92,11 +128,13 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite">
<HintPath>.\System.Data.SQLite.dll</HintPath>
<Reference Include="System.Data.SQLite, Version=1.0.99.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net40\System.Data.SQLite.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Data.SQLite.Linq">
<HintPath>.\System.Data.SQLite.Linq.dll</HintPath>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.99.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.99.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Web" />
Expand Down Expand Up @@ -284,9 +322,6 @@
<Content Include="fge-logo-001-dark.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="SQLite.Interop.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="PlanetSystems\AddMaterialNodeControl.resx">
<DependentUpon>AddMaterialNodeControl.cs</DependentUpon>
</EmbeddedResource>
Expand Down Expand Up @@ -354,12 +389,15 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
copy ..\..\SQLite.Interop.dll .
if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
xcopy /s /y "$(SolutionDir)packages\Noesis.Javascript.0.7.1.0\NativeBinaries\net40\x86\*.*" "$(TargetDir)x86"
if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64"
xcopy /s /y "$(SolutionDir)packages\Noesis.Javascript.0.7.1.0\NativeBinaries\net40\amd64\*.*" "$(TargetDir)amd64"</PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<Import Project="..\packages\System.Data.SQLite.Core.1.0.99.0\build\net40\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.99.0\build\net40\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.99.0\build\net40\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.99.0\build\net40\System.Data.SQLite.Core.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
4 changes: 2 additions & 2 deletions EDDiscovery/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 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("2.6.6.0")]
[assembly: AssemblyFileVersionAttribute("2.6.6.0")]
[assembly: AssemblyVersion("2.6.7.0")]
[assembly: AssemblyFileVersionAttribute("2.6.7.0")]
Binary file removed EDDiscovery/SQLite.Interop.dll
Binary file not shown.
88 changes: 1 addition & 87 deletions EDDiscovery/Trilateration/Trilateration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Noesis.Javascript;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -699,95 +698,10 @@ public void AddEntry(double x, double y, double z, double distance)
/// <returns>Result information, including coordinate and corrected Entry distances if found.</returns>
public Result Run(Algorithm algorithm)
{
switch (algorithm)
{
case Algorithm.RedWizzard_Native:
return RunCSharp();
case Algorithm.RedWizzard_Emulated:
return RunJavascript();
default:
throw new NotImplementedException();
}
}


private Result RunJavascript()
{
var engine = PrepareJavascriptEngine();

engine.Run("var trilat = new Trilateration();");

foreach (var entry in entries)
{
var coord = entry.Coordinate;
var entryDict = new Dictionary<string, double>() {
{ "x", coord.X },
{ "y", coord.Y },
{ "z", coord.Z },
{ "distance", entry.Distance }
};
engine.SetParameter("distance", entryDict);
engine.Run("trilat.addDistance(distance);");
}

engine.Run("trilat.addDistance({ x: 0, y: 0, z: 0, distance: 0 });");

engine.Run("var hasBestCandidate = trilat.best && trilat.best.length === 1;");
var hasBestCandidate = (bool)engine.GetParameter("hasBestCandidate");

if (hasBestCandidate)
{
engine.Run("EDDlog('x = ' + trilat.best[0].x + ', y = ' + trilat.best[0].y + ', z = ' + trilat.best[0].z);");

engine.Run("var bestResult = trilat.best[0];");
var result = (Dictionary<string, object>)engine.GetParameter("bestResult"); // contains either int or double
var coordinate = new Coordinate(
result["x"] is int ? (int)result["x"] * 1.0 : (double)result["x"],
result["y"] is int ? (int)result["y"] * 1.0 : (double)result["y"],
result["z"] is int ? (int)result["z"] * 1.0 : (double)result["z"]
);
var correctEntriesCount = 0;
var correctedEntries = new Dictionary<Entry, double>();

foreach (var entry in entries)
{
var correctedDistance = entry.Coordinate % coordinate;
if (correctedDistance == entry.Distance)
{
correctEntriesCount++;
}
correctedEntries.Add(entry, correctedDistance);
}

engine.Run("EDDlog('trilat.bestCount: ' + trilat.bestCount);");
engine.Run("EDDlog('trilat.nextBest: ' + trilat.nextBest);");
engine.Run("var isPreciseEnough = (trilat.bestCount - trilat.nextBest) >= 2;");
var isPreciseEnough = (bool)engine.GetParameter("isPreciseEnough");
if (isPreciseEnough && correctEntriesCount >= 5)
{
return new Result(ResultState.Exact, coordinate, correctedEntries);
}
else
{
return new Result(ResultState.NotExact, coordinate, correctedEntries);
}
}
else
{
return new Result(ResultState.NeedMoreDistances);
}
}

private JavascriptContext PrepareJavascriptEngine()
{
JavascriptContext context = new JavascriptContext();

context.Run(File.ReadAllText("fround.js"));
context.Run(File.ReadAllText("trilateration.js"));
context.SetParameter("EDDlog", new Action<object>(delegate(object o) { logger(o.ToString()); }));

return context;
}

public class CalculationErrorException : Exception { }

Expand Down
2 changes: 2 additions & 0 deletions EDDiscovery/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
<package id="Noesis.Javascript" version="0.7.1" targetFramework="net4" userInstalled="true" />
<package id="OpenTK" version="1.1.1589.5942" targetFramework="net4" userInstalled="true" />
<package id="OpenTK.GLControl" version="1.1.1589.5942" targetFramework="net4" userInstalled="true" />
<package id="System.Data.SQLite.Core" version="1.0.99.0" targetFramework="net40" />
<package id="System.Data.SQLite.Linq" version="1.0.99.0" targetFramework="net40" />
</packages>
57 changes: 57 additions & 0 deletions EDDiscoveryTests/EDDiscoveryTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -35,9 +37,53 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4" />
<Reference Include="System" />
<Reference Include="System.Data.SQLite, Version=1.0.99.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net40\System.Data.SQLite.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.99.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.99.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Drawing" />
</ItemGroup>
<Choose>
Expand All @@ -62,6 +108,10 @@
<Name>EDDiscovery</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand All @@ -82,6 +132,13 @@
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\System.Data.SQLite.Core.1.0.99.0\build\net40\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.99.0\build\net40\System.Data.SQLite.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\System.Data.SQLite.Core.1.0.99.0\build\net40\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Data.SQLite.Core.1.0.99.0\build\net40\System.Data.SQLite.Core.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down

0 comments on commit 324a41a

Please sign in to comment.