Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA:

Default Wert für Schalterbelegung in LUA 13 Dez 2022 21:11 #7

  • kefro
  • kefros Avatar
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Beiträge: 114
  • Dank erhalten: 69
Also vorlesen werd ich euch die API nicht.
Ab hier solltet ihr euch mal schlau machen!
Pilatus PC6 Turboporter, TS-Modelltechnik, 3740mm, Jetcat SPT-5, DC-24
Pilatus PC6 Turboporter, Bräuer Modellbau, 3520mm, 3W80R2, DC-16_I
Pilatus PC6 Turboporter, Flitework, 2300mm, elektrisch, DC-16_I
Anhänge:

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Default Wert für Schalterbelegung in LUA 13 Dez 2022 21:15 #8

  • davidmcq137
  • davidmcq137s Avatar
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Beiträge: 75
  • Dank erhalten: 80
I have a guess .. it would seem logical that you could do a system.pLoad with a default value, and indeed this works for every datatype EXCEPT switchitems. A switchitem is what lua calls "userdata" and is only defined as a struct in the underlying C runtime. It can't be created from lua.

So if you assign a switch and do a pSave, Jeti has put special code into pSave and pLoad so that it handles switchitems correctly. But I am unaware of any way to specify a switchitem default if it was never previously pSaved .. which I believe was the original question.

But .. perhaps Alex is in possession of the knowledge that we don't have (I hope so!)

Dave

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Default Wert für Schalterbelegung in LUA 13 Dez 2022 21:23 #9

  • sierra_uniform
  • sierra_uniforms Avatar Autor
  • Offline
  • Gold Boarder
  • Gold Boarder
  • Beiträge: 270
  • Dank erhalten: 134
Hallo Alex,

das habe ich auch gelesen. Die große Frage ist, wie muss man den Switch ITEM angeben. Der Typ ist userdata. Und da habe ich bisher keine Möglichkeit gefunden, einen solchen Typ anzugeben. Laut LUA Beschreibung geht das nur über ein Unterprogramm in C. Das kanns aber doch meines Erachtens nicht sein. Hast Du sowas schon mal konkret gemacht? Wenn ja könnten wir Dein Beispiel haben?

Gruß Hermann

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Default Wert für Schalterbelegung in LUA 19 Dez 2022 15:15 #10

  • dit71
  • dit71s Avatar
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Beiträge: 157
  • Dank erhalten: 79

Hi Herman,

You might think (I did!) that if you have createSwitch and getSwitchInfo API calls that you have all that you need .. but sadly, that does not work either. Turns out you can't find out which direction the switch was assigned (which way is +1 and which way is -1) so it's a 50/50 shot of getting it right. I've been in touch with Jeti on this and have suggested a simple extension to these two calls that would allow it all to work. Hopefully they will get to it sometime.

Dave


Hello Dave,

that isn't true, of course you can save a switch and restore it without to guess which direction it was, you have to do it when the switch is selected. I tould you this already one year ago and I'm using it in my dbdis app since two years, and it works perfect!

www.jetiforum.de/index.php/lua-fuer-die-...n-schaltern?start=24

For example if I set up a new model I will always use the the same switches, so I activate the dbdis app and load the configuration file from an other model and all switches are set like I like them. I don't understand why its obviously still a problem, because I found a solution already two years ago and anyone can use or copy it?

Dieter

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Default Wert für Schalterbelegung in LUA 19 Dez 2022 15:32 #11

  • davidmcq137
  • davidmcq137s Avatar
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Beiträge: 75
  • Dank erhalten: 80
Thanks Dieter. Yes of course you can define a switch and pSave and pLoad it and it works correctly. The OP's question was how to set up a default switchitem, if the switch had never been defined before.

I thought that the new createSwitch() API call along with getSwitchInfo() .. but they do not for the reasons I stated.

I guess I really need to look at your app again and see what you are doing to determine if it solves the problem. Last time I looked, I thought it did not. Maybe I am just confused (it happens all the time!) .. I'll look again and get back to you. If you have solved it then I guess Alex will miss out on the free coffee and I'll have to send it to you :-)

Many thanks and happy holidays.
Dave

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Default Wert für Schalterbelegung in LUA 19 Dez 2022 16:10 #12

  • dit71
  • dit71s Avatar
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Beiträge: 157
  • Dank erhalten: 79
Of course for normal starting the transmitter I use the pload or psave command, but especially during testing some code you can loose all the adjustments and that I want to avoid. So I knew your problem, an it took me also quite a time to found a solution that works.

But if the switch had never been defined before than you are right, you don't know the position, at least once you have to define it in a app use it anywhere else.

I cann't tell know the exact code I had to look on it too, but I'm sure you will get, otherwise I will help you.
The main thing is, you don't have to allow to move the switch after selecting, otherwise you will never get the correct position, then you are right. Escpecially if you use a self returning switch, you have to hold them until selection is finished.

Dieter

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Moderatoren: ThornIG-Modellbau
Ladezeit der Seite: 0.597 Sekunden
Powered by Kunena Forum