Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #5073 > unrolled thread

A few questions about inter program communication

Started byMartin <spam@spam.spam>
First post2013-04-17 12:41 +0100
Last post2013-04-18 03:19 -0700
Articles 4 — 3 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  A few questions about inter program communication Martin <spam@spam.spam> - 2013-04-17 12:41 +0100
    Re: A few questions about inter program communication dlzc <dlzc1@cox.net> - 2013-04-17 07:05 -0700
      Re: A few questions about inter program communication Martin <spam@spam.spam> - 2013-04-18 09:40 +0100
    Re: A few questions about inter program communication Mathias <mathias.hakansson@consultec.se> - 2013-04-18 03:19 -0700

#5073 — A few questions about inter program communication

FromMartin <spam@spam.spam>
Date2013-04-17 12:41 +0100
SubjectA few questions about inter program communication
Message-ID<qTvbt.10678$bp1.2457@fx23.fr7>
We currently have a bar code system where the scanning and reading is 
carried out on the same executable.

I want to now move to a VO processing engine, receiving data from small 
scanning programs about the factory.

The processor cannot sit there full on all the time, it will need to 
enter a sleep mode, how can I kick it out of sleep mode when it is not 
polling.

Polling I have doen before with a DBF, but am open to better ideas.

Thanks

Martin

[toc] | [next] | [standalone]


#5075

Fromdlzc <dlzc1@cox.net>
Date2013-04-17 07:05 -0700
Message-ID<98c702ae-991a-4366-adff-0316e422df7b@googlegroups.com>
In reply to#5073
Dear Martin:

On Wednesday, April 17, 2013 4:41:22 AM UTC-7, Martin wrote:
...
> We currently have a bar code system where the
> scanning and reading is carried out on the
> same executable.
> 
> I want to now move to a VO processing engine,
> receiving data from small scanning programs
> about the factory.

They all have local network access?

> The processor cannot sit there full on all
> the time, it will need to enter a sleep mode,
> how can I kick it out of sleep mode when it
> is not polling.
> 
> Polling I have doen before with a DBF, but
> am open to better ideas.

Some options

Let the distributed scanner applications, write to a common transaction database.  You poll the database as you already know how to do.

Let the distributed scanner applications communicate with a central server application, via UDP peer-to-peer.  The server application makes the appropriate database entries, or is your monitor application.

This may not be the mot appropriate link, but there are many UDP-based posts here in this newsgroup:
https://groups.google.com/d/msg/comp.lang.clipper.visual-objects/tJpUpsn50UA/1fplOgS_mhAJ

David A. Smith

[toc] | [prev] | [next] | [standalone]


#5081

FromMartin <spam@spam.spam>
Date2013-04-18 09:40 +0100
Message-ID<JjObt.15456$ZX4.4548@fx08.fr7>
In reply to#5075
Polling does work, but I want instant responce from the processing 
engine, rather than find it at its longest wait time for polling, 
constant polling is a waste and does slow down systems.

Anyway I will investigate UDP it looks like what I need.

Thanks

Martin

On 17/04/2013 15:05, dlzc wrote:
> Dear Martin:
>
> On Wednesday, April 17, 2013 4:41:22 AM UTC-7, Martin wrote:
> ...
>> We currently have a bar code system where the
>> scanning and reading is carried out on the
>> same executable.
>>
>> I want to now move to a VO processing engine,
>> receiving data from small scanning programs
>> about the factory.
>
> They all have local network access?
>
>> The processor cannot sit there full on all
>> the time, it will need to enter a sleep mode,
>> how can I kick it out of sleep mode when it
>> is not polling.
>>
>> Polling I have doen before with a DBF, but
>> am open to better ideas.
>
> Some options
>
> Let the distributed scanner applications, write to a common transaction database.  You poll the database as you already know how to do.
>
> Let the distributed scanner applications communicate with a central server application, via UDP peer-to-peer.  The server application makes the appropriate database entries, or is your monitor application.
>
> This may not be the mot appropriate link, but there are many UDP-based posts here in this newsgroup:
> https://groups.google.com/d/msg/comp.lang.clipper.visual-objects/tJpUpsn50UA/1fplOgS_mhAJ
>
> David A. Smith
>

[toc] | [prev] | [next] | [standalone]


#5083

FromMathias <mathias.hakansson@consultec.se>
Date2013-04-18 03:19 -0700
Message-ID<742b9b3f-f9df-4288-9f30-73cbb7025dcb@googlegroups.com>
In reply to#5073
If scanning and reading is done on the same machine you could send WM_COPYDATA message with all information to be transfered.

Some code is Sven Eberts...

/Mathias

Sending...
hwnd := FindWindow(psz("My ShellWindow class"),null_psz)
if !Empty(hwnd)
	SetForegroundWindow(hwnd)
			
	if !Empty(sFile)	// Send filename to other instance
		pS := StringAlloc(sFile)
				
		copydatastruct.lpData := dword(_cast,pS)
		copydatastruct.cbData := PszLen(pS) + 1
		copydatastruct.dwData := 0
		SendMessage(hWnd,WM_COPYDATA,0,long(_cast,@copydatastruct))
				MemFree(pS)
	endif
endif

Recieving...

method Init( oOwnerApp ) class StandardShellWindow
	local strucClientCreate is _WinClientCreateStruct

	SendClass(self,#Init,#AppWindow,oOwnerApp)

	if MyRegisterShellWindow(_GetInst())
		hWnd := CreateWindowEx(0,psz(_cast,__WCShellWindowClass),psz(_cast," "),_or(WS_OverlappedWindow,WS_CLIPCHILDREN),CW_USEDEFAULT,0,CW_USEDEFAULT,0,0,0,_GetInst(),ptrSelfPtr)
		strucClientCreate.idFirstChild := 0x8001

		hwndClient := CreateWindowEx(WS_EX_CLIENTEDGE,String2Psz("MDICLIENT"),null_ptr,_or(WS_CHILD,WS_CLIPCHILDREN,WS_CLIPSIBLINGS,MDIS_AllChildStyles),0,0,0,0,hWnd,0x2000,_GetInst(),@strucClientCreate)

		if (GetAppObject() != null_object)
			GetAppObject():SetMdiClientWindow(hwndClient)
		endif

		ShowWindow(hwndClient,SW_SHOW)
		SendMessage(hwndClient,WM_MDICASCADE,0,0)
	endif

	// The rest of the SSW:Init...

function MyRegisterShellWindow(hInst as ptr) as logic
 static local lretVal as logic
 local wc is _WINWNDCLASS


 //PP-031129 From S Ebert. Changed wc.hbrBackground
 //Otherwise under XP and theme suport on, you see a toolbar,
 //which is not a client of a rebar with a white background.
 //The reason for this is the transparency flag of toolbar which
 //is needed for XP. So you see the background color of the owner window.


 if !lretVal
  // 2.5c. REDRAW removed - lead to flicker!
  wc.style := CS_DBLCLKS //, CS_HREDRAW, CS_VREDRAW) //, CS_CLASSDC)
  wc.lpfnWndProc := ptr(_cast, @__WCShellWndProc())
  wc.hInstance := hInst
  wc.hIcon := LoadIcon(0, IDI_APPLICATION)
  wc.hCursor := LoadCursor(0, IDC_ARROW)
  wc.hbrBackground := (COLOR_3DFACE+1) //(COLOR_WINDOW + 1)
  wc.lpszClassName := psz(_cast,__WCShellWindowClass)
  wc.cbWndExtra := 12


  lretVal := (RegisterClass(@wc)!=0)
 endif


return lretVal

define __WCShellWindowClass := "My ShellWindow class"

method Dispatch(oEvent) class StandardShellWindow
	local pS				as psz
	local sFile				as string
	local copydatastruct	as _winCOPYDATASTRUCT
	
	do case
	case oEvent:message == WM_COPYDATA
			CopyDataStruct := ptr(_cast,oEvent:lParam)
			pS := ptr(_cast,CopyDataStruct.lpData)
			sFile := Psz2String(psz(_cast,CopyDataStruct.lpData))
			
	endcase
	
	return self:MDispatch(oEvent)

method MDispatch(oEvent) class StandardShellWindow
    //PP-040601 S.Ebert (WM_CONTEXTMENU)
    local oEvt := oEvent as @@Event
    local uMsg as dword
    local wParam as dword
    local wParamLow as dword
    local lParam as long
    local lRetVal as logic
    local lclient as logic
    local lHelpEnable as logic
    local hWndChild as ptr
    local hMDIChild as ptr
    local oDocApp as Window
    
    
    
    uMsg := oEvt:uMsg
    
    do case
    case (uMsg == WM_MENUSELECT) .or.;
            (uMsg == WM_INITMENU) .or.;
            (uMsg == WM_INITMENUPOPUP)
        
        hWndChild := ptr(_cast, SendMessage(hWndClient, WM_MDIGetActive, 0, 0))
        SendMessage(hWndChild, oEvt:uMsg, oEvt:wParam, oEvt:lParam)
        
    case uMsg == WM_COMMAND
        // If the WM_COMMAND is not a help message (id < 0xFFFD)
        // and not a WINDOW menu option (id >= MDI_FIRSTCHILDID)
        // process it.
        
        wParam := oEvt:wParam
        wParamLow := LoWord(wParam)
        
        if (wParamLow >= __WCMdiFirstChildID) //.and. wParamLow<ID_FirstSystemID
            if (wParamLow < ID_FIRSTWCHELPID)
                self:Default(oEvt)
                return self:EventReturnValue
            endif
        endif
        
        lParam := oEvt:lParam
        if (HiWord(wParam) <= 1) //accelerator or menu
            if !lHelpOn .or. !self:__HelpFilter(oEvt)
                if (wParamLow >= 0x0000F000)
                    self:Default(oEvt)
                    return self:EventReturnValue
                endif
                
                hWndChild := ptr(_cast,SendMessage(hWndClient,WM_MDIGetActive,0,0))
                
                if (hWndChild != 0)
                    SendMessage(hWndChild, WM_COMMAND, wParam, lParam)
                    return self:EventReturnValue //Assume child handled menu
                endif
            else
                super:Dispatch(oEvt)
                return self:EventReturnValue
            endif
        endif
        
    case (uMsg == WM_CREATE)
        // If this is a top app window
        // If not opened
        // Tag it open
        // Increment the window count
        if !lOpened
            lOpened := true
            if (GetAppObject() != null_object)
                GetAppObject():__WindowCount += 1
            endif
        endif
        
    case (uMsg == WM_SETCURSOR)
        if (oEvt:wParam) != (dword(_cast, hwndClient))
            lclient := false
        else
            lclient := true
        endif
        if lHelpOn
            if lhelpcursorOn
                lHelpEnable := true
            else
                lHelpEnable := false
            endif
        else
            lHelpEnable := false
        endif
        self:__HandlePointer(oEvt, lHelpCursorOn, lclient)
        return self:EventReturnValue
        
    case (uMsg == WM_WCHelp)
        self:__EnableHelpCursor(false)
        //SELF:HelpRequest(__ObjectCastClassPtr(oEvt, __pCHelpRequestEvent))
        self:HelpRequest(HelpRequestEvent{oEvt})
        return self:EventReturnValue
        
        // case uMsg == WM_NCLBUTTONDBLCLK
        
        /* if (CV_RunTime :: Event_wParam ( e ) == HTMENU )
        {
        dword dwActive=SendMessage(hwndClient,WM_MDIGETACTIVE, 0, 0);
            
        // if it is maximized, look if the click is inside the system menu
        
        if (HiWord(dwActive))
        {
        RECT rc;
            // use windows SDK functions for rectangle to avoid all
        // tricks with vertical coordinates
        
        ::GetWindowRect(hEContext,&rc);
            
        // Calculate system menu rectangle
        
        rc.left+=::GetSystemMetrics(SM_CXBORDER);
            rc.top+=(::GetSystemMetrics(SM_CYBORDER)+::GetSystemMetrics(SM_CYCAPTION));
            rc.right=rc.left+::GetSystemMetrics(SM_CXSIZE);
            rc.bottom=rc.top+::GetSystemMetrics(SM_CYSIZE);
            
        if (::PtInRect(&rc,MAKEPOINT(CV_RunTime :: Event_lParam( e ))))
        SendMessage(LoWord(dwActive),WM_SYSCOMMAND,SC_CLOSE,CV_RunTime :: Event_lParam( e ));
            }
        }
        Default(e);
            break;
            */
    case (uMsg == WM_QUERYENDSESSION) .or. (uMsg == WM_CLOSE)
        if (GetWindow(hWndClient,GW_CHILD) != 0)
            lRetVal := EnumChildWindows(hWndClient, @__WCQueryCloseEnumFunc(), 0)
            if !lRetVal
                return 0L
            endif
        endif
        
    case (uMsg == WM_SIZE)
        super:Dispatch(oEvt)
        if self:__AdjustClient()
            if IsClass(#OleObject)
                hMDIChild := ptr(_cast, SendMessage(self:Handle(4), WM_MDIGETACTIVE, 0, 0L))
                if (hMDIChild != null_ptr)
                    oDocApp := __WCGetWindowByHandle(hMDIChild)
                    if (IsInstanceOf(oDocApp, #__DocApp)) .and.;
                            (IsInstanceOf(oDocApp:owner, #DataWindow))
                        //PP-040915 Issue 12961
                        if IsMethod(oDocApp:Owner, #__UpdateActiveObject)
                            Send(oDocApp:Owner, #__UpdateActiveObject)
                        endif
                    endif
                endif
            endif
            return 0L
        endif
        return self:EventReturnValue
        
    case oEvt:uMsg == WM_CONTEXTMENU
        //In a Shellwindow this message becomes created in the MDIClient Window
        //and __WCGetWindowByHandle() returns a Null_Object in this case, so
        //shell contextmenu is not shown.
        if oEvt:wPARAM = dword(_cast, hWndClient)
            oEvt:wPARAM := dword(_cast, hWnd)
        endif
        
    endcase
    
    *super:Dispatch(oEvt)
    SendClass(self,#Dispatch,#AppWindow,oEvt)
    
    return self:EventReturnValue

/Mathias

Den onsdagen den 17:e april 2013 kl. 13:41:22 UTC+2 skrev Martin:
> We currently have a bar code system where the scanning and reading is 
> 
> carried out on the same executable.
> 
> 
> 
> I want to now move to a VO processing engine, receiving data from small 
> 
> scanning programs about the factory.
> 
> 
> 
> The processor cannot sit there full on all the time, it will need to 
> 
> enter a sleep mode, how can I kick it out of sleep mode when it is not 
> 
> polling.
> 
> 
> 
> Polling I have doen before with a DBF, but am open to better ideas.
> 
> 
> 
> Thanks
> 
> 
> 
> Martin

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web