Crestron.SimplSharp.SDK.Library 2.21.90

dotnet add package Crestron.SimplSharp.SDK.Library --version 2.21.90                
NuGet\Install-Package Crestron.SimplSharp.SDK.Library -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.Library" 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.Library --version 2.21.90                
#r "nuget: Crestron.SimplSharp.SDK.Library, 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.Library as a Cake Addin
#addin nuget:?package=Crestron.SimplSharp.SDK.Library&version=2.21.90

// Install Crestron.SimplSharp.SDK.Library as a Cake Tool
#tool nuget:?package=Crestron.SimplSharp.SDK.Library&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. 
.NET Framework net47 is compatible.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.7

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages (10)

Showing the top 5 NuGet packages that depend on Crestron.SimplSharp.SDK.Library:

Package Downloads
PepperDashCore

Package Description

Crestron.SimplSharp.SDK.ProgramLibrary

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.

UXAV.Logging

A logging package for Crestron SimplSharp

JBAV

Package Description

WebLogger.Crestron

Provides a web socket servers used to send/receive console communications from an embedded HTML user interface to a application. This was originally created for use on Crestron VC4 but has since been migrated to netstandard for use in native runtime application. Wraps the weblogger for the use within the crestron SDK

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.21.90 345 12/26/2024
2.21.68 5,938 11/12/2024
2.21.65 1,246 10/30/2024
2.21.54 888 10/9/2024
2.20.66 5,598 4/30/2024
2.20.63 551 4/23/2024
2.20.58 1,141 3/26/2024
2.20.52 4,952 2/27/2024
2.20.42 10,297 11/28/2023
2.20.40 1,571 11/14/2023
2.20.37 2,616 10/24/2023
2.20.31 2,125 10/17/2023
2.19.78 2,095 10/3/2023
2.19.76 2,421 9/5/2023
2.19.71 3,179 8/22/2023
2.19.69 2,443 7/25/2023
2.19.63 3,267 6/20/2023
2.19.58 3,988 5/16/2023
2.19.53 2,577 4/21/2023
2.19.48 2,974 3/21/2023
2.19.39 2,641 2/21/2023
2.19.36 2,641 2/7/2023
2.19.35 2,668 1/24/2023
2.19.33 2,473 12/20/2022
2.19.22 2,880 11/1/2022
2.19.16 2,918 10/4/2022
2.19.15 2,940 9/13/2022
2.18.112 2,823 8/30/2022
2.18.108 2,993 8/8/2022
2.18.96 3,299 6/28/2022
2.18.85 5,599 5/2/2022
2.18.82 2,665 4/26/2022
2.18.65 3,574 3/22/2022
2.18.56 2,850 3/1/2022
2.18.37 3,235 2/8/2022
2.18.2 3,383 12/14/2021
2.17.80 8,318 11/23/2021
2.17.79 2,498 11/16/2021
2.17.73 2,762 11/2/2021
2.17.69 2,807 10/19/2021
2.17.39 2,913 10/5/2021
2.17.36 26,332 9/8/2021
2.14.182 2,967 8/10/2021
2.14.168 3,226 6/22/2021
2.14.160 2,980 5/19/2021
2.14.157 3,546 4/28/2021
2.14.155 3,149 4/6/2021
2.14.154 23,414 3/23/2021
2.14.147 3,111 2/23/2021
2.14.143 2,617 2/9/2021
2.14.142 2,360 2/2/2021
2.14.134 2,795 12/22/2020
2.14.131 2,660 12/9/2020
2.14.128 2,587 11/30/2020
2.14.120 2,419 11/18/2020
2.14.99 3,012 10/27/2020
2.14.93 2,777 9/21/2020
2.14.78 2,567 9/1/2020
2.14.53 2,604 8/3/2020
2.12.41 2,306 5/12/2020