Skip to content

Commit

Permalink
Merge pull request #6 from mrecht/master
Browse files Browse the repository at this point in the history
Common interface for table classes, disposable connections and general cleanup
  • Loading branch information
maciejlach committed Jul 13, 2015
2 parents d92fe9b + 3c942cc commit f53cff9
Show file tree
Hide file tree
Showing 42 changed files with 1,909 additions and 1,721 deletions.
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
174 changes: 174 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
x64/
build/
bld/
[Bb]in/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

#NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding addin-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
_NCrunch_*
.*crunch*.local.xml

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml

# NuGet Packages Directory
packages/
## TODO: If the tool you use requires repositories.config uncomment the next line
#!packages/repositories.config

# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
!packages/build/

# Windows Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/
25 changes: 13 additions & 12 deletions AsynchClient/AsynchQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

namespace qSharp.Sample
{
class AsynchQuery
internal class AsynchQuery
{
static void Main(string[] args)
private static void Main(string[] args)
{
QCallbackConnection q = new QCallbackConnection(host: (args.Length >= 1) ? args[0] : "localhost",
port: (args.Length >= 2) ? Int32.Parse(args[1]) : 5000);
var q = new QCallbackConnection((args.Length >= 1) ? args[0] : "localhost",
(args.Length >= 2) ? int.Parse(args[1]) : 5000);
try
{
q.DataReceived += OnData;
Expand All @@ -39,9 +39,9 @@ static void Main(string[] args)
q.Sync("asynchMult:{[queryid;a;b] res:a*b; (neg .z.w)(`queryid`result!(queryid;res)) }");
q.StartListener();

Random gen = new Random();
var gen = new Random();
// send asynchronous queries
for (int i = 0; i < 10; i++)
for (var i = 0; i < 10; i++)
{
int a = gen.Next(20), b = gen.Next(20);
Console.WriteLine("Asynchronous call with queryid=" + i + " with arguments= " + a + ", " + b);
Expand All @@ -65,14 +65,16 @@ static void Main(string[] args)
}
}

static void OnData(object sender, QMessageEvent message)
private static void OnData(object sender, QMessageEvent message)
{
Console.WriteLine("Asynchronous message received.");
Console.WriteLine("message type: " + message.Message.MessageType + " size: " + message.Message.MessageSize + " isCompressed: " + message.Message.Compressed + " endianess: " + message.Message.Endianess);
Console.WriteLine("message type: " + message.Message.MessageType + " size: " + message.Message.MessageSize +
" isCompressed: " + message.Message.Compressed + " endianess: " +
message.Message.Endianess);
PrintResult(message.Message.Data);
}

static void PrintResult(object obj)
private static void PrintResult(object obj)
{
if (obj == null)
{
Expand All @@ -88,13 +90,12 @@ static void PrintResult(object obj)
}
}

static void PrintResult(QDictionary d)
private static void PrintResult(QDictionary d)
{
foreach (QDictionary.KeyValuePair e in d)
{
Console.WriteLine(e.Key + "| " + e.Value);
}
}

}
}
}
7 changes: 5 additions & 2 deletions Distribution/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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("qSharp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
Expand All @@ -17,9 +17,11 @@
// 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("66f7e95d-fea0-4958-ab2e-e927791e907c")]

// Version information for an assembly consists of the following four values:
Expand All @@ -29,5 +31,6 @@
// Build Number
// Revision
//

[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
42 changes: 18 additions & 24 deletions Publisher/Publisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@
//

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace qSharp.Sample
{
public class Publisher
{

public static void Main(String[] Args)
public static void Main(string[] Args)
{
QConnection q = new QBasicConnection(Args.Length >= 1 ? Args[0] : "localhost",
Args.Length >= 2 ? int.Parse(Args[1]) : 5001, null, null);
Args.Length >= 2 ? int.Parse(Args[1]) : 5001, null, null);
try
{
q.Open();
Expand All @@ -37,8 +33,8 @@ public static void Main(String[] Args)
Console.WriteLine("Press <ENTER> to close application");
q.Sync(".u.upd:{[x;y] show (x;y)};");

PublisherTask pt = new PublisherTask(q);
Thread workerThread = new Thread(pt.Run);
var pt = new PublisherTask(q);
var workerThread = new Thread(pt.Run);
workerThread.Start();

Console.ReadLine();
Expand All @@ -54,19 +50,18 @@ public static void Main(String[] Args)
q.Close();
}
}

}

class PublisherTask
internal class PublisherTask
{
private QConnection q;
private Random r;
private Boolean running = true;
private readonly QConnection q;
private readonly Random r;
private bool running = true;

public PublisherTask(QConnection q)
{
this.q = q;
this.r = new Random((int)DateTime.Now.Millisecond);
r = new Random(DateTime.Now.Millisecond);
}

public void Stop()
Expand All @@ -85,27 +80,26 @@ public void Run()
// table: ask
q.Sync(".u.upd", "ask", GetAskData());
Console.Out.Write(".");
System.Threading.Thread.Sleep(500);
Thread.Sleep(500);
}
catch (QException e1)
{
// q error
Console.WriteLine("`" + e1.Message);
}

}
}

private Object[] GetAskData()
private object[] GetAskData()
{
int rows = r.Next(10) + 1;
Object[] data = new Object[] { new QTime[rows], new String[rows], new String[rows], new float[rows] };
for (int i = 0; i < rows; i++)
var rows = r.Next(10) + 1;
object[] data = {new QTime[rows], new string[rows], new string[rows], new float[rows]};
for (var i = 0; i < rows; i++)
{
((QTime[])data[0])[i] = new QTime(DateTime.Now);
((String[])data[1])[i] = "INSTR_" + r.Next(100);
((String[])data[2])[i] = "qSharp";
((float[])data[3])[i] = (float)r.NextDouble() * r.Next(100);
((QTime[]) data[0])[i] = new QTime(DateTime.Now);
((string[]) data[1])[i] = "INSTR_" + r.Next(100);
((string[]) data[2])[i] = "qSharp";
((float[]) data[3])[i] = (float) r.NextDouble()*r.Next(100);
}

return data;
Expand Down
Loading

0 comments on commit f53cff9

Please sign in to comment.