Where have I gone wrong
Re: Where have I gone wrong
The separate exe are add on modules to enhance the PoS program.
So far in my vb PoS I have
> card processing
> loyalty
> Gift card
Doing it this way I do not have to re compile the program each time I have to change something
So far in my vb PoS I have
> card processing
> loyalty
> Gift card
Doing it this way I do not have to re compile the program each time I have to change something
-
- Posts: 862
- Joined: May 05, 2015 5:35
- Location: Germany
Re: Where have I gone wrong
So they're all clients? What about the server? Could you give me a short description of your intranet?Gablea wrote:The separate exe are add on modules to enhance the PoS program.
Alas, libcurl is only a client library and not suitable for servers. But there's another library named TSNE_V3, for both Windows and Linux, completely written in FB by ThePuppetMaster. I've tested it just now, and it works fine here (as server and as client, even on one single machine).
Re: Where have I gone wrong
@grindstone,
a really bad idea, to advice on a library, that is non-free, for commercial use:
Also, due to it's age, probably only FBC32 (referres version 0.18.5 of compiler)?!?
EDIT: it's been updated 2016 -- compiler ver. 1.05.0
a really bad idea, to advice on a library, that is non-free, for commercial use:
, in the header of TSNE_V3.bi ...' Free for NON-comercial use! For comercial usage send me a mail -> FreeBasic[at]DeltaLabs.de
Also, due to it's age, probably only FBC32 (referres version 0.18.5 of compiler)?!?
EDIT: it's been updated 2016 -- compiler ver. 1.05.0
#Define TSNE_VersionFull 3.8_20160406 (0.18.5 -> 1.05.0)(L32,L64)
-
- Posts: 862
- Joined: May 05, 2015 5:35
- Location: Germany
Re: Where have I gone wrong
@MrSwiss:
The complete sentence reads:
The complete sentence reads:
So it should be no problem to get the permission to use this library. It's Gablea's decision, but from my point of view it's the best solution as long as there's no need for SSL.Free for NON-comercial use! For comercial usage send me a mail -> FreeBasic[at]DeltaLabs.de or IRC and u get a free usage
Re: Where have I gone wrong
@grindstone
The Modules i think would be servers as they serve to provide a link between the PoS terminals and for example the IPP350 Chip&Pin Device.
The Gift card add one would link into a MySQL database (what i want to do at some point with my Till software for Linux but can not do it with DOS :()
I know I have a LOT to figure out and design (think I have become a bit lazy thanks to VB.NET and windows) but once I get things sorted I am sure I would have a great product to show off what FreeBASIC can do
The Modules i think would be servers as they serve to provide a link between the PoS terminals and for example the IPP350 Chip&Pin Device.
The Gift card add one would link into a MySQL database (what i want to do at some point with my Till software for Linux but can not do it with DOS :()
I know I have a LOT to figure out and design (think I have become a bit lazy thanks to VB.NET and windows) but once I get things sorted I am sure I would have a great product to show off what FreeBASIC can do
Re: Where have I gone wrong
@jj2007
Hi JJ just a quick question how would I make a in memory array so I could add and delete from it as the sale is in progress? (I’m thinking I could use the array to populate the till receipt)
In my windows version I’m using a in memory data table to just that. So if I could replicate the same function I would be well happy.
Hi JJ just a quick question how would I make a in memory array so I could add and delete from it as the sale is in progress? (I’m thinking I could use the array to populate the till receipt)
In my windows version I’m using a in memory data table to just that. So if I could replicate the same function I would be well happy.
Re: Where have I gone wrong
No idea. Probably you can just add or delete strings to/from the Products() array. What does the manual say?Gablea wrote:Hi JJ just a quick question how would I make a in memory array so I could add and delete from it as the sale is in progress? (I’m thinking I could use the array to populate the till receipt)
-
- Posts: 862
- Joined: May 05, 2015 5:35
- Location: Germany
Re: Where have I gone wrong
Only for curiosity: What is a "Gift card"?
Re: Where have I gone wrong
It’s a pre paid card that stores sell with a value on it (for example £20) and the person that was given the card can spend the money on it just like a normal card (most times the customer who has the gift card spends more then what the card has on it)
Also the store would get the £20 first before they issue the gift card.
Also the store would get the £20 first before they issue the gift card.
-
- Posts: 862
- Joined: May 05, 2015 5:35
- Location: Germany
Re: Where have I gone wrong
Alright, and I suppose what you call "modules" are little programs running simultaneously on one computer, and you want them to communicate with one another and with the tills via TCP, right?
Re: Where have I gone wrong
Yes that is correct. Each module is a exe in its own right that would use local tcp ports to talk to the main till program (would the till program be the server or the client)
-
- Posts: 862
- Joined: May 05, 2015 5:35
- Location: Germany
Re: Where have I gone wrong
Slowly the picture becomes clearer. :-)
Next question: What about the network connection of the tills? I suppose every till has its own computer with a network card (or a built-in network chip) and thus its own IP address. How is that IP adress determined (dynamic or static)? And what are the tills connected to? A router or a switch?
BTW: Normally the till program is the server, all others are clients.
Next question: What about the network connection of the tills? I suppose every till has its own computer with a network card (or a built-in network chip) and thus its own IP address. How is that IP adress determined (dynamic or static)? And what are the tills connected to? A router or a switch?
BTW: Normally the till program is the server, all others are clients.
Re: Where have I gone wrong
Each till is a computer in its own right. They all have network cards and each till have static IP.
The tills are all connected to a fast switch the tills all use the full 100MB network connection.
And thanks for clearing up the thing about the tills being the server.
I wish I could work out how to access the MySQL database as easily as I do in VB.net then I would not have to worry about creating data tables or data files I could access the data directly from the server. (But even try I have done has not gone very well)
The tills are all connected to a fast switch the tills all use the full 100MB network connection.
And thanks for clearing up the thing about the tills being the server.
I wish I could work out how to access the MySQL database as easily as I do in VB.net then I would not have to worry about creating data tables or data files I could access the data directly from the server. (But even try I have done has not gone very well)
-
- Posts: 862
- Joined: May 05, 2015 5:35
- Location: Germany
Re: Where have I gone wrong
Sorry, I'm afraid there's a misunderstanding. What I meant to act as server is the main control program running on the mainframe. Any other part of the system that wants to send or receive something sends a request to the server, and the server executes and organizes that communication. That means every till is a client.Gablea wrote:And thanks for clearing up the thing about the tills being the server.
That doesn't mean that you can't implement a server on each till, too, but at the moment I can't see any use in doing so.
I don't know the features of the single devices of your system, but in coarse you can say: Every device that's waiting for a connection request after power-up is a server, and every device that's actively trying to get connected to another device after power-up is a client.
-
- Posts: 862
- Joined: May 05, 2015 5:35
- Location: Germany
Re: Where have I gone wrong
A first hazy notion of a fileserver/-client (the TSNE_V3.bi can be found here, either copy & paste the source code or click at "Dateidownload"):
Server:
Client:
Server:
Code: Select all
#Include Once "TSNE_V3.bi"
Type Client_Type
V_InUse As UByte
V_TSNEID As UInteger
V_IPA As String
V_Data As String
End Type
Dim Shared ClientD() As Client_Type
Dim Shared ClientCount As UInteger
Dim Shared ClientMutex As Any Ptr
Dim G_Server_TSNEID As UInteger
Dim RV As Integer
Dim Shared As UInteger globalTSNEID
Function parse(text As String = "", separator As String = "") As String
Static As String s, t, r
Static As Integer b, e
If separator = Chr(0) Then 'return the rest of the text
r = Mid(t, e + 1)
e = Len(t)
Return r
ElseIf Len(separator) Then
s = separator
EndIf
If Len(text) Then 'new text
t = text
e = 0 'pointer to beginning
EndIf
b = e + 1 'pointer behind last word
Do While InStr(s, Mid(t, b, Len(s))) 'seek next beginning of word
If b >= Len(t) Then
Return ""
EndIf
b += Len(s)
Loop
e = b
Do
'If Mid(t, e, 1) = """" Then 'quotation marks
' Do 'seek end of the quoted text
' e += 1
' If e > Len(t) Then 'text ended
' Exit Do, Do
' EndIf
' Loop Until Mid(t, e, 1) = """"
'EndIf
e += 1
If e > Len(t) Then 'text ended
Exit Do
EndIf
Loop Until InStr(s, Mid(t, e, Len(s))) 'found separator
e -= 1 'set pointer in front of separator
r = Mid(t, b, e - b + 1) 'cut text
Return r
End Function
Sub TSNE_Disconnected(ByVal V_TSNEID As UInteger)
Print "[Disconnected] TSNEID: "; V_TSNEID
MutexLock(ClientMutex)
For X As UInteger = 1 To ClientCount
If ClientD(X).V_InUse = 1 Then
If ClientD(X).V_TSNEID = V_TSNEID Then
ClientD(X).V_InUse = 0
Exit For
End If
End If
Next
MutexUnLock(ClientMutex)
End Sub
Sub TSNE_Connected(ByVal V_TSNEID As UInteger)
Print "[Connected] TSNEID: "; V_TSNEID
End Sub
Sub TSNE_NewData(ByVal V_TSNEID As UInteger, ByRef V_Data As String)
Dim As Integer RV, ff
Dim As String fi, g, request
Print "[NewData] TSNEID: "; V_TSNEID; " Datenlänge: "; Len(V_Data)
request = parse(V_DATA, Chr(13, 10))
Select Case LCase(request)
Case "sendfile" 'client requests a file
fi = parse() 'get file name
ff = FreeFile
If Open (fi For Binary Access Read As #ff) Then
RV = TSNE_Data_Send(V_TSNEID, "nosuchfile " & fi & Chr(13,10) & "0 Bytes" & Chr(13,10))
Else 'send file
'response header
RV = TSNE_Data_Send(V_TSNEID, _
"requestedfile " & fi & Chr(13,10) & _
Lof(ff) & " Bytes" & Chr(13,10))
If RV <> TSNE_Const_NoError Then
Print "[ERROR] " & TSNE_GetGURUCode(RV)
Close ff
Exit Sub
End If
Do Until Eof(ff) 'send file data
g = Input(1024, ff)
RV = TSNE_Data_Send(V_TSNEID, g)
If RV <> TSNE_Const_NoError Then
Print "[ERROR] " & TSNE_GetGURUCode(RV)
Close ff
Exit Sub
End If
Loop
Close ff
EndIf
End Select
End Sub
Sub TSNE_NewConnection(ByVal V_TSNEID As UInteger, ByVal V_RequestID As Socket, ByVal V_IPA As String)
Dim CIndex As UInteger
Dim RV As Integer
Dim NewTSNEID As UInteger
Dim TCUDT As Client_Type
MutexLock(ClientMutex)
For X As UInteger = 1 To ClientCount
If ClientD(X).V_InUse = 0 Then CIndex = X: Exit For
Next
If CIndex = 0 Then
If ClientCount = 250 Then
RV = TSNE_Create_Accept(V_RequestID, NewTSNEID, , 0, 0, 0)
If NewTSNEID = 0 Then TSNE_Disconnect(NewTSNEID)
Exit Sub
End If
ClientCount += 1
CIndex = ClientCount
ReDim Preserve ClientD(ClientCount) As CLient_Type
End If
ClientD(CIndex) = TCUDT
RV = TSNE_Create_Accept(V_RequestID, NewTSNEID, , @TSNE_Disconnected, @TSNE_Connected, @TSNE_NewData)
globalTSNEID = NewTSNEID
With ClientD(CIndex)
.V_InUse = 1
.V_TSNEID = NewTSNEID
.V_IPA = V_IPA
If RV <> TSNE_Const_NoError Then
MutexUnlock(ClientMutex)
Print "[ACCEPT] [ERROR] " & TSNE_GetGURUCode(RV)
Exit Sub
End If
End With
MutexUnlock(ClientMutex)
Print "[ACCEPT] TSNEID: " & NewTSNEID; " IPA: "; V_IPA
End Sub
'------------------------------------------------------
ClientMutex = MutexCreate
RV = TSNE_Create_Server(G_Server_TSNEID, 1234, 10, @TSNE_NewConnection, 0)
If RV <> TSNE_Const_NoError Then
Print "[ERROR] " & TSNE_GetGURUCode(RV) & RV
Sleep 5000
End
End If
Do Until InKey() = Chr(27)
Sleep 1, 1
Loop
'disconnect all clients
MutexLock(ClientMutex)
For X As UInteger = 1 To ClientCount
If ClientD(X).V_InUse > 0 Then
If ClientD(X).V_TSNEID > 0 Then
TSNE_Disconnect(ClientD(X).V_TSNEID)
End If
End If
Next
MutexUnlock(ClientMutex)
MutexLock(ClientMutex)
For X As UInteger = 1 To ClientCount
If ClientD(X).V_InUse > 0 Then
If ClientD(X).V_TSNEID > 0 Then
MutexUnlock(ClientMutex)
TSNE_WaitClose(ClientD(X).V_TSNEID)
MutexLock(ClientMutex)
End If
End If
Next
MutexUnlock(ClientMutex)
MutexDestroy ClientMutex
End 0
Code: Select all
#Include once "TSNE_V3.bi"
Dim G_Client_TSNEID as UInteger
Dim Shared As Integer conn, sff, tofile, disconn, bytes
Dim Shared As String reqfile, savfile
Function parse(text As String = "", separator As String = "") As String
Static As String s, t, r
Static As Integer b, e
If separator = Chr(0) Then 'return the rest of the text
r = Mid(t, e + 1)
e = Len(t)
Return r
ElseIf Len(separator) Then
s = separator
EndIf
If Len(text) Then 'new text
t = text
e = 0 'pointer to beginning
EndIf
b = e + 1 'pointer behind last word
Do While InStr(s, Mid(t, b, Len(s))) 'seek next beginning of word
If b >= Len(t) Then
Return ""
EndIf
b += Len(s)
Loop
e = b
Do
'If Mid(t, e, 1) = """" Then 'quotation marks
' Do 'seek end of the quoted text
' e += 1
' If e > Len(t) Then 'text ended
' Exit Do, Do
' EndIf
' Loop Until Mid(t, e, 1) = """"
'EndIf
e += 1
If e > Len(t) Then 'text ended
Exit Do
EndIf
Loop Until InStr(s, Mid(t, e, Len(s))) 'found separator
e -= 1 'set pointer in front of separator
r = Mid(t, b, e - b + 1) 'cut text
Return r
End Function
Sub TSNE_Disconnected(ByVal V_TSNEID as UInteger)
Close tofile
tofile = 0
Print "[Disconnected] TSNEID: "; V_TSNEID
conn = 0
End Sub
Sub TSNE_Connected(ByVal V_TSNEID as UInteger)
Print "[Connected] TSNEID: "; V_TSNEID
conn = 1
Dim RV as Integer
RV = TSNE_Data_Send(V_TSNEID, "SendFile" & Chr(13, 10) & reqfile & Chr(13, 10))
If RV <> TSNE_Const_NoError Then
Print "[ERROR] " & TSNE_GetGURUCode(RV)
conn = 0
TSNE_Disconnect(V_TSNEID)
End If
End Sub
Sub TSNE_NewData(ByVal V_TSNEID as UInteger, ByRef V_Data as String)
Dim As Integer ff
Dim As String fi, g, response
If tofile = 0 Then
response = parse(V_DATA, Chr(13,10))
Print response
Select Case LCase(response)
Case "requestedfile " & reqfile
g = parse()
bytes = Val(g) 'length of the file
tofile = FreeFile
Open savfile For Output As #tofile
Print g
End Select
Else
Print #tofile, V_DATA;
Print Int(100 * Lof(tofile) / bytes);"%" 'show progress
Locate CsrLin - 1, 1, 0
If Lof(tofile) = bytes Then 'transmission done
Close tofile
disconn = 1
Print
EndIf
EndIf
End Sub
Dim RV as Integer
reqfile = "g:\#01sb271116.mp2" 'requested file. replace by a file of your own
savfile = "g:\#01sb.mp2" 'file to save to
Do
Select Case conn
Case 0
'IP address 127.0.0.1 means "localhost" = server and client are running on the same
' computer. replace by appropriate IP if required
RV = TSNE_Create_Client(G_Client_TSNEID, "127.0.0.1", 1234, @TSNE_Disconnected, @TSNE_Connected, @TSNE_NewData)
If RV <> TSNE_Const_NoError Then
Print "[ERROR] " & RV & " " & TSNE_GetGURUCode(RV)
Sleep 1000
End
End If
Case 1
Sleep 1
End Select
Loop Until (InKey() = Chr(27)) Or (disconn = 1)
Print "Disconnect"
TSNE_Disconnect(G_Client_TSNEID)
Print "WaitClose"
TSNE_WaitClose(G_Client_TSNEID)
Sleep 3000