Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ksc messages #1972

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Ksc messages #1972

wants to merge 5 commits into from

Conversation

zegkljan
Copy link
Contributor

@zegkljan zegkljan commented Mar 8, 2017

So, I got a little bored (well, not really) and just went ahead and implemented what I proposed in #1964.

If you want to see it in "action", you can view a few screenshots here: http://imgur.com/a/dUyR0

I added a single new button to the main kOS window (the one that has the list of loaded processors) that allows to open an "uplink channel" to the currently active vessel. When opened a window very similar to the one used to edit source files appears. In this window the player can type whatever she wants to. Then she can hit the Send button and the content of the window is sent as a string with a proper delay (to home since we are sending from KSC).

Now, there are some things that are kind of hackish. Before this, the SENDER of a message was either Vessel that corresponded to the sender or it was False. Now I needed to distinguish one extra case - the sender is the KSC. I achieved this by setting the SENDER to True when this is the case, but HASSENDER still returns false. In other words, the new "sender table" looks like this:

  • HASSENDER is true, SENDER is a vessel: SENDER contains the vessel that sent the message
  • HASSENDER is false, SENDER is false: the message was sent from a vessel that no longer exists
  • HASSENDER is false, SENDER is true: the message was sent from KSC

In order to do that I modified the GetVesselTarget() method of MessageStructure.

The other hackish thing is the way I represent the actual sender when the message is built. The Message.Create() needs a VesselTarget to be the sender. Therefore I created a new class KscTarget that is a singleton. I also made the method GetGuid() in VesselTarget virtual so that KscTarget can override it. When doing the GetVesselTarget() in MessageStructure, if no vessel is found (via GetVessel()), the singleton KscTarget's guid is checked for equality with the message's vessel.

Be warned that this is effectively my first touch on KSP mods and C# as well (apart from the regexp matching on part tags I have already done) so feel free to bash my head because all the mistakes I have done (which I'm not aware of).

The reason of the [NOT READY] thing is that I have no idea whether I have done it in a good way, and also because the documentation is not updated.

@Dunbaratu
Copy link
Member

This looks like a good idea. I haven't had time to look at the code yet because I had my head buried in the GUI system and the fonts changes. But it looks good and we should get around to looking at it.

As I understand it, it provides a way for you to send a message using the inter-vessel comms system from the KSC to a vessel. Presumably the message has to be a string.

@zegkljan
Copy link
Contributor Author

Yes, exactly - you open a dedicated window where you write whatever you want and then hit Send and (after a delay, if any) the vessel receives the message with that string as the content.

I thought a little bit about sending more than strings but that would need one of two things:

  • literals for lexicons and lists that are currently not in the language (or at least I think so)
  • ability to run kOS code outside the vessel (in the KSC) that would do the message sending - that would probably be quite complicated as a load of variables that are usually there would not be, only some things would be allowed, etc.

Anyway, I decided to go the simplest way and just send strings for now. It is the receiver's business to parse it. In the future, if the lexicon and list literals show up, it should be easy to integrate - e.g. a checkbox would be added to the window that would tell whether I want to parse it or just send as string and then upon sending the message the typed stuff would be parsed.

@hvacengi hvacengi added the Not Ready Author is warning Reveiwer not to merge this PR yet. More edits are expected. label Apr 10, 2017
@hvacengi hvacengi changed the title Ksc messages [NOT READY] Ksc messages Apr 10, 2017
@hvacengi hvacengi added Pending Documentation Author is warning Reviewer not to merge this PR yet. User doc changes aren't in the PR yet. and removed Not Ready Author is warning Reveiwer not to merge this PR yet. More edits are expected. labels Apr 10, 2017
@hvacengi
Copy link
Member

I'm moving the [Not Ready] title to a Pending Documentation label. We can start working on reviewing the code while you figure out the documentation side. Plus then we know that if it looks like we can handle the documentation easily enough we can do it during the code review.

* Added images illustrating button for opening uplink channel and the message sending window.
* Added a section on sending messages from KSC to a vessel.
* Added a TODO to replace the overview image in settingsWindows.rst.
* Documented the SENDER and HASSENDER attributes.
* Better description of the general usage.
# Conflicts:
#	src/kOS/Screen/KOSToolbarWindow.cs
@zegkljan
Copy link
Contributor Author

Everything should be documented. The only exception is the /_images/general/controlPanelWindow.png which should to be redone to reflect other changes too. For the time being I added a small TODO just above that picture in /general/settingsWindows.rst.

@Dunbaratu
Copy link
Member

Thanks. I'm digging through some older issues and PR's so it may be a day or two before I look at this.

@sebseb7
Copy link

sebseb7 commented May 30, 2017

give the space center its own cpu and gui

@zegkljan
Copy link
Contributor Author

@sebseb7 Yes, that would be awesome. However, it would be also a lot of work (a lot of things in kerboscript assumes that there is a vessel to control, e.g. the whole SHIP variable) which for me is too much, as I don't know C# very much and also I know next to nothing about how kOS is internally organized. I thought this could be a first step towards what might be a KSC-side CPU.

@mathuin
Copy link
Contributor

mathuin commented May 12, 2018

@sebseb7 that is a brilliant idea. If KSC had its own CPU and GUI, the archive could live there. Code could then be transferred between CPUs in the VAB/SPH and on the launchpad/runway as appropriate. Files could be transferred to and from vessels within radio range. Lots of interesting possibilities!

On another note, what if anything is left for this PR before it can be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pending Documentation Author is warning Reviewer not to merge this PR yet. User doc changes aren't in the PR yet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants