Crestron.SimplSharp.SDK.ProgramLibrary 2.21.90

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

// Install Crestron.SimplSharp.SDK.ProgramLibrary as a Cake Tool
#tool nuget:?package=Crestron.SimplSharp.SDK.ProgramLibrary&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.

NuGet packages (18)

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

Package Downloads
UXAV.AVnet.Core

Package Description

Crestron.SimplSharp.SDK.Program

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.

PepperDash.Essentials.Devices.Common

Package Description

PepperDash.Essentials.Core

Package Description

JBAV

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.21.90 247 12/26/2024
2.21.68 3,254 11/12/2024
2.21.65 1,094 10/30/2024
2.21.54 1,030 10/9/2024
2.20.66 5,699 4/30/2024
2.20.63 572 4/23/2024
2.20.58 1,084 3/26/2024
2.20.52 3,811 2/27/2024
2.20.42 8,823 11/28/2023
2.20.40 1,010 11/14/2023
2.20.37 2,103 10/24/2023
2.20.31 1,252 10/17/2023
2.19.78 1,115 10/3/2023
2.19.76 1,386 9/5/2023
2.19.71 2,239 8/22/2023
2.19.69 1,468 7/25/2023
2.19.63 2,099 6/20/2023
2.19.58 1,624 5/16/2023
2.19.53 1,525 4/21/2023
2.19.48 1,534 3/21/2023
2.19.39 1,382 2/21/2023
2.19.36 1,515 2/7/2023
2.19.35 1,419 1/24/2023
2.19.33 1,418 12/20/2022
2.19.22 1,753 11/1/2022
2.19.16 1,765 10/4/2022
2.19.15 1,743 9/13/2022
2.18.112 1,582 8/30/2022
2.18.108 1,626 8/8/2022
2.18.96 1,975 6/28/2022
2.18.85 4,276 5/2/2022
2.18.82 1,509 4/26/2022
2.18.65 2,264 3/22/2022
2.18.56 1,716 3/1/2022
2.18.37 1,749 2/8/2022
2.18.2 2,285 12/14/2021
2.17.80 6,894 11/23/2021
2.17.79 1,177 11/16/2021
2.17.73 1,430 11/2/2021
2.17.69 1,661 10/19/2021
2.17.39 1,385 10/5/2021
2.17.36 25,718 9/8/2021
2.14.182 1,879 8/10/2021
2.14.168 2,117 6/22/2021
2.14.160 1,916 5/19/2021
2.14.157 2,467 4/28/2021
2.14.155 2,103 4/6/2021
2.14.154 21,156 3/23/2021
2.14.147 1,909 2/23/2021
2.14.143 1,507 2/9/2021
2.14.142 1,406 2/2/2021
2.14.134 1,746 12/22/2020
2.14.131 1,703 12/9/2020
2.14.128 1,622 11/30/2020
2.14.120 1,358 11/18/2020
2.14.99 1,881 10/27/2020
2.14.93 1,742 9/21/2020
2.14.78 1,495 9/1/2020
2.14.53 1,510 8/3/2020
2.12.41 1,714 5/12/2020