Recent

Author Topic: Openwire in Lazarus?  (Read 23678 times)

bserviss

  • New member
  • *
  • Posts: 7
Openwire in Lazarus?
« on: March 20, 2011, 07:51:15 pm »
I have always been fascinated by NI LabView and ran across http://sourceforge.net/projects/openwireproject/ but had some major errors trying to install it in Lazarus. Many of them revolving around a missing property StateIndex of TTreeNodes.

Has anyone tried to install this library?

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Openwire in Lazarus?
« Reply #1 on: April 28, 2011, 11:12:40 pm »
In his initial effort author has mentioned that Lazarus needed patch 0014881 for OpenWire to work. I don't know current status since I use CodeTyphon 1.60 which comes with OpenWire prepackaged and ready for use. Components from OpenWire Help tutorial are in component pallete and ready to use. Component editors are buggy so you will end up with more manual coding then with Delphi, but OpenWire in general was usable in my 15 minutes initial test.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

CaptBill

  • Sr. Member
  • ****
  • Posts: 435
Re: Openwire in Lazarus?
« Reply #2 on: April 29, 2011, 01:40:05 am »
In his initial effort author has mentioned that Lazarus needed patch 0014881 for OpenWire to work. I don't know current status since I use CodeTyphon 1.60 which comes with OpenWire prepackaged and ready for use. Components from OpenWire Help tutorial are in component pallete and ready to use. Component editors are buggy so you will end up with more manual coding then with Delphi, but OpenWire in general was usable in my 15 minutes initial test.

Have you figured out how to load the Labview/Videolab/Audiolab component packages? Do the even exist for Lazarus yet?

Openwire looks very promising. Seems like this would be an ideal strategy for connecting Lazarus to the Arduino boards.

Would I be correct?

circular

  • Hero Member
  • *****
  • Posts: 4467
    • Personal webpage
Re: Openwire in Lazarus?
« Reply #3 on: April 29, 2011, 08:54:41 am »
Openwire seems to be very powerful. I wonder what can be done with it.
Conscience is the debugger of the mind

CaptBill

  • Sr. Member
  • ****
  • Posts: 435
Re: Openwire in Lazarus?
« Reply #4 on: April 29, 2011, 04:38:33 pm »
Openwire seems to be very powerful. I wonder what can be done with it.

I bet this would be an excellent framework to attach to BGRAbitmap. If my understanding is correct, the idea is to eliminate coding the connection/state changes/general housekeeping issues involved with data/state connections.

 Imagine for instance,a 'skinning engine' that exposes all the 'BGRAcontrols' pins in a breadboard style interface. The wires/pins we can use to make property editors for design time. Imagine having all the functionality in LazPaint available as a property editor! Drop a BGRAcomp on the form and double click and this opens a property based on LazPaint to design the actual graphic. We could have multiple editors for specific types of components. Say, BGRAgradientpanel, BGRAphongButton, BGRAshapepanel, each with a specialized editor. Plus we handle the size/proportions/naming conventions etc. etc.. Maybe we store it all in in res. file that has its own 'breadboard' interface.

 Once we have that set up we have a simplified framework to base the CLIENT components on. I say 'we' as in the whole Lazarus community can now build the client components based upon the pre-configured 'breadboard' arrangement. Now we have a back-end framework to greatly simplify making of 'front-end' components. Then we can even start thinking of a visual designer. Something along the line of Grasshopper for Rhino (really cool graphical 'visual scripter', look at this to understand what is possible with Openwire).

https://lh4.googleusercontent.com/_pttOwurJ_ak/TbrK_HN5NpI/AAAAAAAAArc/R6Ro-el32gA/s640/Grasshopper1.jpg

https://lh4.googleusercontent.com/_pttOwurJ_ak/TQQ8jfDaNVI/AAAAAAAAAhU/ty7X7gOR6HI/s640/ggrid.jpg



circular

  • Hero Member
  • *****
  • Posts: 4467
    • Personal webpage
Re: Openwire in Lazarus?
« Reply #5 on: April 29, 2011, 04:51:19 pm »
Do you mean to make a 2D image generator with graphical editing embedded in Lazarus ?
Conscience is the debugger of the mind

CaptBill

  • Sr. Member
  • ****
  • Posts: 435
Re: Openwire in Lazarus?
« Reply #6 on: April 29, 2011, 05:36:37 pm »
Do you mean to make a 2D image generator with graphical editing embedded in Lazarus ?

Hi Circular,
Yeah, that is one way of putting it. We build some base components which utilize BGRAbitmap extensively. The components could have their own property editor for design time. Double click the component (or open via property inspector) and up pops a custom property editor.

Example:
BGRAbutton- uses three bgrabitmaps for each state (up,down,disabled). Our editor helps us create all three bitmaps together and set all necessary properties. Plus it should expose the necessary 'pins', just like a physical button does. Now we can simply plug it into whatever we need to.

Also we could save the end result into a database table as a 'skin interface' or just to reuse in the other buttons on our form(or any future form)

These are just some of my brainstorming ideas....and I would'nt call myself a programmer,yet HAHA! More like an end-user hoping to find the simplest route to the action.

circular

  • Hero Member
  • *****
  • Posts: 4467
    • Personal webpage
Re: Openwire in Lazarus?
« Reply #7 on: April 29, 2011, 05:44:36 pm »
Ok, so if I sumarize you are talking of two things :
- one is making BGRA interface components, like Dibo started to do
- second is to make BGRA "logical" components to plug with OpenWire, and to add plugs for interface components too.

It's a good idea, if someone has the time to do this of course. I was also thinking about creating an easy scripting language for LazPaint.

But first, I will have a look at openwire with CodeTyphon...
Conscience is the debugger of the mind

CaptBill

  • Sr. Member
  • ****
  • Posts: 435
Re: Openwire in Lazarus?
« Reply #8 on: April 29, 2011, 06:18:38 pm »
Ok, so if I sumarize you are talking of two things :
- one is making BGRA interface components, like Dibo started to do
- second is to make BGRA "logical" components to plug with OpenWire, and to add plugs for interface components too.

It's a good idea, if someone has the time to do this of course. I was also thinking about creating an easy scripting language for LazPaint.

But first, I will have a look at openwire with CodeTyphon...

The scripting idea would be awesome.  Grasshopper has a VB scripting component that would be worth taking a look at. What it is doing is making a visual representation of a Function header with input variables and output variables, and vbscript in between. The standard components then can be 'wired' by simply dragging a source pin to a sink pin.

https://lh6.googleusercontent.com/_pttOwurJ_ak/TbrjnXJa8NI/AAAAAAAAArk/ezGL88j6m0c/s640/Script.jpg

The idea is to be able to 'wrap' around a method/function. Then us newbies can build 'component-ized methods' which would be simpler than building full-blown components.

The whole idea here is to allow the end-users (like myself) free you to do the heavy duty back-end programming.

Great work with BGRA, btw. Really nice work.


circular

  • Hero Member
  • *****
  • Posts: 4467
    • Personal webpage
Re: Openwire in Lazarus?
« Reply #9 on: April 29, 2011, 06:22:08 pm »
Thanks.

Well, I was not thinking about graphical scripting, just a script language that would be easy to understand for a non programmer.
Conscience is the debugger of the mind

CaptBill

  • Sr. Member
  • ****
  • Posts: 435
Re: Openwire in Lazarus?
« Reply #10 on: April 29, 2011, 06:39:08 pm »
Thanks.

Well, I was not thinking about graphical scripting, just a script language that would be easy to understand for a non programmer.

I was playing around with the concept of a component for BGRAbitmap using CompCreate which will give you an idea of what I am thinking. This is just a start with no properties exposed. That will be done with OpenWire, is the idea anyway. Idea is to eventually have a property editor to to design 'layers' over a base image. (grid layer, lines layer, etc.) Hopefully something like this could serve as a base component for the concept.(when finished) Have a look if you have a minute..

Quote
{ ****************************************************************** }
{                                                                    }
{   VCL component TMyClass                                           }
{                                                                    }
{   Code generated by Component Create for Delphi                    }
{                                                                    }
{   Generated from source file c:\codetyphoon16\codetyphon\hiphiproject\compcreate1.cd }
{   on 28 April 2011 at 14:18                                        }
{                                                                    }
{   A public domain component by the Ark Project                     }
{                                                                    }
{ ****************************************************************** }

unit MyUnit;

interface

uses WinTypes, WinProcs, Messages, SysUtils, Classes, Controls,
     Forms, Graphics, Extctrls;

type
  TMyClass = class(TPanel)
    private
      { Private fields of TMyClass }
        BGRABiasDivider : BGRABitmap;
        BGRAGridX : BGRAbitmap;
        BGRAGridY : BGRABitmap;
        BGRAHorizRuler : BGRAbitmap;
        BGRALinesX : BGRABitmap;
        BGRALinesY : BGRABitmap;
        BGRAVertRuler : BGRAbitmap;
        PnlMain : TPanel;

      { Private methods of TMyClass }
        { Method to set variable and property values and create objects }
        procedure AutoInitialize;
        { Method to free any objects created by AutoInitialize }
        procedure AutoDestroy;
        function GetFileBackground : TBitmap;
        procedure SetFileBackground(Value : TBitmap);
        function GetX_it : Integer;
        procedure SetX_it(Value : Integer);

    protected
      { Protected fields of TMyClass }
        BGRABackground : BGRAbitmap;
        PhiX : THiPhi;
        PhiY : THiPhi;

      { Protected methods of TMyClass }
        procedure Click; override;
        procedure KeyPress(var Key : Char); override;
        procedure Loaded; override;
        procedure Paint; override;

    public
      { Public fields and properties of TMyClass }

      { Public methods of TMyClass }
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;

    published
      { Published properties of TMyClass }
        property OnClick;
        property OnDblClick;
        property OnDragDrop;
        property OnEnter;
        property OnExit;
        property OnKeyDown;
        property OnKeyPress;
        property OnKeyUp;
        property OnMouseDown;
        property OnMouseMove;
        property OnMouseUp;
        property OnResize;
        property FileBackground : TBitmap
             read GetFileBackground write SetFileBackground;
        property X_it : Integer read GetX_it write SetX_it;

  end;

procedure Register;

implementation

procedure Register;
begin
     { Register TMyClass with Standard as its
       default page on the Delphi component palette }
     RegisterComponents('Standard', [TMyClass]);
end;

{ Method to set variable and property values and create objects }
procedure TMyClass.AutoInitialize;
begin
     BGRABackground := BGRAbitmap.Create(Self);
     BGRABackground.Parent := Self;
     with BGRABackground do
          begin
          { Left := }
          {  Top := }
           Width := 640;
           Height := 200;
         
          Visible := True;
          end;
     BGRABiasDivider := BGRABitmap.Create(Self);
     BGRABiasDivider.Parent := Self;
     BGRAGridX := BGRAbitmap.Create(Self);
     BGRAGridX.Parent := Self;
     BGRAGridY := BGRABitmap.Create(Self);
     BGRAGridY.Parent := Self;
     BGRAHorizRuler := BGRAbitmap.Create(Self);
     BGRAHorizRuler.Parent := Self;
     BGRALinesX := BGRABitmap.Create(Self);
     BGRALinesX.Parent := Self;
     BGRALinesY := BGRABitmap.Create(Self);
     BGRALinesY.Parent := Self;
     BGRAVertRuler := BGRAbitmap.Create(Self);
     BGRAVertRuler.Parent := Self;
     PhiX := THiPhi.Create;
     PhiY := THiPhi.Create;
     PnlMain := TPanel.Create;
     with PnlMain do
          begin
          { Left := }
          { Top := }
           Width := 640;
           Height := 200;
         
          Visible := True
          end;
end; { of AutoInitialize }

{ Method to free any objects created by AutoInitialize }
procedure TMyClass.AutoDestroy;
begin
     BGRABackground.Free;
     BGRABiasDivider.Free;
     BGRAGridX.Free;
     BGRAGridY.Free;
     BGRAHorizRuler.Free;
     BGRALinesX.Free;
     BGRALinesY.Free;
     BGRAVertRuler.Free;
     PhiX.Free;
     PhiY.Free;
     PnlMain.Free;
end; { of AutoDestroy }

function TMyClass.GetFileBackground : TBitmap;
begin
     { Return the BGRABackground.Tbitmapfile property }
     Result := BGRABackground.Tbitmapfile;
end;

procedure TMyClass.SetFileBackground(Value : TBitmap);
begin
     { Set the BGRABackground.Tbitmapfile property }
     BGRABackground.Tbitmapfile := Value;
end;

function TMyClass.GetX_it : Integer;
begin
     { Return the BGRAGridX.GridX_it property }
     Result := BGRAGridX.GridX_it;
end;

procedure TMyClass.SetX_it(Value : Integer);
begin
     { Set the BGRAGridX.GridX_it property }
     BGRAGridX.GridX_it := Value;
end;

{ Override OnClick handler from TPanel }
procedure TMyClass.Click;
begin
     { Call method of parent class }
     inherited Click;
end;

{ Override OnKeyPress handler from TPanel }
procedure TMyClass.KeyPress(var Key : Char);
begin
     { Call method of parent class }
     inherited KeyPress(Key);
end;

constructor TMyClass.Create(AOwner: TComponent);
begin
     inherited Create(AOwner);
     AutoInitialize;

     { Code to perform other tasks when the component is created }

end;

destructor TMyClass.Destroy;
begin
     AutoDestroy;
     inherited Destroy;
end;

procedure TMyClass.Loaded;
begin
     inherited Loaded;

     { Perform any component setup that depends on the property
       values having been set }

end;

procedure TMyClass.Paint;
begin
     { Make this component look like its parent component by calling
       its parent's Paint method. }
     inherited Paint;

     { To change the appearance of the component, use the methods
       supplied by the component's Canvas property (which is of
       type TCanvas).  For example, }

     { Canvas.Rectangle(0, 0, Width, Height); }
end;


end.

circular

  • Hero Member
  • *****
  • Posts: 4467
    • Personal webpage
Re: Openwire in Lazarus?
« Reply #11 on: April 29, 2011, 10:30:28 pm »
Hmm... Some things are not correct.

Field declarations should be "... : TBGRABitmap"

I'm not sure what it means, but I suppose Filebackground should be a TBGRABitmap instead of TBitmap and use Assign and Duplicate methods.
Conscience is the debugger of the mind

CaptBill

  • Sr. Member
  • ****
  • Posts: 435
Re: Openwire in Lazarus?
« Reply #12 on: April 30, 2011, 01:39:13 am »
Hmm... Some things are not correct.

Field declarations should be "... : TBGRABitmap"

I'm not sure what it means, but I suppose Filebackground should be a TBGRABitmap instead of TBitmap and use Assign and Duplicate methods.


This is the output from a little program called CompCreate which is a component designer app. This is only a beginning framework of a component with multiple layers.

The idea is now to set up the Openwire pins in the public section. For instance the background could have have, say, 6 pins: 1)R 2)G 3)B 4)alpha 5)GradientStyle 6)Color2
And the THiPhi variables are holding scale values from the Fibonacci sequence. Idea is to pick positions from a scale of, say, 12 values from the 'Divine Proportion' or 'Golden Section' instead of ALL points within a range. This variable will have a pin for X and Y values picked from a list of the 12 values.

Also the THiphi can be used to make the ultimate color picker. Instead of just picking colors from all the possible ones available, we use the Golden Section to preselect colors that are 'harmonized' to color theory concepts.

Check THIS color picker out....

http://goldennumber.net/images/palette.gif

This will build color 'swatches' of colors decided from color theory concepts. Much better than just picking from the vast array of colors available.



This setup should allow us to simply connect 1,2,3,4 to a pin enabled slider, for instance, with no other coding. Plug and go.

In fact, this component will probably have LOTS of pins. But with it we should be able to easily 'rig' these up into any configuration we need without lots of coding all the events etc.

Please forgive the typos. It is just the beginnings of an outline so far. I haven't attempted to compile it yet(that is how I do spell checking, HAHA). I actually need to register the TBGRAbitmap into CompCreate yet.

circular

  • Hero Member
  • *****
  • Posts: 4467
    • Personal webpage
Re: Openwire in Lazarus?
« Reply #13 on: April 30, 2011, 09:14:48 am »
If you come up with something, please tell us.

Well, I've tried OpenWire with CodeTyphon, but it was buggy. When there was more than 3 components, it would not work correctly anymore.
Conscience is the debugger of the mind

CaptBill

  • Sr. Member
  • ****
  • Posts: 435
Re: Openwire in Lazarus?
« Reply #14 on: April 30, 2011, 05:49:21 pm »
If you come up with something, please tell us.

Well, I've tried OpenWire with CodeTyphon, but it was buggy. When there was more than 3 components, it would not work correctly anymore.

You know what, after seeing what OpenWire actually does I realized that CompCreate can do the same basically. How it is implemented in CompCreate vs Openwire is completely different, however. OpenWire is library of code vs CompCreate which is merely a code generator. I can do the same with CompCreate by simply using the menu item 'add data link'. What it does is, based on a dialog, is create all the methods and functions pertinent to a datalink connection,with comments on what to do. No other libraries, which may as well be a black box to me. This way is perfect for newbies because then we can start to see what is happening,yet still be working from a set plan. Actually, the 'add datalink' is strictly for a data aware components, but it should be easy enough to add this functionality for other components.

I personally am liking the CompCreate approach . The events and code blocks will need coding individually, but there is no third party in between us this way. Plus for a newbie like myself it makes things much easier to 'put it all together', and keep focus and be working from a framework. Simply the commenting out of the canned method blocks is great for understanding what is happening. Also it seems to to impart no limitations like a library does, that I can tell.

What may be the best approach is to simply add a menu function 'menu/add openwire connection' within CompCreate. Best of both worlds.

Once I can get my tools all in order here I hope to put together a 'shell' component wrapping up some of the basic functionality.

Thanks for all your input. I hope to have something in a few days of interest.



Quote
CompCreate Help
Edit | Add data link
Data link properties

When you select this menu item, you will first be asked whether you wish to add a data link that is read-only (for database browsing) or read-write (for database editing).  You will then choose the names for the data link object and for the data source and data field properties associated with the data link.  If the data link you are adding is the first one in the component, you will see "DataSource" and "DataField" supplied as the default property names. 

Data link event handlers

You will also choose the names for the method or methods that will act as event handlers for the data link.  Default method names will be provided.  If a method does not already exist, Component Create will generate it. 

If the data link is read-write, it will have event handling methods for OnDataChange, OnUpdateData, OnEditingChange, and OnActiveChange.  If the data link is read-only, it will have only an OnDataChange event handler. 

These events are not events of your component, but events of the data link object that are handled within your component.  For example, when the data in a field changes, the data link object fires an OnDataChange event.  The method that you specify will be called in response to this event, where it presumably will change the appearance of your component (e.g., the Caption property of a label component).

After you add the data link, you make your component interact with it by adding code to the method or methods that the Edit | Add data link menu item generated.  Comments in the methods explain what to do depending on the nature of your component.

You can add multiple data links by using the Edit | Add data link menu item more than once.  A method can act as the event handler for more than one data link.

Data link methods

If you have added a read-write data link, you will also need to add references in your component to methods of the data link object.  Wherever your component code may change the property or properties that correspond to the data field (e.g., the Text property of a data-aware edit box), you need to call the data link's Edit method beforehand to put the data link into editing mode and call its Modified method afterward to signal a change.  For example, if the data link is named FDataLink, you would write:

FDataLink.Edit;
CodeToUpdateTheComponent;
FDataLink.Modified;

A data link object also has an UpdateRecord method that your component should call when it loses the focus (normally in its OnExit handler).

Data links are objects of type TFieldDataLink, which is declared by the Visual Component Library in Dbtables.pas.

For examples of code for data-aware components, see VCL source code file Dbctrls.pas and Component Create sample files Multfld.cd (label that links with multiple fields of a data source) and Dbunedit.cd (data-aware edit control with undo).

Data field property editors

Normally, Delphi's Object Inspector provides a drop-down field list only for data field properties named "DataField" associated with a data source property named "DataSource."  If the data field or data source property has another name, the developer must type the field name.  To allow the developer to see a drop-down list of fields in the Object Inspector for a data field property with another name, component writers developing components with multiple data links need to register a custom property editor for each such data field property.

To do so, select the data field property (whatever its name) on the Properties page and press the ">>>" button.  Enter a property editor unit and class name.  Then, generate the property editor unit with the Generate | Property editors menu item.  Select "Drop-down list of data field names" as the property editor type.

If your component's data source property has a name other than "DataSource," you will also need to edit the DataSourcePropName constant in the GetValues method of the generated property editor class.

 

TinyPortal © 2005-2018