Viperpit(s).org
September 03, 2010, 02:38:28 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Do you realise that all this new glitter and glamour DOES cost money every month ?
Do VP a favour and click on the PayPal button to your left ! Wink
 
  Home   Forum   AUCTIONS GALLERY DOWNLOADS MEMBER MAP Login Register Help   **
Recent Posts
[Today at 02:31:16 PM]

by gus
[Today at 02:17:26 PM]

[Today at 12:53:04 PM]

[Today at 10:57:51 AM]

[Today at 10:41:28 AM]

[Today at 01:09:50 AM]

[Today at 12:49:54 AM]

[September 02, 2010, 01:47:00 PM]

[September 02, 2010, 12:30:03 PM]

by KK
[September 02, 2010, 08:41:57 AM]

[September 02, 2010, 07:26:05 AM]

[September 01, 2010, 04:50:46 PM]
Forum Donations
Help us keep Viperpit alive !
Feeds
Atom feed RSS/RDF feed RSS 0.91 Feed RSS 2.0 Feed
Pages: [1] 2 3 ... 6   Go Down
  Add bookmark  |  Print  
Author Topic: Open-source macro programming library  (Read 10627 times)
lightning
-=VP Donor=-
General
*
Offline Offline

United States United States

Awards:

Grant award..
Posts: 2126


Topic starter

WWW
« on: January 31, 2008, 06:00:26 PM »

I'm starting a thread for my macro programming tools project here, and I'll keep it up to date as progress is made, with source code postings and such things, along the way. 

The basic idea for this project is to create an open-source software library that makes creating macros for various input devices a lot easier. 

Built on top of this open-source library will be a custom-developed, user-friendly scripting language (somewhat akin to the Cougar macro language), a compiler, and a runtime that can execute user-defined scripts.  Later, there may be a visual development environment as well. 

To give you an idea of some of the "primitives" that make up the underlying library, here's an incomplete list:

AnalogSignal
  Represents a 64-bit integer value, and provides notifications to registered "listeners" whenever this value changes.

Counter
  Takes a DigitalSignal called In, and produces an AnalogSignal that represents the number of times the DigitalSignal's value has been set High (true).   Also provides a Reset line, and can be initialized  to start at any number, and increment by any number.

Delay
  Allows adding user-defined delay to a macro chain.  When Delay's In signal is set High (true), it's Out signal will come on a user-specified  time period later.

DigitalSignal
  Represents a Boolean value (true or false), and provides notifications to registerd "listeners" whenever this value changes.

ExecuteCommand
  When its In line is set High (true), ExecuteCommand runs a user-specified program, optionally supplying user-specified parameters to the program. 

FlipFlop
  Each time its In line is set High (true), a FlipFlop's Out value toggles between true and false

ForcedPriorityTask
  When its In line is set High (true), a ForcedPriorityTask will cause any other I/O macros to queue up.  When the ForcedPriorityTask completes, those other macros can then be completed in the order they were queued.

IntegerOperation
  Provides basic math operations on AnalogSignals. Available operators include: AbsoluteValue, Multiply,Divide,Add, Subtract,DivRem (modulo division), Min,Max,Power,Sign,LeftShift,RightShift, and Negate, among potentially many others. 

Takes any number of AnalogSignals and applies the given operator to them, in order, producing another AnalogSignal as the output carrying the result of the operation.

Inverter
  Flips a DigitalSignal to its opposite value.  An Inverter's Out line is set High (true) whenever its In line is set Low (false).

Join
  Waits for two or more DigitalSignals to be set High (true), at which point its Out line is set High (true). 

KeyPress
  Generates a user-specified key press (down, up, or both in sequence) one time, when its In line is set High (true).  Upon completion, it raises its Out line.

LogicGate
  Provides basic logical operators on DigitalSignals.  Operators include Not (output is the opposite of the input),And, OrNand,Nor, Xor,XNor,False (output is True when both inputs are False),and True (output is True when both inputs are True)

Macro
  Provides a wrapper that allows waiting for multiple, chained "primitives" to finish.  A Macro has an In line that will start the macro chain when it is raised.  It also requires a ToStart line indicating the input signal at the front of the macro chain that will be started, and a WaitFor line that represents the output from the last macro in the chain. A Macro's Out line will be set High (true) when all of the macros contained in the chain have completed.

MouseClick
  Generates a mouse button click (or a simple independent button-down or button-up event) on the user-specified mouse button, when its In line is set High (true).  Upon completion, its Out line will be set High (true). 

MouseDoubleClick
  Same as MouseClick except generates a double click on the specified mouse button.

MouseMovement
  Moves the mouse cursor to the specified absolute or relative coordinates when its In line is set High (true). Upon completion, its Out line will be set High (true). 

MouseRotator
  Similar to the Cougar's MOUSEROTATE command.  Rotates the mouse cursor around a user-specified circle, optionally executing a Macro at user-defined spots along the circle or along the entire path.  Upon completion, its Out line will be set High (true). 

MouseWheelMovement
 Simulates movement of the mouse wheel by a user-specified amount (specified in multiples of WheelDelta).  Upon completion, its Out line will be set High (true). 

Pulser
  A Pulser toggles a Macro on and off, at user-specified intervals. 

Range
  Represents a pair of user-specified analog values to which an AnalogSignal can be compared. 

RangeEvaluator
  Compares an AnalogSignal to a Range.  The RangeEvaluator's Out line will be set to High (true) when the AnalogSignal's value is within the specified Range.

Repeater
  Repeats a Macro a user-specified number of times.

Split
  Splits a DigitalSignal into two or more DigitalSignals that all derive their values from same source DigitalSignal.  Allows for macro chains to execute in parallel.

Timeout
  Executes a Macro and forcibly aborts the Macro if the Macro does not complete within a user-specified time period.

Timer
  Executes a Macro only for a user-specified time period.

Toggle
  Each time its In line is set High (true), a Toggle will set the next DigitalSignal in its Outs collection to High (true), and will set all other output lines Low (false).  A Toggle also provides reset and reverse lines.  Acts as a switch for selecting between alternate signal paths, in sequence.

You can combine these programmatic "primitives" to produce a full-fledged macro program.  The "compiler" itself, generates a program built entirely from these and other such primitives. 

An example C# code snippet, showing a tiny program built using some of the above primitives, is shown below:

Code:
            ExecuteCommand notepad = new ExecuteCommand("notepad.exe");
            Delay waitForNotepad = new Delay(new TimeSpan(0, 0, 4), notepad.Out);

            KeyPress key1 = new KeyPress(Keys.H);
            KeyPress key2 = new KeyPress(Keys.E, key1.Out);
            KeyPress key3 = new KeyPress(Keys.L, key2.Out);
            KeyPress key4 = new KeyPress(Keys.L, key3.Out);
            KeyPress key5 = new KeyPress(Keys.O, key4.Out);
            KeyPress key6 = new KeyPress(Keys.Oemcomma, key5.Out);
            KeyPress key7 = new KeyPress(Keys.Space, key6.Out);
            KeyPress key8 = new KeyPress(Keys.W, key7.Out);
            KeyPress key9 = new KeyPress(Keys.O, key8.Out);
            KeyPress key10 = new KeyPress(Keys.R, key9.Out);
            KeyPress key11 = new KeyPress(Keys.L, key10.Out);
            KeyPress key12 = new KeyPress(Keys.D,key11.Out);
            KeyPress key13 = new KeyPress(Keys.OemPeriod, key12.Out);
            KeyPress key14 = new KeyPress(Keys.Return, key13.Out);
            Delay d = new Delay(new TimeSpan(0, 0, 0, 1));
            d.In = key14.Out;
           
            Pulser p = new Pulser(new TimeSpan(0,0,0,0,1));
            p.Macro.ToStart = key1.In;
            p.Macro.WaitFor = d.Out;

            Timer t = new Timer(new TimeSpan(0, 0,1));
            t.Macro.ToStart = p.In;
            t.Macro.WaitFor = p.Out;

            Macro start = new Macro();
            start.In = waitForNotepad.Out; //this macro will start after notepad launches
            start.ToStart = t.In;
            start.WaitFor = t.Out;

            notepad.In.State = true; //start the notepad macro which will in turn launch our other stuff

I leave it as an exercise for the reader to figure out just what this simple program might be outputting.

I will be uploading the primitives library to this thread in a few weeks, and I'll get more work done on the scripting language and compiler after that.   

edit:the current work on this macro tools project can be found in my Subversion repository, for now; NOT on the main page of my Assembla workspace, yet, since it has not been officially released yet...)
« Last Edit: March 10, 2008, 02:59:22 AM by lightning » Logged

bismond
General
******
Offline Offline

United States United States

Awards:

Grant award..
Posts: 502



« Reply #1 on: January 31, 2008, 07:10:43 PM »

Naughty boy! Reading, sipping coffee...
Logged

ttp://www.vusaf.org/
lightning
-=VP Donor=-
General
*
Offline Offline

United States United States

Awards:

Grant award..
Posts: 2126


Topic starter

WWW
« Reply #2 on: January 31, 2008, 07:19:30 PM »

wtf?
Logged

bismond
General
******
Offline Offline

United States United States

Awards:

Grant award..
Posts: 502



« Reply #3 on: January 31, 2008, 07:54:55 PM »

It looked better the first time. Reading, sipping coffee...
Logged

ttp://www.vusaf.org/
kdittyr
Brig.General
*****
Offline Offline

United States United States

Grant award..
Posts: 264



« Reply #4 on: February 03, 2008, 10:19:58 PM »

Cool, good idea.  Thanks Lightning Smiley
Logged

________________________
kdittyr -aka- "PoppaSmoke"

lightning
-=VP Donor=-
General
*
Offline Offline

United States United States

Awards:

Grant award..
Posts: 2126


Topic starter

WWW
« Reply #5 on: February 14, 2008, 04:26:16 AM »

Here's the first deliverable in this project -- a C# .NET shared memory reader.  This supports the OpenFalcon header format, the BMS2/FreeFalcon/RedViper header format, and the F4AF header format.  Edit: Now also supports COM languages like VB6.

Also included is a "test" project which can dump the contents of the shared memory out to a console window where you can pipe it into a text file.  This has been tested with OF4.5, RedViper 4, and F4AF. 

I can't be bothered to do a full NDoc/Sandcastle doc package on this one (nor follow .Net coding style conventions for the FlightData class field names...) but there's plenty of documentation out there (and in the code comments) on the shared memory values...

This library provides an easy way for .NET & COM-compliant language (i.e. VB6, Delphi, etc.) programmers to work with the shared memory without having to worry about whether they got the marshaling details right and without having to deal with the beast of handling different header file formats.  As the headers change, I'll keep this up library up to date with the changes.

It's very easy to use from your own code -- just create an instance of the F4SharedMem.Reader class, providing it with the format type that you want to read (AF, OF, BMS2).  You then loop while checking the IsFalconRunning property to detect that properly.  Once Falcon's running, you can then call GetCurrentData() which will give you back a format-neutral FlightData object containing everything from the shared memory (with nulled or zeroed fields where those aren't supported by the specified data format).  For performance reasons, the connection to Falcon's shared memory-mapped file is held open until the Reader is Dispose()'d.

The shared memory tester tool that comes bundled with this library is just a simple console executable which takes a single optional command line argument that specifies the data format ("bms" (or "redviper"), "alliedforce", or "openfalcon").  The tester tool will connect to Falcon's shared memory and output a detailed report of all the values in the shared mem, including the names of any lightbits/HSIbits that are on (as well as the raw values of those fields in binary and decimal).  I have no idea why you'd want to use the tester program except for troubleshooting purposes, but perhaps you have some other use for it like piping the output into a script or batch file or whatever.

Anyway -- here's the zip containing the Visual Studio 2005 projects for the F4 Shared Memory Reader for .NET & COM.

edit: The F4 Shared Memory Reader download is now hosted on my Assembla workspace
« Last Edit: January 28, 2009, 11:25:13 AM by lightning » Logged

kdittyr
Brig.General
*****
Offline Offline

United States United States

Grant award..
Posts: 264



« Reply #6 on: February 14, 2008, 10:53:05 AM »

Awesome work, Lightning!  I can't wait to get home and play with this.  More beer !

I am working on a little project that will allow the user to easily create a keyfile for use in game.  This is being written in c# as well, so maybe I should post it here when I am done with it.  I have already written a version that works in php, though it is kind of dumb to have the tool online instead of on the persons home computer.  I will post updates on it in the near future.

Thanks again for your work, lightning, I find it cool as hell Smiley
« Last Edit: February 14, 2008, 10:58:31 AM by kdittyr » Logged

________________________
kdittyr -aka- "PoppaSmoke"

lightning
-=VP Donor=-
General
*
Offline Offline

United States United States

Awards:

Grant award..
Posts: 2126


Topic starter

WWW
« Reply #7 on: February 14, 2008, 11:26:12 AM »

I am working on a little project that will allow the user to easily create a keyfile for use in game.  This is being written in c# as well, so maybe I should post it here when I am done with it. 

I was going to write that exact thing today...so maybe I'll hold off on that for now!
Logged

bismond
General
******
Offline Offline

United States United States

Awards:

Grant award..
Posts: 502



« Reply #8 on: February 14, 2008, 12:52:39 PM »

.NET Gods. Reading, sipping coffee...
Logged

ttp://www.vusaf.org/
Ka-Bar03
- Mike -
Administrator
General
*****
Offline Offline

United States United States

Awards:

Grant award..
Posts: 5074



« Reply #9 on: February 14, 2008, 01:20:24 PM »

Bruce, you sure do read the paper a lot and drink mucho coffee  Reading, sipping coffee...  Tongue

anyone that can program this stuff is a god to me Hail master
Logged


Click Above for info
AiRdAncE
- Kim -
Administrator
General
*****
Offline Offline

Netherlands Netherlands

Awards:

Grant award..
Posts: 3955


Fly till I PUKE !


« Reply #10 on: February 14, 2008, 02:45:31 PM »

anyone that can program this stuff is a god to me Hail master
I second that Smiley
Logged
bismond
General
******
Offline Offline

United States United States

Awards:

Grant award..
Posts: 502



« Reply #11 on: February 14, 2008, 03:15:01 PM »

Mike,
       I figure if I sit around long enough  and do nothing the pit will build itself. GRROWNL !
Logged

ttp://www.vusaf.org/
Ka-Bar03
- Mike -
Administrator
General
*****
Offline Offline

United States United States

Awards:

Grant award..
Posts: 5074



« Reply #12 on: February 14, 2008, 04:06:43 PM »

If that were the case I would have a dozen Cool

Mike,
       I figure if I sit around long enough  and do nothing the pit will build itself. GRROWNL !
Logged


Click Above for info
Jarrod66
-=VP Donor=-
General
*
Offline Offline

United States United States

Awards:

Grant award..
Posts: 709



« Reply #13 on: February 14, 2008, 06:46:52 PM »

We have to use a gazillion log in screens and accounts to get to one application at work.  I have a macro setup on my PC that lets me just do one click and it does everything else.  Is that kind of what you guys are doing?  I had thought about using a macro that would start up my F4IM, Falcon, G15 Viper, FalconGauges etc.... at one click of a button and that would take some of the PITA out of firing everything up to get in a sortie.....that is if I can make it work....
Logged
Ka-Bar03
- Mike -
Administrator
General
*****
Offline Offline

United States United States

Awards:

Grant award..
Posts: 5074



« Reply #14 on: February 14, 2008, 07:03:49 PM »

that is a hell of an idea and like it. Seems the more neat useful items that are available to us, the more we will be doing this type of program startup fiascos

We have to use a gazillion log in screens and accounts to get to one application at work.  I have a macro setup on my PC that lets me just do one click and it does everything else.  Is that kind of what you guys are doing?  I had thought about using a macro that would start up my F4IM, Falcon, G15 Viper, FalconGauges etc.... at one click of a button and that would take some of the PITA out of firing everything up to get in a sortie.....that is if I can make it work....
Logged


Click Above for info
Pages: [1] 2 3 ... 6   Go Up
  Add bookmark  |  Print  
 
Jump to:  

Your local time
VP Time
19:38 UTC
September 03,2010
Today's Birthdays
Members
Total Members: 2374
Latest: bjviper
Stats
Total Posts: 79163
Total Topics: 5545
Online Today: 20
Online Ever: 459
(November 02, 2009, 09:46:32 PM)
Users Online
Users: 6
Guests: 14
Total: 20
Top 10 Posters
Ka-Bar03 (5074)
AiRdAncE (3955)
Crease-Guard (2725)
Nigel (2387)
Red Dog (2330)
Kneeling Warrior (2326)
Nikolas_A (2148)
lightning (2126)
101-Douxx (2024)
Flareless (1708)
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!
Page created in 0.262 seconds with 34 queries.