Crestron.SimplSharp.SDK.Program 2.21.90

dotnet add package Crestron.SimplSharp.SDK.Program --version 2.21.90                
NuGet\Install-Package Crestron.SimplSharp.SDK.Program -Version 2.21.90                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Crestron.SimplSharp.SDK.Program" Version="2.21.90" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Crestron.SimplSharp.SDK.Program --version 2.21.90                
#r "nuget: Crestron.SimplSharp.SDK.Program, 2.21.90"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Crestron.SimplSharp.SDK.Program as a Cake Addin
#addin nuget:?package=Crestron.SimplSharp.SDK.Program&version=2.21.90

// Install Crestron.SimplSharp.SDK.Program as a Cake Tool
#tool nuget:?package=Crestron.SimplSharp.SDK.Program&version=2.21.90                

<p align="center"><img src="images/crestron_logo_nuget.jpg"></p> <h1 align="center"> Crestron.SimplSharp.SDK.Program</a></h1> <p align="center">Crestron's 4-Series appliances and server based Virtual Control enable you to program your system in C#. This package includes all the necessary libraries needed to create a C# Program that runs on 4-Series or Virtual Control.</p>

Index

Quick Start

To program your Crestron system in C#, follow these steps:

  1. Install the package via NuGet. You can use the following command in the Package Manager Console:

     dotnet add package Crestron.SimplSharp.SDK.Program
    
  2. Import these namespaces in your code file(s) at a minimum:

     using Crestron.SimplSharp;
     using Crestron.SimplSharpPro;
    

    Depending on your application and the devices used, you might need to import additional namespaces.

  3. Create a class that inherits from CrestronControlSystem and add a parameterless constructor: The constructor needs to exit in a timely fashion, otherwise the program will exit. You cannot send/receive data in the constructor

     public class ControlSystem : CrestronControlSystem
     {
     	public ControlSystem() : base()
     	{
     		try
     		{
     			// Initialize Crestron threadpool
     			Crestron.SimplSharpPro.CrestronThread.Thread.MaxNumberOfUserThreads = 20;
     		}
     		catch (Exception e)
     		{
     			ErrorLog.Error("Error in the constructor: {0}", e.Message);
     		}
     	}
     }
    

    Use the constructor to:

    • Initialize the maximum number of threads (max = 400)
    • Register devices
    • Register event handlers
    • Add Console Commands
  4. Add InitializeSystem() This method gets called after the constructor has finished. InitializeSystem() needs to exit in a timely fashion, otherwise the program will exit.

     public override void InitializeSystem()
     {
     	try
     	{
    
     	}
     	catch (Exception e)
     	{
     		ErrorLog.Error("Error in InitializeSystem: {0}", e.Message);
     	}
     }
    

    Use InitializeSystem to:

    • Start threads
    • Configure ports, such as serial and verisports
    • Start and initialize socket connections
    • Send initial device configurations
  5. Subscribe to controller events

    Program Status Events Event handler for programmatic events, such as program stop, pause, and resume. Handling the program stopping scenario is mandatory.

     CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControllerProgramEventHandler);
    
     void ControllerProgramEventHandler(eProgramStatusEventType programStatusEventType)  
     {  
     	switch (programStatusEventType)  
     	{  
     		case (eProgramStatusEventType.Paused):  
     			// The program has been paused. Pause all user threads/timers as needed.  
     			break;  
     		case (eProgramStatusEventType.Resumed):  
     			// The program has been resumed. Resume all the user threads/timers as needed.
     			break;  
     		case (eProgramStatusEventType.Stopping):  
     			// The program has been stopped.  
     			// Close all threads.            
     			// Shutdown all Client/Servers in the system.  
     			// General cleanup. 
     			// Unsubscribe to all System Monitor events  
     			break;  
     	}  
     }
    

    OPTIONAL: System Events Event handler for system events, such as disk inserted/ejected, and system reboot

     CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControllerSystemEventHandler);
    
     void ControllerSystemEventHandler(eSystemEventType systemEventType)  
     {  
     	switch (systemEventType)  
     	 {  
     		case (eSystemEventType.DiskInserted):  
     			// Removable media was detected on the system  
     			break;  
     		case (eSystemEventType.DiskRemoved):  
     			// Removable media was detached from the system  
     			break;  
     		case (eSystemEventType.Rebooting):  
     			// The system is rebooting.   
     			// Very limited time to preform clean up and save any settings to disk.  
     			break;  
     	 }
     }
    

    OPTIONAL: Ethernet Events Event handler for ethernet events, such as link up / link down

     CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControllerEthernetEventHandler);
    
     void _ControllerEthernetEventHandler(EthernetEventArgs ethernetEventArgs)  
     {  
     	switch (ethernetEventArgs.EthernetEventType)  
     	{
     		//Determine the event type Link Up or Link Down  
     		case (eEthernetEventType.LinkDown):  
     			//Next need to determine which adapter the event is for.   
     			//LAN is the adapter is the port connected to external networks.  
     			if (ethernetEventArgs.EthernetAdapter == EthernetAdapterType.EthernetLANAdapter)  
     			{  
    
     			}  
     			break;  
     		case (eEthernetEventType.LinkUp):  
     			if (ethernetEventArgs.EthernetAdapter == EthernetAdapterType.EthernetLANAdapter)  
     			{
    
     			}  
     			break;  
     	}
     }
    

Release Notes

Documentation

Additional documentation can be found <a href="https://community.crestron.com/s/article/id-1000637">here</a></p>

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Crestron.SimplSharp.SDK.Program:

Package Downloads
PepperDashEssentials

Package Description

Vistacom.Class.Library

Vistacom.Class.Library is a specialized software library designed for Crestron control systems. This library is tailored to work with Crestron devices and is equipped with Application Programming Interfaces (APIs) that facilitate the seamless control of various devices through the Simpl# programming language. With Vistacom.Class.Library, Crestron integrators and developers can efficiently manage and interact with a wide range of devices, making it an essential tool for creating custom control solutions within the Crestron ecosystem. This library streamlines the process of programming and controlling devices, enhancing the capabilities and functionality of Crestron-based systems.

Crestron.SimplSharp.SDK.SandboxProgram

A version of Crestron.SimplSharp.SDK.Program suitable for use with a 3-series sandbox build. See https://github.com/scottpidzarko/CrestronSandboxBuild This project pulls the required files from the Device Database. You MUST have the S# plugin and everything it requires installed for this package to function.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.21.90 70 12/26/2024
2.21.68 1,148 11/12/2024
2.21.65 835 10/30/2024
2.21.54 691 10/9/2024
2.20.66 4,238 4/30/2024
2.20.63 293 4/23/2024
2.20.58 769 3/26/2024
2.20.52 1,224 2/27/2024
2.20.42 6,162 11/28/2023
2.20.40 409 11/14/2023
2.20.37 1,122 10/24/2023
2.20.31 619 10/17/2023
2.19.78 656 10/3/2023
2.19.76 843 9/5/2023
2.19.71 1,703 8/22/2023
2.19.69 779 7/25/2023
2.19.63 1,345 6/20/2023
2.19.58 703 5/16/2023
2.19.53 725 4/21/2023
2.19.48 798 3/21/2023
2.19.39 695 2/21/2023
2.19.36 578 2/7/2023
2.19.35 715 1/24/2023
2.19.33 600 12/20/2022
2.19.22 957 11/1/2022
2.19.16 909 10/4/2022
2.19.15 836 9/13/2022
2.18.112 664 8/30/2022
2.18.108 762 8/8/2022
2.18.96 1,044 6/28/2022
2.18.85 3,019 5/2/2022
2.18.82 646 4/26/2022
2.18.65 1,128 3/22/2022
2.18.56 836 3/1/2022
2.18.37 860 2/8/2022
2.18.2 989 12/14/2021
2.17.80 5,627 11/23/2021
2.17.79 467 11/16/2021
2.17.73 691 11/2/2021
2.17.69 594 10/19/2021
2.17.39 587 10/5/2021
2.17.36 661 9/8/2021
2.14.182 708 8/10/2021
2.14.168 939 6/22/2021
2.14.160 854 5/19/2021
2.14.157 1,355 4/28/2021
2.14.155 1,326 4/6/2021
2.14.154 643 3/23/2021
2.14.147 906 2/23/2021
2.14.143 768 2/9/2021
2.14.142 561 2/2/2021
2.14.134 912 12/22/2020
2.14.131 893 12/9/2020
2.14.128 796 11/30/2020
2.14.120 617 11/18/2020
2.14.99 735 10/27/2020
2.14.93 750 9/21/2020
2.14.78 737 9/1/2020
2.14.53 712 8/3/2020
2.12.41 1,747 5/12/2020