¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Program starts then stops. SimplWindows, Simpl+ and S#


 
Edited

I am having an issue with my code starting and stopping.? I am not using "ProgramInitComplete" in SimplWindows. Once program is loaded, I send the ProgReset in text console and program starts then stops . Program ID Tags shows as SN and no program loaded.
I am pasting S# and Simpl+ code here.

S#
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharp.Net.Http;
using System;
?
namespace TriplePlayMyServer
?
{
? ? public class TriplePlayLoader
? ? {
? ? ? ? // Private member variables
? ? ? ? private string serverIP = "";
? ? ? ? public static string Username;
? ? ? ? public static string Password;
?
? ? ? ? // Public delegates
? ? ? ? public errorHandler OnError { get; set; }
? ? ? ? public delegate void errorHandler(SimplSharpString errMsg);
?
? ? ? ? // Public Properties
? ? ? ? public string ServerIP
? ? ? ? {
? ? ? ? ? ? set { serverIP = value; }
? ? ? ? }
? ? ? ? public TriplePlayLoader()
? ? ? ? {
? ? ? ? ? ?//Default Constructor to allow C# to communicate with Simpl+
? ? ? ? }
? ? ? ? public void Initialize()
? ? ? ? {
? ? ? ? ? ?CrestronConsole.PrintLine("Server IP is : {0}", serverIP);
? ? ? ? ? ?HttpClient httpClient = new HttpClient();
? ? ? ? ? ?HttpClientRequest httpRequest = new HttpClientRequest();
? ? ? ? ??
? ? ? ? ? if (serverIP == "" && OnError != null)
? ? ? ? ? {
? ? ? ? ? ? ? ? OnError(new SimplSharpString("No Server IP Specified"));
? ? ? ? ? }
? ? ? ? ? ? ??
? ??
? ? ? ? ? ? try
? ? ? ? ? ? {
? ? ? ? ? ? ? ? // Use this is if Port is 443 - HTTPS
? ? ? ? ? ? ? ? //string url = (Constants.SERVER_URL_PROTOCOL + Username + ":" + Password + "@" + ServerIP + Constants.SERVER_HEADER + Constants.SERVER_QUERY);
?
? ? ? ? ? ? ? ? // Get Json from Server
? ? ? ? ? ? ? ? httpClient.KeepAlive = false;
? ? ? ? ? ? ? ? string url = (Constants.SERVER_URL_PROTOCOL + serverIP + Constants.SERVER_HEADER + Constants.SERVER_QUERY);
? ? ? ? ? ? ? ? var json = new HttpClient().Get(url);
? ? ? ? ? ? ? ?// var json = File.ReadToEnd(Constants.CONFIG_DIRECTORY + "TriplePlay.json", Encoding.UTF8);
? ? ? ? ? ? ? ? StringReader stringReader = new StringReader(json);
? ? ? ? ? ? ? ? var jsonTextReader = new Newtonsoft.Json.JsonTextReader(stringReader);
? ? ? ? ? ? ? ? var jsonSerializer = new Newtonsoft.Json.JsonSerializer();
? ? ? ? ? ? ? ? TriplePlayParent parent = jsonSerializer.Deserialize<TriplePlayParent>(jsonTextReader);
? ? ? ? ? ? ? ? CrestronConsole.Print(" Method - Json return data: {0}", parent);
? ? ? ? ? ? }
? ? ? ? ? ? ? ? catch (Exception ex)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ErrorLog.Error("Error in Deserializing TriplePlay Json : {0}", ex);
? ? ? ? ? ? }
? ? ? ? }
? ? }
}


Simpl+

#USER_SIMPLSHARP_LIBRARY "TriplePlayServer"
?
/*
? DIGITAL, ANALOG and SERIAL INPUTS and OUTPUTS
? (Uncomment and declare inputs and outputs as needed)
*/
DIGITAL_INPUT? _SKIP_, _SKIP_, _SKIP_, _SKIP_, _SKIP_, Go, GetData;
// STRING_INPUT?
// BUFFER_INPUT?
?
DIGITAL_OUTPUT _SKIP_, _SKIP_, _SKIP_, _SKIP_, _SKIP_,Initialized_Fb;?
STRING_OUTPUT TotalClients, _SKIP_, ClientsID[MaxOutput], Location[MaxOutput];
?
?
TriplePlayLoader myServer;
?
/*
? SOCKETS
? (Uncomment and define socket definitions as needed)
*/
// TCP_CLIENT
// TCP_SERVER
// UDP_SOCKET
?
/*
? Parameters
? (Uncomment and declare parameters as needed)
*/
STRING_PARAMETER ServerIPAddress[15];
INTEGER_PARAMETER Port;
STRING_PARAMETER Username[20], Password[20];
?
?
?
#BEGIN_PARAMETER_PROPERTIES ServerIPAddress
propDefaultValue="192.168.1.40";
#END_PARAMETER_PROPERTIES
?
#BEGIN_PARAMETER_PROPERTIES Port
propValidUnits= unitDecimal;
propDefaultUnit=unitDecimal;
propDefaultValue=80d;
propList={ 80d,"HTTP" },{ 443d,"HTTPS" };
#END_PARAMETER_PROPERTIES
?
#BEGIN_PARAMETER_PROPERTIES Username
propValidUnits= unitString;
propDefaultUnit=unitString;
propDefaultValue="Admin";
#END_PARAMETER_PROPERTIES
?
#BEGIN_PARAMETER_PROPERTIES Password
propValidUnits= unitString;
propDefaultUnit=unitString;
propDefaultValue="";
#END_PARAMETER_PROPERTIES
?
?
Integer x;?
?
Function SetServerIP()
{
? ? ?RegisterDelegate(myServer,OnError,MyOnError); // Register the MyOnError function to the OnError delegate
? ? ?myServer.ServerIP = ServerIPAddress; //send IP address of TriplePlay Server to S#?
?// myServer.Initialize();
? ? print("Hello There");
}
?
// MyOnError is triggered from the C# module when an error happens. We add it to the ErrorLog
callback Function MyOnError(String strError)
{
GenerateUserError("TriplePlayServer Error %s\n\r",strError);
}
?
?
PUSH Go
{
? ? //Print("Server IP in Simpl+ is: %s", ServerIPAddress);
? ? SetServerIP();
? ? //Print("Returned from S#");
}
Push GetData
{
? ? //TriplePlayLoader.Initialize();?
?
? ?/* If(Port <> 80)
? ? {
? ? ? ? TriplePlayLoader.Username = Username;? ? ? ? ? ?// send Username of TriplePly Server to S#
? ? ? ? TriplePlayLoader.Password = Password;? ? ? ? ? ? ?// send Password of TriplePly Server to S#
? ? }
?
? ? TotalClients = TriplePlayParent.Result.Result.Total;
? ? */
}
Function Main()
{
? ? WaitForInitializationComplete();
}
?

Join [email protected] to automatically receive all group messages.