Jump to content

[WIP][Plugin][0.90] Telemachus and RemoteTech Kitbash


jackellice

Recommended Posts

Telemachus and RemoteTech Kitbash

The purpose of this mod is to function as a realism add-on that combines Telemachus and RemoteTech in a nifty way.

This mod is a small change that does two things

  1. Telemachus module to every RemoteTech enabled Antenna. That means if RemoteTech or anyone patches other antennas to include a RemoteTech antenna, it will be able to function as a Telemachus antenna as well.
  2. makes Telemachus reliant on RemoteTech to function. That means if the antenna does not have a connection to the KSC, No Telemetary will be received by the end user.

Requirements:

  1. Remote Tech v1.6.3
  2. Telemachus 2014-10-12

I don't know if this will work in later versions. If anyone could help me figure out how to modify another mod's override update method outside of recompiling their dll, i'm all ears.

Licenses located here

For Telemachus(Modified BSD) This product includes software developed by Richard Bunt.

For remoteTech(GPLv2)

Installation

Installation requires you to move the gamedata folder to the ksp directory. If you compile the Telemachus dll, you will have to replace the dll in Telemachus' folder. it does this to add the remotetech reliance to all telemachus parts. If that is not desired just simply use the config file. It will just add telemachus to all remote tech antenna without including the reliance.

Remember to only install this modification after installing RemoteTech and Telemachus

stock_dish_not_working_by_jackellice-d8jhqfe.pngstock_dish_working_by_jackellice-d8jhqd2.png


[/SIZE][SIZE=3]{
[/SIZE][SIZE=3] statusString = "No Connection!";
[/SIZE][SIZE=3] isActive = false;
[/SIZE][SIZE=3] telemachusInactive();[/SIZE]
[SIZE=3]}[/SIZE]
[SIZE=3]else if (!RemoteTech.API.API.HasConnectionToKSC(FlightGlobals.ActiveVessel.id))//if remote tech is not operational do this.


@PART
[*]:HAS[@MODULE[ModuleRTAntenna]]:AFTER[RemoteTech]:NEEDS[RemoteTech]{
MODULE
{
name = TelemachusDataLink
}


MODULE
{
name = TelemachusPowerDrain
powerConsumptionBase = 0.01
powerConsumptionIncrease = 0.02
}
}

Compiled files

Files include the config file and the compiled dll

Download from here

Source Code

Files included are a config file to add telemachus to all RemoteTech parts and the source code for the Telemachus dll. Permission has been granted by forum.kerbalspaceprogram.com/members/17885-Rich"]Rich

Download from here

This mod is not endorsed by either Rich or Peppie23

Possible Future Updates

Provided I can figure out how, move my changes over to a separate dll so that it doesn't change the Telemachus dll.

Make telemetary data lag as the signal delay increases with distance.

include more telemetary data or UI to the server side of Telemachus.

So that's that. let me know what you think.

Edited by jackellice
readding permissions
Link to comment
Share on other sites

Oh hey you do KSA. I saw it recently, It was pretty cool.

As to you kOS stuff. I have been thinking if it was possible to code stuff from a telemachus link that transfers the code to the onboard kOS.

If I can make telemetary data lag and it doesn't look juttery on the web server side I think it should be very possible for you to get that working for kOS.

Link to comment
Share on other sites

So this is what I think may make it work. I'm not familiar with server code and the ramifications of what i'm doing.

This bit is located in the KSPWebSocketService class in the Server.dll


[COLOR=#000000][FONT=Verdana]private void streamData(object sender, ElapsedEventArgs e) [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] streamTimer.Interval = streamRate;[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana] DataSources dataSources = new DataSources();[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana] if (toRun.Count + subscriptions.Count > 0)[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] try[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] List<string> entries = new List<string>();[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana] APIEntry entry = null;[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana] lock (subscriptionLock)[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] dataSources.vessel = kspAPI.getVessel();[/FONT][/COLOR]

[B][COLOR=#000000][FONT=Verdana] signalDelay = RemoteTech.API.API.GetSignalDelayToKSC(dataSources.vessel.id);// this is what i've added[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] if (UnityEngine.Time.time - currentTime > signalDelay) // as well as this calculates the change in time. if the change is more than signal delay time, execute[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR][/B]
[COLOR=#000000][FONT=Verdana] if (dataSources.vessel != null)[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] toRun.UnionWith(subscriptions);[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana] foreach (string s in toRun)[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] DataSources dataSourcesClone = dataSources.Clone();[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] string trimedQuotes = s.Trim();[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] string refArg = trimedQuotes;[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] kspAPI.parseParams(ref refArg, ref dataSourcesClone);[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana] kspAPI.process(refArg, out entry);[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana] if (entry != null)[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] entry.formatter.setVarName(trimedQuotes);[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] entries.Add(entry.formatter.format(entry.function(dataSourcesClone)));[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] }[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] }[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana] toRun.Clear();[/FONT][/COLOR]

[COLOR=#000000][FONT=Verdana] if (entry != null)[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] WebSocketFrame frame = new WebSocketFrame(ASCIIEncoding.UTF8.GetBytes(entry.formatter.pack(entries)));[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] byte[] bFrame = frame.AsBytes();[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] dataRates.addDownLinkPoint(System.DateTime.Now, bFrame.Length * UpLinkDownLinkRate.BITS_PER_BYTE);[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] clientConnection.Send(bFrame);[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] }[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] }[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] else[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] sendNullMessage();[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] }[/FONT][/COLOR]
[B][COLOR=#000000][FONT=Verdana] }// end of if statment[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] currentTime = UnityEngine.Time.time;// changes current time to the current time of the frame[/FONT][/COLOR][/B]
[COLOR=#000000][FONT=Verdana] } [/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] }[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] catch(NullReferenceException)[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] PluginLogger.debug("Swallowing null reference exception, potentially due to async game state change.");[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] sendNullMessage();[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] }[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] catch (Exception ex)[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] PluginLogger.debug("Closing socket due to potential client disconnect:" + ex.GetType().ToString());[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] close();[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] }[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] }[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] else[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] {[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] sendNullMessage();[/FONT][/COLOR]
[COLOR=#000000][FONT=Verdana] }
[/FONT][/COLOR]

Link to comment
Share on other sites

This is cool and all but you need to ensure you keep your ducks in a row. You aren't really in compliance with Telemachus' license (though you can be with some small changes), and you haven't provided your own license either. Like I this I think this is cool, so i'd hate to see it taken down for little things you can fix :)

Link to comment
Share on other sites

Could you be more specific as to what I'm not complying with? Thanks!

Well if you check out the Telemachus license, as I see it there are 3 main points:

1. You need his permission to redistribute. did you get that? Generally you would post something saying you did.

2. It needs to include the copyright notice, which i'm not sure a link satisfies that. Probably best just to include the actual text both in the post and in your source code. It might already bein your source code, which I didn't look at, so if it is my apologies.

And lastly:

3. All advertising materials mentioning features or use of this software

must display the following acknowledgement:

This product includes software developed by Richard Bunt.

Like I said, minor things really. Just best to cross your Ts and Dot your Is as the saying goes.

Link to comment
Share on other sites

This is fair. I've misread it as requiring permission if the source file wasn't distributed as well. I'll remove the compiled dll.

Licenses were provided in both compiled and source files.

Will add the acknowledgement.

Thanks for clarifying.

Edited by jackellice
Link to comment
Share on other sites

  • 3 months later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...