Gadroc Posted October 11, 2009 Posted October 11, 2009 I'm fuzzy on the SIOC cards and setup as I don't have any... (yet still debating on whether I just build out a bigger touchscreen setup or start a physical pit). All of the items I described is based on Oakes code and should be done in the Export.lua file. There are aptly named functions that you edit. This file is found in the Config/Export directory in the Black Shark install directory. (Make a backup copy before you start tinkering.) You can find another example in the TouchPal blackshark profile. Although much like Oakes example it's more complicated, but more of the logic is handled in the TouchPal config/code.
Oakes Posted October 12, 2009 Posted October 12, 2009 Hi Stelios I don't have any USBKey card myself so take the following with a big:) grain of salt. You need to first connect the card to SIOC via sioc.ini From the SIOC help file (Press Config in main SIOC program and then search help on usbkeys & usb_keys): USBKeys=(Device Index),(Device Number) For USBKeys CardsSecondly you need to bind the USBKeys card to a parameter in SIOC (again from the help file): With this link we can access to USB_KEYS cards. Each pressed key is sent to the variable, that takes the corresponding value, runs the script and returns its value to 0. Is possible to link with the keyboard emulator module just setting the TYPE attribute to K. This way, the key pressed is sent by USB_KEYS as defined in the SIOC.INI file. Attributes: Name Assigns a symbolic name to a variable. Value Assigns an initial value. Device Is the card device number where the variable is assigned. If it is 0, the first available number is considered (default). Clicking on the button gives access to a list of available IOCards USB cards connected. In this case we can select the device from the list. If it is not selected, a 0 will be considered. Type Optionally, K can be set to indicate a keyboard simulation. Example: Var 0001, name Teclas, Link USB_KEYS, Device 123, Type KThis will give you a SIOC parameter that briefly takes the value of the the pressed button and then returns to zero, you can then send this value to DCS and use it to determine what you want to do. Without having access to the hardware (I use the master cards and the scripts are written for that purpose) it is problematic to give any better advise, one question pops to mind though, what happens when you release the button (i.e what will be sent to the linked variable?) Can releases be detected? /Oakes
stelios2000 Posted October 13, 2009 Posted October 13, 2009 (edited) Dear friend Oakes, I have master card and an expansion card so i connect them to my PC with USB instead of LPT. Can you please tell me everything you do with the master card (how you connect it, what files do you change etc etc every step) and write me just the code lines for these 2 switces i mention and which file do i have to change (only Export.lua ???) so i will try to understand all the procedure (and make them work...just these 2 switches) Also a question to make....i have read somewhere that it has over 700 (buttons/different situations???) the B.S. How you intend to cover all them? By using only Master cards?How many? If so then i have to buy some more myself. Thanks again and please forgive me my ignorance but i am confused... I am reading too many different post in many forums and i am confused. Some peoples they change not only the Export.lua file but also the clikabledata.lua file the import/export file (where are these????) and they write code lines(where???) Much confused.....Stelios Edited October 13, 2009 by stelios2000
Oakes Posted October 14, 2009 Posted October 14, 2009 Hi Stelios Np, lets start with the mastercards/usb expansion etc 1. Connect the USB Expansion to the Master Card and test that it works (you don't need to test the outputs yet etc, just test a few inputs) , here is a very good link http://personales.ya.com/micabina737/iocards/hard/test1i.htm for this. btw, If you do not have the appropriate parallel cable for connecting the master card to the USB Expansion card you can remove the jack posts (see picture at http://media.digikey.com/photos/Tyco%20Amp%20Photos/5207719-3.jpg) from the mastercard 25 pin dsub and connect them directly. Just make sure you use the J1 connector on the USB Expansion card (http://personales.ya.com/micabina737/iocards/hard/numi.htm) I didn't connect any 5 volt source to the master card initially and this worked fine until I started connecting LEDS/displays etc so I guess you can skip that step for now. 2. Connect a simple two position switch to any input on the master card. http://personales.ya.com/micabina737/iocards/hard/elementosi.htm 3. Check that this works with the Controlador software. ..and then we will take it from there. Links from http://personales.ya.com/micabina737/iocards/hard/guiai.htm /Oakes
stelios2000 Posted October 14, 2009 Posted October 14, 2009 (edited) ok i did all these (i have parallel cable and connect it to J1 from Master to J1 to Expansion Card) I updated/changed the file C:\Program Files\IOCards\controlador.ini USB = yes MUSB = no i chose to wire the 1st pin with the 10th(GND) pin and the result is this for ON/OFF switch http://img169.imageshack.us/img169/1531/54878124.jpg http://img261.imageshack.us/img261/5738/51424837.jpg i did the same to all inputs and they work fine thanks stelios Edited October 14, 2009 by stelios2000
PanelBuilder Posted October 14, 2009 Posted October 14, 2009 from the mastercard 25 pin dsub and connect them directly. Just make sure you use the J1 connector on the USB Expansion card (http://personales.ya.com/micabina737.../hard/numi.htm) All I can say is...wow.
Oakes Posted October 14, 2009 Posted October 14, 2009 ok i did all these (i have parallel cable and connect it to J1 from Master to J1 to Expansion Card) I updated/changed the file C:\Program Files\IOCards\controlador.ini USB = yes MUSB = no i chose to wire the 1st pin with the 10th(GND) pin and the result is this for ON/OFF switch http://img169.imageshack.us/img169/1531/54878124.jpg http://img261.imageshack.us/img261/5738/51424837.jpg i did the same to all inputs and they work fine thanks stelios Ok, now we need to connect the mastercard and the switch to SIOC. For this you need to find the Device ID of the USB Expansion card and add (or modify) the following line to sioc.ini (under masters). MASTER=0,4,1,X "X" is the Device id of the USB card, you can find this number by starting SIOC, then on the upper right window you can see this number, it says "Something something - Device = 123" I belive. You should only have one USB expansion card connected to the computer for this to work I believe. (You can also use USBCheck to see the device ID http://www.opencockpits.com/modules.php?name=Downloads&d_op=getit&lid=254) Here is some more info about the device number. http://www.lekseecon.nl/howto.html#device While you are editing sioc.ini also change the CONFIG_FILE=.\keys.ssi to something appropriate like CONFIG_FILE=.\dcs_001.ssi or similar. This is the SIOC file that we will use for DCS (defines all the inputs/outputs/logic) etc. /Oakes
stelios2000 Posted October 14, 2009 Posted October 14, 2009 (edited) Ok i run opencockpits Sioc and have this http://img381.imageshack.us/img381/8196/25994084.jpg I then edit the C:\Program Files\IOCards\SIOC\sioc.ini (I think that square brackets [] includes remarks) so i found the http://img381.imageshack.us/img381/4992/87129017.jpg and change it to http://img381.imageshack.us/img381/5081/50563902.jpg I hope this is the line that you mention...How can i check if i did it right ? I run again the opencockpits Sioc and have the same look as before the change thanks again stelios Edited October 14, 2009 by stelios2000
Oakes Posted October 14, 2009 Posted October 14, 2009 Ok, now for the fun part. Hit the Config button on the SIOC page. This opens the editor. Now right click and select Insert Var or New var. Double click on the rectangle that appears. In the new window that opens, left click on the "NOT LINKED" text and select Switches (under IO Cards Master). Set Var Num to 10, Name to Test, InS/Outs/# to 1 (this is the physical number of the input for your switch, corresponds to the number in contraldor program). Hit Ok. Now you should have this line in the editor: Var 0010, name Test, Link IOCARD_SW, Input 1 Now save the file (Files-> Save) Now hit Reload on the Main SIOC window. Then hit IOCPCONSOLE, check that the status is CONNECTED. Now when you flip the switch (connected to input 001 on the master card) you should see var 10 (also named Test) in the IPOCCONSOLE window shift from 0 to 1 (or vise versa)....if this works then the connection from the switch to the master to the USB to the SIOC to the variable works. Next we do the scriptfiles. /Oakes
stelios2000 Posted October 14, 2009 Posted October 14, 2009 (edited) ok i did what you told me and i got from this http://img129.imageshack.us/img129/5562/46009214.jpg this http://img129.imageshack.us/img129/4586/80974172.jpg what is this IAS that changes anyway ? I understood the meaning of these Name=Test and the InS/Outs/# = 1 but why we chose Var Num=10 ??? Can we have Variable Num = any number ? thanks stelios Edited October 14, 2009 by stelios2000
Oakes Posted October 14, 2009 Posted October 14, 2009 (edited) Hi I think you missed this step: While you are editing sioc.ini also change the CONFIG_FILE=.\keys.ssi to something appropriate like CONFIG_FILE=.\dcs_001.ssi or similar. This is the SIOC file that we will use for DCS (defines all the inputs/outputs/logic) etc.Your "CONFIG_FILE=" (maybe "CONFIG_FILE=.\sioc.ssi") might be different from mine. The important thing is that we start a new file...otherwise we get a lot of old stuff. Like VSI etc. So basically change the CONFIG_FILE=something to CONFIG_FILE=.\dcs_001.ssi, restart SIOC and then repeat the adding of a variable in the editor (this time you should get a blank file when you hit the CONFIG button). Yes you can use any variable number you like, but I choose 10 as the example. /Oakes Edited October 14, 2009 by Oakes
stelios2000 Posted October 14, 2009 Posted October 14, 2009 I did what you told me and I added the variable first... then save it as dcs_001.ssi and then change the sioc.ini file to CONFIG_FILE=.\dcs_001.ssi so i am getting this http://img119.imageshack.us/img119/823/76640016.jpg which i believe is correct thanks stelios
Oakes Posted October 15, 2009 Posted October 15, 2009 That seems right, just make sure that the Var 10 shift between 0 and 1 when you flip the switch. Ok, next step is to download the latest version of the scripts from http://code.google.com/p/dcsbsexport/downloads/list and unzip the files into the Export directory of BS (make a backup first). <--(I'm assuming you have already done this but I included it for new people following this thread.) Anyway, you then need to set EnableExportScript = true in the Config/Export/Config.lua to get the export going. Edit your inputsTable.lua so that you only have the line below. inputsTable = {[10] = {TwoPositionSwitch, 60, 2, 1}}Now comment all the stuff in LuaExportAfterNextFrame() since you do not have any indicators, ammo counters etc function LuaExportAfterNextFrame() -- Works just after every simulation frame. -- Generate the SIOC string for all indicatortables in the master gIndicatorTables table -- local lSIOC_SendString = ProcessIndicators(gIndicatorTables) --Generate and add the SIOC string for the ammocounters to SIOC string --lSIOC_SendString = lSIOC_SendString..ProcessAmmoCount(ammoCounters.Remain,ammoCounters.RNDS) --Send the string to SIOC if --if lSIOC_SendString ~= "" then --socket.try(c:send("Arn.Resp:"..lSIOC_SendString.."\n")) --end end Run DCS:BS, if everything works correctly you should now see the simulated Targeting System Power Switch (same panel as Auto Turn, Moving Gnd Target etc) follow you physical switch. If it doesn't work check the Temp\Error.log file for errors. (I use the Kiwi Log Viewer http://www.kiwisyslog.com/kiwi-log-viewer-overview/ for this but of course you can just open the file with Notepad etc.) Btw, PSPad is a good editor for LUA files http://www.pspad.com/ To enable LUA highlighting in PSPAD do this: 1. Settings -> Highlighter Settings 2. Select one of the <not assigned> entries at the bottom of the list to the left 3. Select LUA in the list of User Highlighters 4. Click OK. /Oakes
stelios2000 Posted October 15, 2009 Posted October 15, 2009 Now comment all the stuff in LuaExportAfterNextFrame() since you do not have any indicators, ammo counters etc function LuaExportAfterNextFrame() -- Works just after every simulation frame. -- Generate the SIOC string for all indicatortables in the master gIndicatorTables table -- local lSIOC_SendString = ProcessIndicators(gIndicatorTables) --Generate and add the SIOC string for the ammocounters to SIOC string --lSIOC_SendString = lSIOC_SendString..ProcessAmmoCount(ammoCounters.Remain,ammoCounters.RNDS) --Send the string to SIOC if --if lSIOC_SendString ~= "" then --socket.try(c:send("Arn.Resp:"..lSIOC_SendString.."\n")) --end end /Oakes in which file is the [b]LuaExportAfterNextFrame()[/b] function ? thanks
stelios2000 Posted October 15, 2009 Posted October 15, 2009 Export.lua. /Oakes you mean the C:\Program Files\Eagle Dynamics\Ka-50\Config\Export\Export.lua ??? As i saw...it exists....I then run B.S. but nothing happened here is the link to donwload and see my export.lua file http://rapidshare.com/files/293321321/Export.lua.html To remind you that i have downloaded and unzip your Export Folder (Export 0.92 beta) that you gave us in another post.
Oakes Posted October 15, 2009 Posted October 15, 2009 What does the Error.log file say? Do you get a connection to SIOC when you run DSC:BS (SIOC must be running btw)? You can check this under <IOCP> Server -> Clients Connected. You should have 0 when not running DCS and 1 client when running DCS (IOCP Console connects to this as well so every IOCP Console window means +1 on this value). In the export directory you should have my Export.lua, ExportSupport.lua, weaponsTypeIndicator and in the subdir SIOCConfig you should have siocConfig.lua. /Oakes
stelios2000 Posted October 15, 2009 Posted October 15, 2009 In the export directory you should have my Export.lua, ExportSupport.lua, weaponsTypeIndicator and in the subdir SIOCConfig you should have siocConfig.lua. /Oakes I wasnt running the Sioc. So now i have this when i run it (clients running = 1) http://img376.imageshack.us/img376/3619/16896737.jpg and this is the switch we are trying to move it right ? http://img395.imageshack.us/img395/5553/18470115.jpg as far as the C:\Program Files\Eagle Dynamics\Ka-50\Temp\error.log please download it from this link http://rapidshare.com/files/293338115/Error.log.html Now at the export folder i have what you told me(erase the others) but it is freezing at the first screen that tells me to press the Pause/Break button to start. I read the error.log and the game couldnt find the class.lua file so i put it back. So in the export folder i have the export lua weaponstypeindicator.lua config.lua exportsupport.lua class.lua Siocconfig folder with siocconfig.lua file in it thanks stelios
Oakes Posted October 15, 2009 Posted October 15, 2009 Ok, no problem with the error log, this is normal. Did you update the inputsTable table in siocConfig.lua to reflect your settings? Since you downloaded the new version you need to redo this step (the new version takes it's input from siocConfig.lua and not the old inputsTable.lua) Edit your inputsTable.lua so that you only have the line below. Code: inputsTable = {[10] = {TwoPositionSwitch, 60, 2, 1}} Basically replace this: inputsTable = { [501] = {TwoPositionSwitch, 12, 1, 1}, [502] = {TwoPositionSwitch, 12, 3, 1}, [503] = {TwoPositionSwitch, 12, 22, 1}, [504] = {TwoPositionSwitch, 12, 21, 1}, [505] = {TwoPositionSwitch, 12, 5, 1, 1}, [508] = {TwoPositionSwitch, 12, 6, 1, 1}, [509] = {TwoPositionSwitch, 12, 20, 1, 1}, [510] = {SimpleRotary, 12, 4}, [530] = {TwoPositionSwitch, 12, 9, 1}, [531] = {TwoPositionSwitch, 60, 2, 1}, [532] = {TwoPositionSwitch, 23, 2, 1}, [533] = {TwoPositionSwitch, 12, 17, 1}, [534] = {TwoPositionSwitch, 11, 1, 1}, [535] = {TwoPositionSwitch, 12, 16, 1}, [540] = {TwoPositionSwitch, 12, 10, 1}, [541] = {TwoPositionSwitch, 12, 12, 1}, [542] = {TwoPositionSwitch, 12, 11, 1}, [543] = {TwoPositionSwitch, 12, 13, 1}, [555] = {SimpleRotary, 12, 14}, [578] = {TwoPositionSwitch, 25, 5, 0.2}, [590] = {SimpleRotary, 25, 14}, [595] = {SimpleRotary, 25, 15}, }with this inputsTable = {[10] = {TwoPositionSwitch, 60, 2, 1}} in siocConfig.lua In the export directory you should have my Export.lua, ExportSupport.lua, weaponsTypeIndicator and in the subdir SIOCConfig you should have siocConfig.lua.Sorry for the confusion, by this I meant you should replace any default Export.lua etc with my version, not remove everything else:music_whistling: And yes, that is the switch we are trying to move. /Oakes
stelios2000 Posted October 15, 2009 Posted October 15, 2009 it works ........... :-)))))))))))))))))) this is the procedure for the on/off switches right ??? does it need anything else ? how about rotary/push buttons/toggle swiches/Led etc etc ? is it the same ? and what is the purpose of the programming that many peoples do here ? thankssssssssssssssssssss again stelios
londo-cat Posted October 15, 2009 Posted October 15, 2009 I just started with LUA and I am setting up my Vista machine with it, since I am using LUA for Windows, what version are most of you running? Also - what editor are you using to modify the .lua files?
londo-cat Posted October 16, 2009 Posted October 16, 2009 Notepad++ is used for editing lua files. Thanks JG14_Smil - I never knew about Notepad++, so thanks for the info on that. I downloaded from lua.org the latest version of LUA "LuaForWindows_v5.1.4-30.exe" and installed that, so I think I am now on my way to doing the same LUA programming. :thumbup:
Oakes Posted October 16, 2009 Posted October 16, 2009 Online LUA demo....good for testing quick things while learning. http://www.lua.org/demo.html /Oakes
Oakes Posted October 16, 2009 Posted October 16, 2009 it works ........... :-)))))))))))))))))) this is the procedure for the on/off switches right ??? Yep does it need anything else ?Nope how about rotary/push buttons/toggle swiches/Led etc etc ? is it the same ? Nope, LEDs are done via the indicatorTables in siocConfig. Rotaries(not encoders) are done with the SimpleRotary Function. I'll post about this in a little while. and what is the purpose of the programming that many peoples do here ??? Adapting the solution to their needs I guess. Also, please note that I've made a soulution that works for two types of inputs Switches and simple rotaries, there is lots of other stuff that needs to be handled, instruments etc thankssssssssssssssssssss againNp :thumbup: /Oakes
Recommended Posts