├── SG
├── Part7
│ ├── Properties
│ │ ├── ControlSystem.cfg
│ │ └── AssemblyInfo.cs
│ ├── SG Primer XPANEL.vtp
│ ├── Part7.csproj
│ ├── SG Primer XPANEL.sgd
│ └── ControlSystem.cs
└── SgProDemo.sln
├── Part2
├── Part2
│ ├── Properties
│ │ ├── ControlSystem.cfg
│ │ └── AssemblyInfo.cs
│ ├── Part2.csproj.user
│ ├── Part2.csproj
│ └── ControlSystem.cs
├── Touchpanel
│ └── Part2_TSW-1060.vtp
└── Part2.sln
├── Primer
├── Part3
│ ├── Properties
│ │ ├── ControlSystem.cfg
│ │ └── AssemblyInfo.cs
│ ├── Part3_TSW-1060_v1.vtp
│ ├── Samsung BD Series.ir
│ ├── Part3.csproj.user
│ ├── Part3.csproj
│ └── ControlSystem.cs
├── Part4
│ ├── Properties
│ │ ├── ControlSystem.cfg
│ │ └── AssemblyInfo.cs
│ ├── Part4.csproj.user
│ ├── ControlSystem.cs
│ └── Part4.csproj
├── Part5
│ ├── Properties
│ │ ├── ControlSystem.cfg
│ │ └── AssemblyInfo.cs
│ ├── Part5.csproj.user
│ ├── Part5.csproj
│ └── ControlSystem.cs
└── Primer.sln
├── CleanUpExample
├── .gitignore
├── packages.config
├── CleanUpExample.sln
├── Properties
│ └── AssemblyInfo.cs
├── ControlSystem.cs
└── CleanUpExample.csproj
├── .gitattributes
├── .gitignore
├── Part1
├── Part1
│ ├── Part1.csproj.user
│ ├── Properties
│ │ ├── ControlSystem.cfg
│ │ └── AssemblyInfo.cs
│ ├── ControlSystem.cs
│ └── Part1.csproj
└── Part1.sln
├── README.md
└── LICENSE
/SG/Part7/Properties/ControlSystem.cfg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Part2/Part2/Properties/ControlSystem.cfg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Primer/Part3/Properties/ControlSystem.cfg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Primer/Part4/Properties/ControlSystem.cfg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Primer/Part5/Properties/ControlSystem.cfg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/CleanUpExample/.gitignore:
--------------------------------------------------------------------------------
1 | .vs/
2 | packages/
3 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/SG/Part7/SG Primer XPANEL.vtp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kielthecoder/SimplSharpPrimer/HEAD/SG/Part7/SG Primer XPANEL.vtp
--------------------------------------------------------------------------------
/Primer/Part3/Part3_TSW-1060_v1.vtp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kielthecoder/SimplSharpPrimer/HEAD/Primer/Part3/Part3_TSW-1060_v1.vtp
--------------------------------------------------------------------------------
/Primer/Part3/Samsung BD Series.ir:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kielthecoder/SimplSharpPrimer/HEAD/Primer/Part3/Samsung BD Series.ir
--------------------------------------------------------------------------------
/Part2/Touchpanel/Part2_TSW-1060.vtp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kielthecoder/SimplSharpPrimer/HEAD/Part2/Touchpanel/Part2_TSW-1060.vtp
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
3 | *.ASV
4 | *.cache
5 | *.csproj.user
6 | *.hash
7 | *.pdb
8 | *.projectinfo
9 | *.suo
10 | *.vtz
11 | *.air
12 | *.exe
13 | *.c3p
14 |
--------------------------------------------------------------------------------
/Part1/Part1/Part1.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 | E282E6BE-C7C3-4ece-916A-88FB1CF8AF3C
4 |
5 |
--------------------------------------------------------------------------------
/Part2/Part2/Part2.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 | E282E6BE-C7C3-4ece-916A-88FB1CF8AF3C
4 |
5 |
--------------------------------------------------------------------------------
/Primer/Part3/Part3.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 | E282E6BE-C7C3-4ece-916A-88FB1CF8AF3C
4 |
5 |
--------------------------------------------------------------------------------
/Primer/Part4/Part4.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 | E282E6BE-C7C3-4ece-916A-88FB1CF8AF3C
4 |
5 |
--------------------------------------------------------------------------------
/Primer/Part5/Part5.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 | E282E6BE-C7C3-4ece-916A-88FB1CF8AF3C
4 |
5 |
--------------------------------------------------------------------------------
/Part1/Part1/Properties/ControlSystem.cfg:
--------------------------------------------------------------------------------
1 |
2 |
3 | PRO3_CS
4 | ssh 172.22.0.1
5 |
6 | Internal Flash
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SimplSharpPrimer
2 | A SIMPL# Pro Primer
3 |
4 | This repository provides access to the code and touchpanel layouts that we'll generate by following the primer at https://kielthecoder.com/tag/primer/
5 |
6 | More parts will be added as the series develops on my blog.
7 |
--------------------------------------------------------------------------------
/SG/Part7/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("Part7")]
4 | [assembly: AssemblyCompany("")]
5 | [assembly: AssemblyProduct("Part7")]
6 | [assembly: AssemblyCopyright("Copyright © 2020")]
7 | [assembly: AssemblyVersion("1.0.0.*")]
8 |
9 |
--------------------------------------------------------------------------------
/Part1/Part1/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("Part1")]
4 | [assembly: AssemblyCompany("")]
5 | [assembly: AssemblyProduct("Part1")]
6 | [assembly: AssemblyCopyright("Copyright © 2020")]
7 | [assembly: AssemblyVersion("1.0.0.*")]
8 |
9 |
--------------------------------------------------------------------------------
/Part2/Part2/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("Part2")]
4 | [assembly: AssemblyCompany("")]
5 | [assembly: AssemblyProduct("Part2")]
6 | [assembly: AssemblyCopyright("Copyright © 2020")]
7 | [assembly: AssemblyVersion("1.0.0.*")]
8 |
9 |
--------------------------------------------------------------------------------
/Primer/Part3/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("Part3")]
4 | [assembly: AssemblyCompany("")]
5 | [assembly: AssemblyProduct("Part3")]
6 | [assembly: AssemblyCopyright("Copyright © 2020")]
7 | [assembly: AssemblyVersion("1.0.0.*")]
8 |
9 |
--------------------------------------------------------------------------------
/Primer/Part4/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("Part4")]
4 | [assembly: AssemblyCompany("")]
5 | [assembly: AssemblyProduct("Part4")]
6 | [assembly: AssemblyCopyright("Copyright © 2020")]
7 | [assembly: AssemblyVersion("1.0.0.*")]
8 |
9 |
--------------------------------------------------------------------------------
/Primer/Part5/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("Part5")]
4 | [assembly: AssemblyCompany("")]
5 | [assembly: AssemblyProduct("Part5")]
6 | [assembly: AssemblyCopyright("Copyright © 2020")]
7 | [assembly: AssemblyVersion("1.0.0.*")]
8 |
9 |
--------------------------------------------------------------------------------
/CleanUpExample/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Part1/Part1/ControlSystem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Crestron.SimplSharp;
3 | using Crestron.SimplSharpPro;
4 | using Crestron.SimplSharpPro.CrestronThread;
5 |
6 | namespace Part1
7 | {
8 | public class ControlSystem : CrestronControlSystem
9 | {
10 | public ControlSystem()
11 | : base()
12 | {
13 | Thread.MaxNumberOfUserThreads = 10;
14 | }
15 |
16 | public override void InitializeSystem()
17 | {
18 | CrestronConsole.PrintLine("\n Hello world! \n");
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/Part1/Part1.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Part1", "Part1\Part1.csproj", "{E191A86E-D2B1-4F4F-8649-F5B1F87635E6}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {E191A86E-D2B1-4F4F-8649-F5B1F87635E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {E191A86E-D2B1-4F4F-8649-F5B1F87635E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {E191A86E-D2B1-4F4F-8649-F5B1F87635E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {E191A86E-D2B1-4F4F-8649-F5B1F87635E6}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/Part2/Part2.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Part2", "Part2\Part2.csproj", "{FAEC73D2-1B74-4FD6-A828-FCEB78C26474}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {FAEC73D2-1B74-4FD6-A828-FCEB78C26474}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {FAEC73D2-1B74-4FD6-A828-FCEB78C26474}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {FAEC73D2-1B74-4FD6-A828-FCEB78C26474}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {FAEC73D2-1B74-4FD6-A828-FCEB78C26474}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/SG/SgProDemo.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Part7", "Part7\Part7.csproj", "{2786020C-EB75-439F-9209-C4CA1875241D}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {2786020C-EB75-439F-9209-C4CA1875241D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {2786020C-EB75-439F-9209-C4CA1875241D}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {2786020C-EB75-439F-9209-C4CA1875241D}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {2786020C-EB75-439F-9209-C4CA1875241D}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Kiel Lofstrand
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/CleanUpExample/CleanUpExample.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.6.33723.286
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CleanUpExample", "CleanUpExample.csproj", "{F0B45EF7-F702-4909-828F-C6D08E2C84F5}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {F0B45EF7-F702-4909-828F-C6D08E2C84F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {F0B45EF7-F702-4909-828F-C6D08E2C84F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {F0B45EF7-F702-4909-828F-C6D08E2C84F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {F0B45EF7-F702-4909-828F-C6D08E2C84F5}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {2448BCFD-9A11-42EB-906E-C413D9A82C70}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/CleanUpExample/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("CleanUpExample")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("CleanUpExample")]
13 | [assembly: AssemblyCopyright("Copyright © 2023")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f0b45ef7-f702-4909-828f-c6d08e2c84f5")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Primer/Primer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Part3", "Part3\Part3.csproj", "{B153B472-5D78-4FDB-A770-E4FF8C06E709}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Part4", "Part4\Part4.csproj", "{114D2459-413D-4CAA-BF87-52F0B4D28B31}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Part5", "Part5\Part5.csproj", "{4E5A42F6-7CD9-459E-AA1B-94747ABA36AA}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {B153B472-5D78-4FDB-A770-E4FF8C06E709}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {B153B472-5D78-4FDB-A770-E4FF8C06E709}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {B153B472-5D78-4FDB-A770-E4FF8C06E709}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {B153B472-5D78-4FDB-A770-E4FF8C06E709}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {114D2459-413D-4CAA-BF87-52F0B4D28B31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {114D2459-413D-4CAA-BF87-52F0B4D28B31}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {114D2459-413D-4CAA-BF87-52F0B4D28B31}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {114D2459-413D-4CAA-BF87-52F0B4D28B31}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {4E5A42F6-7CD9-459E-AA1B-94747ABA36AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {4E5A42F6-7CD9-459E-AA1B-94747ABA36AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {4E5A42F6-7CD9-459E-AA1B-94747ABA36AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {4E5A42F6-7CD9-459E-AA1B-94747ABA36AA}.Release|Any CPU.Build.0 = Release|Any CPU
28 | EndGlobalSection
29 | GlobalSection(SolutionProperties) = preSolution
30 | HideSolutionNode = FALSE
31 | EndGlobalSection
32 | EndGlobal
33 |
--------------------------------------------------------------------------------
/CleanUpExample/ControlSystem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Crestron.SimplSharp; // For Basic SIMPL# Classes
3 | using Crestron.SimplSharpPro; // For Basic SIMPL#Pro classes
4 | using Crestron.SimplSharpPro.CrestronThread; // For Threading
5 | using Crestron.SimplSharpPro.Diagnostics; // For System Monitor Access
6 | using Crestron.SimplSharpPro.DeviceSupport; // For Generic Device Support
7 |
8 | namespace CleanUpExample
9 | {
10 | public class ControlSystem : CrestronControlSystem
11 | {
12 | private Thread _unstoppable;
13 | private bool _running;
14 |
15 | public ControlSystem() : base()
16 | {
17 | try
18 | {
19 | Thread.MaxNumberOfUserThreads = 20;
20 |
21 | CrestronEnvironment.ProgramStatusEventHandler += ProgramEventHandler;
22 | }
23 | catch (Exception e)
24 | {
25 | ErrorLog.Error("Error in the constructor: {0}", e.Message);
26 | }
27 | }
28 |
29 | public override void InitializeSystem()
30 | {
31 | try
32 | {
33 | _unstoppable = new Thread(InfiniteLoop, null);
34 | }
35 | catch (Exception e)
36 | {
37 | ErrorLog.Error("Error in InitializeSystem: {0}", e.Message);
38 | }
39 | }
40 |
41 | void ProgramEventHandler(eProgramStatusEventType type)
42 | {
43 | if (type == eProgramStatusEventType.Stopping)
44 | _running = false;
45 | }
46 |
47 | object InfiniteLoop(object userObj)
48 | {
49 | var toggle = false;
50 |
51 | Thread.Sleep(1000);
52 | CrestronConsole.PrintLine("Starting our loop: ");
53 |
54 | _running = true;
55 | while (_running)
56 | {
57 | toggle = !toggle;
58 | Thread.Sleep(1500);
59 |
60 | if (toggle)
61 | CrestronConsole.Print("/");
62 | else
63 | CrestronConsole.Print("\\");
64 | }
65 |
66 | CrestronConsole.PrintLine("Out of the loop!");
67 |
68 | return null;
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/Primer/Part4/ControlSystem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Crestron.SimplSharp;
3 | using Crestron.SimplSharpPro;
4 | using Crestron.SimplSharpPro.CrestronThread;
5 | using Crestron.SimplSharpPro.Diagnostics;
6 | using Crestron.SimplSharpPro.DeviceSupport;
7 |
8 | namespace Part4
9 | {
10 | public class ControlSystem : CrestronControlSystem
11 | {
12 | public ControlSystem()
13 | : base()
14 | {
15 | try
16 | {
17 | Thread.MaxNumberOfUserThreads = 20;
18 | }
19 | catch (Exception e)
20 | {
21 | ErrorLog.Error("Error in ControlSystem constructor: {0}", e.StackTrace);
22 | }
23 | }
24 |
25 | public override void InitializeSystem()
26 | {
27 | try
28 | {
29 | if (!CrestronConsole.AddNewConsoleCommand(ControlSystemInfo,
30 | "controllerinfo", "Print information about this control system",
31 | ConsoleAccessLevelEnum.AccessOperator))
32 | {
33 | ErrorLog.Error("Unable to add 'controllerinfo' command to console");
34 | }
35 | }
36 | catch (Exception e)
37 | {
38 | ErrorLog.Error("Error in InitializeSystem: {0}", e.StackTrace);
39 | }
40 | }
41 |
42 | public void ControlSystemInfo(string parms)
43 | {
44 | if (parms == "?")
45 | {
46 | CrestronConsole.ConsoleCommandResponse("CONTROLLERINFO\n\r\tNo parameters needed.\n\r");
47 | }
48 | else
49 | {
50 | CrestronConsole.ConsoleCommandResponse("Controller prompt: {0}\n\r", this.ControllerPrompt);
51 | CrestronConsole.ConsoleCommandResponse("Number of serial ports: {0}\n\r", this.NumberOfComPorts);
52 | CrestronConsole.ConsoleCommandResponse("Number of IR ports: {0}\n\r", this.NumberOfIROutputPorts);
53 |
54 | if (this.SupportsRelay)
55 | CrestronConsole.ConsoleCommandResponse("Number of relay ports: {0}\n\r", this.NumberOfRelayPorts);
56 | if (this.SupportsDigitalInput)
57 | CrestronConsole.ConsoleCommandResponse("Number of digital inputs: {0}\n\r", this.NumberOfDigitalInputPorts);
58 | if (this.SupportsVersiport)
59 | CrestronConsole.ConsoleCommandResponse("Number of versiports: {0}\n\r", this.NumberOfVersiPorts);
60 |
61 | CrestronConsole.ConsoleCommandResponse("Internal RF Gateway: {0}\n\r", this.SupportsInternalRFGateway ? "YES" : "NO");
62 |
63 | // Check if built-in DM switcher
64 | if (this.SystemControl != null)
65 | {
66 | CrestronConsole.ConsoleCommandResponse("System ID: {0}\n\r", this.SystemControl.SystemId);
67 |
68 | if (this.SupportsSwitcherInputs)
69 | CrestronConsole.ConsoleCommandResponse("Number of switcher inputs: {0}\n\r", this.NumberOfSwitcherInputs);
70 | if (this.SupportsSwitcherOutputs)
71 | CrestronConsole.ConsoleCommandResponse("Number of switcher outputs: {0}\n\r", this.NumberOfSwitcherOutputs);
72 | }
73 | }
74 | }
75 | }
76 | }
--------------------------------------------------------------------------------
/Part1/Part1/Part1.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Release
4 | AnyCPU
5 | 9.0.30729
6 | 2.0
7 | {E191A86E-D2B1-4F4F-8649-F5B1F87635E6}
8 | Library
9 | Properties
10 | Part1
11 | Part1
12 | {0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
13 | WindowsCE
14 | E2BECB1F-8C8C-41ba-B736-9BE7D946A398
15 | 5.0
16 | SmartDeviceProject1
17 | v3.5
18 | Windows CE
19 |
20 |
21 |
22 |
23 | .allowedReferenceRelatedFileExtensions
24 | true
25 | full
26 | false
27 | bin\Debug\
28 | DEBUG;TRACE;
29 | prompt
30 | 4
31 | 512
32 | true
33 | true
34 | off
35 |
36 |
37 | .allowedReferenceRelatedFileExtensions
38 | none
39 | true
40 | bin\Release\
41 | prompt
42 | 4
43 | 512
44 | true
45 | true
46 | off
47 |
48 |
49 |
50 | False
51 | ..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll
52 |
53 |
54 |
55 | False
56 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll
57 |
58 |
59 | False
60 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll
61 |
62 |
63 | False
64 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | rem S# Pro preparation will execute after these operations
78 |
79 |
--------------------------------------------------------------------------------
/Part2/Part2/Part2.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Release
4 | AnyCPU
5 | 9.0.30729
6 | 2.0
7 | {FAEC73D2-1B74-4FD6-A828-FCEB78C26474}
8 | Library
9 | Properties
10 | Part2
11 | Part2
12 | {0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
13 | WindowsCE
14 | E2BECB1F-8C8C-41ba-B736-9BE7D946A398
15 | 5.0
16 | SmartDeviceProject1
17 | v3.5
18 | Windows CE
19 |
20 |
21 |
22 |
23 | .allowedReferenceRelatedFileExtensions
24 | true
25 | full
26 | false
27 | bin\Debug\
28 | DEBUG;TRACE;
29 | prompt
30 | 4
31 | 512
32 | true
33 | true
34 | off
35 |
36 |
37 | .allowedReferenceRelatedFileExtensions
38 | none
39 | true
40 | bin\Release\
41 | prompt
42 | 4
43 | 512
44 | true
45 | true
46 | off
47 |
48 |
49 |
50 | False
51 | ..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll
52 |
53 |
54 | False
55 | ..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll
56 |
57 |
58 |
59 | False
60 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll
61 |
62 |
63 | False
64 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll
65 |
66 |
67 | False
68 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | rem S# Pro preparation will execute after these operations
82 |
83 |
--------------------------------------------------------------------------------
/Primer/Part4/Part4.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Release
4 | AnyCPU
5 | 9.0.30729
6 | 2.0
7 | {114D2459-413D-4CAA-BF87-52F0B4D28B31}
8 | Library
9 | Properties
10 | Part4
11 | Part4
12 | {0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
13 | WindowsCE
14 | E2BECB1F-8C8C-41ba-B736-9BE7D946A398
15 | 5.0
16 | SmartDeviceProject1
17 | v3.5
18 | Windows CE
19 |
20 |
21 |
22 |
23 | .allowedReferenceRelatedFileExtensions
24 | true
25 | full
26 | false
27 | bin\Debug\
28 | DEBUG;TRACE;
29 | prompt
30 | 4
31 | 512
32 | true
33 | true
34 | off
35 |
36 |
37 | .allowedReferenceRelatedFileExtensions
38 | none
39 | true
40 | bin\Release\
41 | prompt
42 | 4
43 | 512
44 | true
45 | true
46 | off
47 |
48 |
49 |
50 | False
51 | ..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll
52 |
53 |
54 | False
55 | ..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll
56 |
57 |
58 |
59 | False
60 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll
61 |
62 |
63 | False
64 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll
65 |
66 |
67 | False
68 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | rem S# Pro preparation will execute after these operations
82 |
83 |
--------------------------------------------------------------------------------
/Primer/Part5/Part5.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Release
4 | AnyCPU
5 | 9.0.30729
6 | 2.0
7 | {4E5A42F6-7CD9-459E-AA1B-94747ABA36AA}
8 | Library
9 | Properties
10 | Part5
11 | Part5
12 | {0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
13 | WindowsCE
14 | E2BECB1F-8C8C-41ba-B736-9BE7D946A398
15 | 5.0
16 | SmartDeviceProject1
17 | v3.5
18 | Windows CE
19 |
20 |
21 |
22 |
23 | .allowedReferenceRelatedFileExtensions
24 | true
25 | full
26 | false
27 | bin\Debug\
28 | DEBUG;TRACE;
29 | prompt
30 | 4
31 | 512
32 | true
33 | true
34 | off
35 |
36 |
37 | .allowedReferenceRelatedFileExtensions
38 | none
39 | true
40 | bin\Release\
41 | prompt
42 | 4
43 | 512
44 | true
45 | true
46 | off
47 |
48 |
49 |
50 | False
51 | ..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll
52 |
53 |
54 | False
55 | ..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll
56 |
57 |
58 |
59 | False
60 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll
61 |
62 |
63 | False
64 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll
65 |
66 |
67 | False
68 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | rem S# Pro preparation will execute after these operations
82 |
83 |
--------------------------------------------------------------------------------
/SG/Part7/Part7.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Release
4 | AnyCPU
5 | 9.0.30729
6 | 2.0
7 | {2786020C-EB75-439F-9209-C4CA1875241D}
8 | Library
9 | Properties
10 | Part7
11 | Part7
12 | {0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
13 | WindowsCE
14 | E2BECB1F-8C8C-41ba-B736-9BE7D946A398
15 | 5.0
16 | SmartDeviceProject1
17 | v3.5
18 | Windows CE
19 |
20 |
21 |
22 |
23 | .allowedReferenceRelatedFileExtensions
24 | true
25 | full
26 | false
27 | bin\Debug\
28 | DEBUG;TRACE;
29 | prompt
30 | 4
31 | 512
32 | true
33 | true
34 | off
35 |
36 |
37 | .allowedReferenceRelatedFileExtensions
38 | none
39 | true
40 | bin\Release\
41 | prompt
42 | 4
43 | 512
44 | true
45 | true
46 | off
47 |
48 |
49 |
50 | False
51 | ..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll
52 |
53 |
54 | False
55 | ..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll
56 |
57 |
58 |
59 | False
60 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll
61 |
62 |
63 | False
64 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll
65 |
66 |
67 | False
68 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | Always
80 |
81 |
82 |
83 |
84 | rem S# Pro preparation will execute after these operations
85 |
86 |
--------------------------------------------------------------------------------
/Primer/Part3/Part3.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Release
4 | AnyCPU
5 | 9.0.30729
6 | 2.0
7 | {B153B472-5D78-4FDB-A770-E4FF8C06E709}
8 | Library
9 | Properties
10 | Part3
11 | Part3
12 | {0B4745B0-194B-4BB6-8E21-E9057CA92230};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
13 | WindowsCE
14 | E2BECB1F-8C8C-41ba-B736-9BE7D946A398
15 | 5.0
16 | SmartDeviceProject1
17 | v3.5
18 | Windows CE
19 |
20 |
21 |
22 |
23 | .allowedReferenceRelatedFileExtensions
24 | true
25 | full
26 | false
27 | bin\Debug\
28 | DEBUG;TRACE;
29 | prompt
30 | 4
31 | 512
32 | true
33 | true
34 | off
35 |
36 |
37 | .allowedReferenceRelatedFileExtensions
38 | none
39 | true
40 | bin\Release\
41 | prompt
42 | 4
43 | 512
44 | true
45 | true
46 | off
47 |
48 |
49 |
50 | False
51 | ..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll
52 |
53 |
54 | False
55 | ..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll
56 |
57 |
58 | False
59 | ..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll
60 |
61 |
62 |
63 | False
64 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll
65 |
66 |
67 | False
68 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll
69 |
70 |
71 | False
72 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | PreserveNewest
84 |
85 |
86 |
87 |
88 | rem S# Pro preparation will execute after these operations
89 |
90 |
--------------------------------------------------------------------------------
/Primer/Part3/ControlSystem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Crestron.SimplSharp;
4 | using Crestron.SimplSharp.CrestronIO;
5 | using Crestron.SimplSharpPro;
6 | using Crestron.SimplSharpPro.CrestronThread;
7 | using Crestron.SimplSharpPro.DeviceSupport;
8 | using Crestron.SimplSharpPro.DM;
9 | using Crestron.SimplSharpPro.DM.Cards;
10 | using Crestron.SimplSharpPro.DM.Endpoints.Receivers;
11 | using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
12 | using Crestron.SimplSharpPro.UI;
13 |
14 | namespace Part3
15 | {
16 | public class ControlSystem : CrestronControlSystem
17 | {
18 | private Tsw1050 _tp;
19 | private Switch _sw;
20 | private List _inputs;
21 | private List _outputs;
22 |
23 | private DmTx4K100C1G _tx;
24 | private DmRmc4k100C _rx;
25 |
26 | public ControlSystem()
27 | : base()
28 | {
29 | Thread.MaxNumberOfUserThreads = 20;
30 | }
31 |
32 | public override void InitializeSystem()
33 | {
34 | _tp = new Tsw1050(0x03, this);
35 | _tp.SigChange += new SigEventHandler(_tp_SigChange);
36 | _tp.Register();
37 |
38 | _inputs = new List();
39 | _outputs = new List();
40 |
41 | _sw = new DmMd8x8(0x10, this);
42 | _inputs.Add(new Dmc4kC(1, _sw));
43 | _outputs.Add(new DmcCoHdSingle(1, _sw));
44 |
45 | _tx = new DmTx4K100C1G(0x14, _sw.Inputs[1]);
46 | _tx.OnlineStatusChange +=new OnlineStatusChangeEventHandler(_tx_OnlineStatusChange);
47 |
48 | _rx = new DmRmc4k100C(0x15, _sw.Outputs[1]);
49 | _rx.OnlineStatusChange += new OnlineStatusChangeEventHandler(_rx_OnlineStatusChange);
50 |
51 | _sw.OnlineStatusChange += new OnlineStatusChangeEventHandler(_sw_OnlineStatusChange);
52 | _sw.Register();
53 | }
54 |
55 | void _tp_SigChange(BasicTriList currentDevice, SigEventArgs args)
56 | {
57 | if (args.Sig.Type == eSigType.Bool)
58 | {
59 | // Display controls
60 | if (args.Sig.Number > 20 && args.Sig.Number < 30)
61 | {
62 | _tp_DisplayControl(currentDevice, args.Sig.Number - 20, args.Sig.BoolValue);
63 | }
64 |
65 | // Blu-ray controls
66 | if (args.Sig.Number > 30 && args.Sig.Number < 50)
67 | {
68 | _tp_BluRayControl(currentDevice, args.Sig.Number - 30, args.Sig.BoolValue);
69 | }
70 | }
71 | }
72 |
73 | void _tp_DisplayControl(BasicTriList device, uint number, bool value)
74 | {
75 | if (value)
76 | {
77 | switch (number)
78 | {
79 | case 1: // Power On
80 | _rx.ComPorts[1].Send("\xAA\x11\x01\x01\x01\x14");
81 | break;
82 | case 2: // Power Off
83 | _rx.ComPorts[1].Send("\xAA\x11\x01\x01\x00\x13");
84 | break;
85 | case 3: // HDMI
86 | _rx.ComPorts[1].Send("\xAA\x14\x01\x01\x21\x37");
87 | break;
88 | }
89 | }
90 | }
91 |
92 | void _tp_BluRayControl(BasicTriList device, uint number, bool value)
93 | {
94 | string[] commands = {
95 | "",
96 | "PLAY", "STOP", "PAUSE",
97 | "RSCAN", "FSCAN", "TRACK-", "TRACK+",
98 | "UP_ARROW", "DN_ARROW", "LEFT_ARROW", "RIGHT_ARROW", "ENTER/SELECT"
99 | };
100 |
101 | if (value)
102 | _tx.IROutputPorts[1].Press(commands[number]);
103 | else
104 | _tx.IROutputPorts[1].Release();
105 | }
106 |
107 | void _sw_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
108 | {
109 | }
110 |
111 | void _tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
112 | {
113 | if (args.DeviceOnLine)
114 | {
115 | (currentDevice as DmTx4K100C1G).IROutputPorts[1].LoadIRDriver(Directory.GetApplicationDirectory() + Path.PathSeparator + "Samsung BD Series.ir");
116 | }
117 | }
118 |
119 | void _rx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
120 | {
121 | if (args.DeviceOnLine)
122 | {
123 | (currentDevice as DmRmc4k100C).ComPorts[1].SetComPortSpec(ComPort.eComBaudRates.ComspecBaudRate9600,
124 | ComPort.eComDataBits.ComspecDataBits8, ComPort.eComParityType.ComspecParityNone, ComPort.eComStopBits.ComspecStopBits1,
125 | ComPort.eComProtocolType.ComspecProtocolRS232, ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone,
126 | ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone, false);
127 | }
128 | }
129 | }
130 | }
--------------------------------------------------------------------------------
/Primer/Part5/ControlSystem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Crestron.SimplSharp;
3 | using Crestron.SimplSharpPro;
4 | using Crestron.SimplSharpPro.CrestronThread;
5 | using Crestron.SimplSharpPro.Diagnostics;
6 | using Crestron.SimplSharpPro.DeviceSupport;
7 | using Crestron.SimplSharpPro.DM;
8 | using Crestron.SimplSharpPro.DM.Cards;
9 | using Crestron.SimplSharpPro.DM.Endpoints;
10 | using Crestron.SimplSharpPro.DM.Endpoints.Receivers;
11 | using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
12 |
13 | namespace Part5
14 | {
15 | public class ControlSystem : CrestronControlSystem
16 | {
17 | public const uint NumberOfSources = 2;
18 |
19 | // Samsung MDC protocol
20 | public const string PowerOn = "\xAA\x11\x01\x01\x01\x14";
21 | public const string PowerOff = "\xAA\x11\x01\x01\x00\x13";
22 |
23 | private DMInput[] _source;
24 | private bool[] _sourceAvailable;
25 |
26 | private DmTx200C2G _tx1;
27 | private DmTx200C2G _tx2;
28 | private DmRmcScalerC _rmc1;
29 |
30 | public ControlSystem()
31 | : base()
32 | {
33 | try
34 | {
35 | Thread.MaxNumberOfUserThreads = 20;
36 |
37 | _sourceAvailable = new bool[NumberOfSources];
38 | _source = new DMInput[NumberOfSources];
39 | }
40 | catch (Exception e)
41 | {
42 | ErrorLog.Error("Error in ControlSystem constructor: {0}", e.StackTrace);
43 | }
44 | }
45 |
46 | public override void InitializeSystem()
47 | {
48 | try
49 | {
50 | // Currently only runs on DMPS architecture
51 | if (this.SystemControl == null)
52 | {
53 | // Eventually we'll handle external switchers, too
54 | ErrorLog.Error("Sorry, this program only runs on DMPS3 processors!");
55 | }
56 | else
57 | {
58 | var control = this.SystemControl as Dmps3SystemControl;
59 | control.SystemPowerOn();
60 |
61 | // Samsung MDC = 9600 baud, 8 data bits, no parity, 1 stop bit
62 | var displayComSettings = new ComPort.ComPortSpec();
63 | displayComSettings.Protocol = ComPort.eComProtocolType.ComspecProtocolRS232;
64 | displayComSettings.BaudRate = ComPort.eComBaudRates.ComspecBaudRate9600;
65 | displayComSettings.DataBits = ComPort.eComDataBits.ComspecDataBits8;
66 | displayComSettings.Parity = ComPort.eComParityType.ComspecParityNone;
67 | displayComSettings.StopBits = ComPort.eComStopBits.ComspecStopBits1;
68 | displayComSettings.HardwareHandShake = ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone;
69 | displayComSettings.SoftwareHandshake = ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone;
70 |
71 | // Assume DM transmitter is connected to DM input 6
72 | _source[0] = this.SwitcherInputs[6] as DMInput;
73 | _tx1 = new DmTx200C2G(0x14, _source[0]);
74 | _tx1.HdmiInput.InputStreamChange += new EndpointInputStreamChangeEventHandler((input, args) => tx_InputStreamChange(0, input, args));
75 | _tx1.VgaInput.InputStreamChange += new EndpointInputStreamChangeEventHandler((input, args) => tx_InputStreamChange(0, input, args));
76 |
77 | // Assume DM transmitter is connected to DM input 7
78 | _source[1] = this.SwitcherInputs[7] as DMInput;
79 | _tx2 = new DmTx200C2G(0x15, _source[1]);
80 | _tx2.HdmiInput.InputStreamChange += new EndpointInputStreamChangeEventHandler((input, args) => tx_InputStreamChange(1, input, args));
81 | _tx2.VgaInput.InputStreamChange += new EndpointInputStreamChangeEventHandler((input, args) => tx_InputStreamChange(1, input, args));
82 |
83 | // Assume DM roombox is connected to DM output 3
84 | _rmc1 = new DmRmcScalerC(0x16, this.SwitcherOutputs[3] as DMOutput);
85 | _rmc1.ComPorts[1].SetComPortSpec(displayComSettings);
86 | }
87 | }
88 | catch (Exception e)
89 | {
90 | ErrorLog.Error("Error in InitializeSystem: {0}", e.StackTrace);
91 | }
92 | }
93 |
94 | void tx_InputStreamChange(uint src, EndpointInputStream inputStream, EndpointInputStreamEventArgs args)
95 | {
96 | if (args.EventId == EndpointInputStreamEventIds.SyncDetectedFeedbackEventId)
97 | {
98 | switch (inputStream.StreamType)
99 | {
100 | case eDmStreamType.Hdmi:
101 | var hdmiStream = inputStream as EndpointHdmiInput;
102 | _sourceAvailable[src] = hdmiStream.SyncDetectedFeedback.BoolValue;
103 | if (_sourceAvailable[src])
104 | CrestronConsole.PrintLine("HDMI detected on source {0}", src);
105 | else
106 | CrestronConsole.PrintLine("HDMI not detected on source {0}", src);
107 | break;
108 | case eDmStreamType.Vga:
109 | var vgaStream = inputStream as EndpointVgaInput;
110 | _sourceAvailable[src] = vgaStream.SyncDetectedFeedback.BoolValue;
111 | if (_sourceAvailable[src])
112 | CrestronConsole.PrintLine("VGA detected on source {0}", src);
113 | else
114 | CrestronConsole.PrintLine("VGA not detected on source {0}", src);
115 | break;
116 | }
117 | AutoRouteVideo();
118 | }
119 | }
120 |
121 | void AutoRouteVideo()
122 | {
123 | for (uint i = 0; i < NumberOfSources; i++)
124 | {
125 | if (_sourceAvailable[i])
126 | {
127 | // Make route and power on display
128 | (this.SwitcherOutputs[3] as DMOutput).VideoOut = _source[i];
129 | _rmc1.ComPorts[1].Send(PowerOn);
130 | return;
131 | }
132 | }
133 |
134 | // Clear route and power off display
135 | (this.SwitcherOutputs[3] as DMOutput).VideoOut = null;
136 | _rmc1.ComPorts[1].Send(PowerOff);
137 | }
138 | }
139 | }
--------------------------------------------------------------------------------
/SG/Part7/SG Primer XPANEL.sgd:
--------------------------------------------------------------------------------
1 | [
2 | ObjTp=FSgntr
3 | Sgntr=SGD
4 | RelVrs=3
5 | VTProeVer=6.2.02
6 | Schema=1
7 | CRCGUID=957EE686-8427-4A41-ADF8-FD6224586131
8 | ]
9 | ;================================================================================
10 | [
11 | ObjTp=Hd
12 | ProjectFile=SG Primer XPANEL.vtp
13 | VtpGuid=39B3C6D1-D415-4151-B5E7-1EDC912FFCAC
14 | ]
15 | ;================================================================================
16 | [
17 | ObjTp=Symbol
18 | Name=SG Primer XPANEL_Menu_Menu List.ced
19 | Hint=Menu List (Smart Object ID=1)
20 | Code=1
21 | SGControlType=Icon List Horizontal
22 | SGControlName=Menu List
23 | GUID=AB6F699E-7EB8-4741-86D7-729EE50184FC
24 | SmplCName=SG Primer XPANEL_Menu_Menu List.ced
25 | SMWRev=4.02.19
26 | Expand=expand_random
27 | HelpID=10032
28 | ;Define the number of inputs, outputs and parameters
29 | MinVariableInputs=3
30 | MaxVariableInputs=3
31 | MinVariableOutputs=3
32 | MaxVariableOutputs=3
33 | NumFixedParams=1
34 | MinVariableInputsList2=6
35 | MaxVariableInputsList2=6
36 | MinVariableOutputsList2=6
37 | MaxVariableOutputsList2=6
38 | MinVariableInputsList3=0
39 | MaxVariableInputsList3=0
40 | MinVariableOutputsList3=0
41 | MaxVariableOutputsList3=0
42 | ;Define the cues, and signal types each input, output and parameter.
43 | InputCue1=[~UNUSED3~]
44 | InputSigType1=Digital
45 | OutputCue1=Item 1 Pressed
46 | OutputSigType1=Digital
47 | InputCue2=[~UNUSED3~]
48 | InputSigType2=Digital
49 | OutputCue2=Item 2 Pressed
50 | OutputSigType2=Digital
51 | InputCue3=[~UNUSED3~]
52 | InputSigType3=Digital
53 | OutputCue3=Item 3 Pressed
54 | OutputSigType3=Digital
55 | InputList2Cue1=Select Item
56 | InputList2SigType1=Analog
57 | OutputList2Cue1=[~UNUSED3~]
58 | OutputList2SigType1=Analog
59 | InputList2Cue2=Deselect Item
60 | InputList2SigType2=Analog
61 | OutputList2Cue2=[~UNUSED3~]
62 | OutputList2SigType2=Analog
63 | InputList2Cue3=Scroll Item
64 | InputList2SigType3=Analog
65 | OutputList2Cue3=[~UNUSED3~]
66 | OutputList2SigType3=Analog
67 | InputList2Cue4=[~UNUSED3~]
68 | InputList2SigType4=Analog
69 | OutputList2Cue4=Item Clicked
70 | OutputList2SigType4=Analog
71 | InputList2Cue5=[~UNUSED3~]
72 | InputList2SigType5=Analog
73 | OutputList2Cue5=Item Held
74 | OutputList2SigType5=Analog
75 | InputList2Cue6=Set Num of Items
76 | InputList2SigType6=Analog
77 | OutputList2Cue6=[~UNUSED3~]
78 | OutputList2SigType6=Analog
79 | ParamCue1=SmartObjectId
80 | ParamSigType1=Constant
81 | MPp=1
82 | Pp1=1
83 | CedH=1
84 | SmartObjId=1d
85 | ]
86 | ; Parameter Properties for Smart Object ID
87 | [
88 | ObjTp=Dp
89 | H=1
90 | Tp=1
91 | HD=TRUE
92 | DV=1d
93 | NF=1
94 | DNF=1
95 | EncFmt=0
96 | DVLF=1
97 | Sgn=0
98 | ]
99 | ; Smart Objects Definition section
100 | [
101 | ObjTp=CED
102 | H=1
103 | Name=SG Primer XPANEL_Menu_Menu List.ced
104 | ;Cedver is the version of the Smart Graphics control, not the CED file format.
105 | ;If the control definition changes, increment this.
106 | CedVer=1
107 | ]
108 | ;================================================================================
109 | [
110 | ObjTp=Symbol
111 | Name=SG Primer XPANEL_Video Call_VTC Keypad.ced
112 | Hint=VTC Keypad (Smart Object ID=2)
113 | Code=2
114 | SGControlType=Simple Keypad
115 | SGControlName=VTC Keypad
116 | GUID=C124C3C2-B06C-415A-A6A7-EAE87DBDD786
117 | SmplCName=SG Primer XPANEL_Video Call_VTC Keypad.ced
118 | SMWRev=4.02.19
119 | Expand=expand_random
120 | HelpID=10061
121 | ;Define the number of inputs, outputs and parameters
122 | MinVariableInputs=12
123 | MaxVariableInputs=12
124 | MinVariableOutputs=12
125 | MaxVariableOutputs=12
126 | NumFixedParams=1
127 | MinVariableInputsList2=0
128 | MaxVariableInputsList2=0
129 | MinVariableOutputsList2=0
130 | MaxVariableOutputsList2=0
131 | MinVariableInputsList3=0
132 | MaxVariableInputsList3=0
133 | MinVariableOutputsList3=0
134 | MaxVariableOutputsList3=0
135 | ;Define the cues, and signal types each input, output and parameter.
136 | InputCue1=[~UNUSED3~]
137 | InputSigType1=Digital
138 | OutputCue1=1
139 | OutputSigType1=Digital
140 | InputCue2=[~UNUSED3~]
141 | InputSigType2=Digital
142 | OutputCue2=2
143 | OutputSigType2=Digital
144 | InputCue3=[~UNUSED3~]
145 | InputSigType3=Digital
146 | OutputCue3=3
147 | OutputSigType3=Digital
148 | InputCue4=[~UNUSED3~]
149 | InputSigType4=Digital
150 | OutputCue4=4
151 | OutputSigType4=Digital
152 | InputCue5=[~UNUSED3~]
153 | InputSigType5=Digital
154 | OutputCue5=5
155 | OutputSigType5=Digital
156 | InputCue6=[~UNUSED3~]
157 | InputSigType6=Digital
158 | OutputCue6=6
159 | OutputSigType6=Digital
160 | InputCue7=[~UNUSED3~]
161 | InputSigType7=Digital
162 | OutputCue7=7
163 | OutputSigType7=Digital
164 | InputCue8=[~UNUSED3~]
165 | InputSigType8=Digital
166 | OutputCue8=8
167 | OutputSigType8=Digital
168 | InputCue9=[~UNUSED3~]
169 | InputSigType9=Digital
170 | OutputCue9=9
171 | OutputSigType9=Digital
172 | InputCue10=[~UNUSED3~]
173 | InputSigType10=Digital
174 | OutputCue10=0
175 | OutputSigType10=Digital
176 | InputCue11=[~UNUSED3~]
177 | InputSigType11=Digital
178 | OutputCue11=Misc_1
179 | OutputSigType11=Digital
180 | InputCue12=[~UNUSED3~]
181 | InputSigType12=Digital
182 | OutputCue12=Misc_2
183 | OutputSigType12=Digital
184 | ParamCue1=SmartObjectId
185 | ParamSigType1=Constant
186 | MPp=1
187 | Pp1=2
188 | CedH=2
189 | SmartObjId=2d
190 | ]
191 | ; Parameter Properties for Smart Object ID
192 | [
193 | ObjTp=Dp
194 | H=2
195 | Tp=1
196 | HD=TRUE
197 | DV=2d
198 | NF=1
199 | DNF=1
200 | EncFmt=0
201 | DVLF=1
202 | Sgn=0
203 | ]
204 | ; Smart Objects Definition section
205 | [
206 | ObjTp=CED
207 | H=2
208 | Name=SG Primer XPANEL_Video Call_VTC Keypad.ced
209 | ;Cedver is the version of the Smart Graphics control, not the CED file format.
210 | ;If the control definition changes, increment this.
211 | CedVer=1
212 | ]
213 | ;================================================================================
214 | [
215 | ObjTp=Symbol
216 | Name=SG Primer XPANEL_Video Call_Camera DPad.ced
217 | Hint=Camera DPad (Smart Object ID=3)
218 | Code=3
219 | SGControlType=DPad
220 | SGControlName=Camera DPad
221 | GUID=0EB12BCE-1EC4-4A8C-868E-86F39C8508E4
222 | SmplCName=SG Primer XPANEL_Video Call_Camera DPad.ced
223 | SMWRev=4.02.19
224 | Expand=expand_random
225 | HelpID=10015
226 | ;Define the number of inputs, outputs and parameters
227 | MinVariableInputs=5
228 | MaxVariableInputs=5
229 | MinVariableOutputs=5
230 | MaxVariableOutputs=5
231 | NumFixedParams=1
232 | MinVariableInputsList2=0
233 | MaxVariableInputsList2=0
234 | MinVariableOutputsList2=0
235 | MaxVariableOutputsList2=0
236 | MinVariableInputsList3=0
237 | MaxVariableInputsList3=0
238 | MinVariableOutputsList3=0
239 | MaxVariableOutputsList3=0
240 | ;Define the cues, and signal types each input, output and parameter.
241 | InputCue1=[~UNUSED3~]
242 | InputSigType1=Digital
243 | OutputCue1=Up
244 | OutputSigType1=Digital
245 | InputCue2=[~UNUSED3~]
246 | InputSigType2=Digital
247 | OutputCue2=Down
248 | OutputSigType2=Digital
249 | InputCue3=[~UNUSED3~]
250 | InputSigType3=Digital
251 | OutputCue3=Left
252 | OutputSigType3=Digital
253 | InputCue4=[~UNUSED3~]
254 | InputSigType4=Digital
255 | OutputCue4=Right
256 | OutputSigType4=Digital
257 | InputCue5=[~UNUSED3~]
258 | InputSigType5=Digital
259 | OutputCue5=Center
260 | OutputSigType5=Digital
261 | ParamCue1=SmartObjectId
262 | ParamSigType1=Constant
263 | MPp=1
264 | Pp1=3
265 | CedH=3
266 | SmartObjId=3d
267 | ]
268 | ; Parameter Properties for Smart Object ID
269 | [
270 | ObjTp=Dp
271 | H=3
272 | Tp=1
273 | HD=TRUE
274 | DV=3d
275 | NF=1
276 | DNF=1
277 | EncFmt=0
278 | DVLF=1
279 | Sgn=0
280 | ]
281 | ; Smart Objects Definition section
282 | [
283 | ObjTp=CED
284 | H=3
285 | Name=SG Primer XPANEL_Video Call_Camera DPad.ced
286 | ;Cedver is the version of the Smart Graphics control, not the CED file format.
287 | ;If the control definition changes, increment this.
288 | CedVer=1
289 | ]
290 |
--------------------------------------------------------------------------------
/Part2/Part2/ControlSystem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Crestron.SimplSharp; // For Basic SIMPL# Classes
3 | using Crestron.SimplSharpPro; // For Basic SIMPL#Pro classes
4 | using Crestron.SimplSharpPro.CrestronThread; // For Threading
5 | using Crestron.SimplSharpPro.Diagnostics; // For System Monitor Access
6 | using Crestron.SimplSharpPro.DeviceSupport; // For Generic Device Support
7 | using Crestron.SimplSharpPro.UI; // For Touchpanels
8 |
9 | namespace Part2
10 | {
11 | public class ControlSystem : CrestronControlSystem
12 | {
13 | private Tsw1060 _tsw;
14 |
15 | ///
16 | /// ControlSystem Constructor. Starting point for the SIMPL#Pro program.
17 | /// Use the constructor to:
18 | /// * Initialize the maximum number of threads (max = 400)
19 | /// * Register devices
20 | /// * Register event handlers
21 | /// * Add Console Commands
22 | ///
23 | /// Please be aware that the constructor needs to exit quickly; if it doesn't
24 | /// exit in time, the SIMPL#Pro program will exit.
25 | ///
26 | /// You cannot send / receive data in the constructor
27 | ///
28 | public ControlSystem()
29 | : base()
30 | {
31 | try
32 | {
33 | Thread.MaxNumberOfUserThreads = 20;
34 |
35 | //Subscribe to the controller events (System, Program, and Ethernet)
36 | CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
37 | CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
38 | CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);
39 | }
40 | catch (Exception e)
41 | {
42 | ErrorLog.Error("Error in the constructor: {0}", e.Message);
43 | }
44 | }
45 |
46 | ///
47 | /// InitializeSystem - this method gets called after the constructor
48 | /// has finished.
49 | ///
50 | /// Use InitializeSystem to:
51 | /// * Start threads
52 | /// * Configure ports, such as serial and verisports
53 | /// * Start and initialize socket connections
54 | /// Send initial device configurations
55 | ///
56 | /// Please be aware that InitializeSystem needs to exit quickly also;
57 | /// if it doesn't exit in time, the SIMPL#Pro program will exit.
58 | ///
59 | public override void InitializeSystem()
60 | {
61 | try
62 | {
63 | _tsw = new Tsw1060(0x03, this);
64 | _tsw.OnlineStatusChange += new OnlineStatusChangeEventHandler(_tsw_OnlineStatusChange);
65 | _tsw.SigChange += new SigEventHandler(_tsw_SigChange);
66 | }
67 | catch (Exception e)
68 | {
69 | ErrorLog.Error("Error in InitializeSystem: {0}", e.Message);
70 | }
71 | }
72 |
73 | void _tsw_SigChange(BasicTriList currentDevice, SigEventArgs args)
74 | {
75 | if (args.Sig.Number == 10)
76 | {
77 | if (args.Sig.BoolValue)
78 | {
79 | currentDevice.StringInput[1].StringValue = "Hello world!";
80 | }
81 | }
82 | if (args.Sig.Number == 11)
83 | {
84 | if (args.Sig.BoolValue)
85 | {
86 | currentDevice.StringInput[1].StringValue = "";
87 | }
88 | }
89 | }
90 |
91 | void _tsw_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
92 | {
93 | throw new NotImplementedException();
94 | }
95 |
96 | ///
97 | /// Event Handler for Ethernet events: Link Up and Link Down.
98 | /// Use these events to close / re-open sockets, etc.
99 | ///
100 | /// This parameter holds the values
101 | /// such as whether it's a Link Up or Link Down event. It will also indicate
102 | /// wich Ethernet adapter this event belongs to.
103 | ///
104 | void ControlSystem_ControllerEthernetEventHandler(EthernetEventArgs ethernetEventArgs)
105 | {
106 | switch (ethernetEventArgs.EthernetEventType)
107 | {//Determine the event type Link Up or Link Down
108 | case (eEthernetEventType.LinkDown):
109 | //Next need to determine which adapter the event is for.
110 | //LAN is the adapter is the port connected to external networks.
111 | if (ethernetEventArgs.EthernetAdapter == EthernetAdapterType.EthernetLANAdapter)
112 | {
113 | //
114 | }
115 | break;
116 | case (eEthernetEventType.LinkUp):
117 | if (ethernetEventArgs.EthernetAdapter == EthernetAdapterType.EthernetLANAdapter)
118 | {
119 |
120 | }
121 | break;
122 | }
123 | }
124 |
125 | ///
126 | /// Event Handler for Programmatic events: Stop, Pause, Resume.
127 | /// Use this event to clean up when a program is stopping, pausing, and resuming.
128 | /// This event only applies to this SIMPL#Pro program, it doesn't receive events
129 | /// for other programs stopping
130 | ///
131 | ///
132 | void ControlSystem_ControllerProgramEventHandler(eProgramStatusEventType programStatusEventType)
133 | {
134 | switch (programStatusEventType)
135 | {
136 | case (eProgramStatusEventType.Paused):
137 | //The program has been paused. Pause all user threads/timers as needed.
138 | break;
139 | case (eProgramStatusEventType.Resumed):
140 | //The program has been resumed. Resume all the user threads/timers as needed.
141 | break;
142 | case (eProgramStatusEventType.Stopping):
143 | //The program has been stopped.
144 | //Close all threads.
145 | //Shutdown all Client/Servers in the system.
146 | //General cleanup.
147 | //Unsubscribe to all System Monitor events
148 | break;
149 | }
150 |
151 | }
152 |
153 | ///
154 | /// Event Handler for system events, Disk Inserted/Ejected, and Reboot
155 | /// Use this event to clean up when someone types in reboot, or when your SD /USB
156 | /// removable media is ejected / re-inserted.
157 | ///
158 | ///
159 | void ControlSystem_ControllerSystemEventHandler(eSystemEventType systemEventType)
160 | {
161 | switch (systemEventType)
162 | {
163 | case (eSystemEventType.DiskInserted):
164 | //Removable media was detected on the system
165 | break;
166 | case (eSystemEventType.DiskRemoved):
167 | //Removable media was detached from the system
168 | break;
169 | case (eSystemEventType.Rebooting):
170 | //The system is rebooting.
171 | //Very limited time to preform clean up and save any settings to disk.
172 | break;
173 | }
174 |
175 | }
176 | }
177 | }
--------------------------------------------------------------------------------
/SG/Part7/ControlSystem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Crestron.SimplSharp;
3 | using Crestron.SimplSharp.CrestronIO;
4 | using Crestron.SimplSharpPro;
5 | using Crestron.SimplSharpPro.CrestronThread;
6 | using Crestron.SimplSharpPro.DeviceSupport;
7 | using Crestron.SimplSharpPro.UI;
8 |
9 | namespace Part7
10 | {
11 | public class ControlSystem : CrestronControlSystem
12 | {
13 | private XpanelForSmartGraphics _tp;
14 | private Thread _ramp;
15 | private CTimer _delay;
16 | private ushort _menu;
17 | private string _dialString;
18 | private short _pan;
19 | private short _tilt;
20 | private short _zoom;
21 | private bool _privacy;
22 | private bool _mute;
23 | private ushort _volume;
24 | private ushort _presentationSource;
25 | private ushort[] _lights;
26 | private ushort[][] _preset;
27 |
28 | public ControlSystem()
29 | : base()
30 | {
31 | try
32 | {
33 | Thread.MaxNumberOfUserThreads = 100;
34 | }
35 | catch (Exception e)
36 | {
37 | ErrorLog.Error("Error in Constructor: {0}", e.Message);
38 | }
39 | }
40 |
41 | public override void InitializeSystem()
42 | {
43 | try
44 | {
45 | _dialString = "";
46 | _volume = 32767;
47 | _presentationSource = 0;
48 |
49 | _lights = new ushort[3];
50 |
51 | _preset = new ushort[3][];
52 |
53 | _preset[0] = new ushort[3];
54 | _preset[0][0] = 65535;
55 | _preset[0][1] = 65535;
56 | _preset[0][2] = 65535;
57 |
58 | _preset[1] = new ushort[3];
59 | _preset[1][0] = 32767;
60 | _preset[1][1] = 32767;
61 | _preset[1][2] = 32767;
62 |
63 | _preset[2] = new ushort[3];
64 | _preset[2][0] = 0;
65 | _preset[2][1] = 0;
66 | _preset[2][2] = 0;
67 |
68 | _tp = new XpanelForSmartGraphics(0x03, this);
69 | _tp.LoadSmartObjects(Directory.GetApplicationDirectory() +
70 | Path.DirectorySeparatorChar + "SG Primer XPANEL.sgd");
71 |
72 | _tp.OnlineStatusChange += _tp_Online;
73 | _tp.SigChange += _tp_SigChange;
74 |
75 | _tp.SmartObjects[1].SigChange += _tp_MenuSigChange;
76 | _tp.SmartObjects[2].SigChange += _tp_KeypadSigChange;
77 | _tp.SmartObjects[3].SigChange += _tp_DPadSigChange;
78 |
79 | var result = _tp.Register();
80 |
81 | if (result != eDeviceRegistrationUnRegistrationResponse.Success)
82 | ErrorLog.Warn("Problem registering XPanel: {0}", result);
83 | }
84 | catch (Exception e)
85 | {
86 | ErrorLog.Error("Error in InitializeSystem: {0}", e.Message);
87 | }
88 | }
89 |
90 | private void _tp_MenuSigChange(GenericBase dev, SmartObjectEventArgs args)
91 | {
92 | if (args.Sig.Name == "Item Clicked")
93 | {
94 | _menu = args.Sig.UShortValue;
95 | _tp_UpdateMenu();
96 | }
97 | }
98 |
99 | private void _tp_UpdateMenu()
100 | {
101 | _tp.BooleanInput[21].BoolValue = (_menu == 1); // Video Call
102 | _tp.BooleanInput[22].BoolValue = (_menu == 2); // Presentation
103 | _tp.BooleanInput[23].BoolValue = (_menu == 3); // Lights
104 | }
105 |
106 | private void _tp_KeypadSigChange(GenericBase dev, SmartObjectEventArgs args)
107 | {
108 | if (args.Sig.BoolValue) // Press
109 | {
110 | if (_dialString.Length < 50)
111 | {
112 | if (args.Sig.Name == "Misc_1")
113 | _dialString += "*";
114 | else if (args.Sig.Name == "Misc_2")
115 | _dialString += "#";
116 | else
117 | _dialString += args.Sig.Name;
118 |
119 | _tp_UpdateDialString();
120 | }
121 | }
122 | }
123 |
124 | private void _tp_UpdateDialString()
125 | {
126 | _tp.StringInput[11].StringValue = _dialString;
127 | }
128 |
129 | private void _tp_DPadSigChange(GenericBase dev, SmartObjectEventArgs args)
130 | {
131 | if (args.Sig.BoolValue) // Press
132 | {
133 | if (args.Sig.Name == "Center")
134 | {
135 | _pan = 0;
136 | _tilt = 0;
137 | }
138 | else if (args.Sig.Name == "Up")
139 | {
140 | _ramp = new Thread(o => { return _tp_Tilt(1); }, null);
141 | }
142 | else if (args.Sig.Name == "Down")
143 | {
144 | _ramp = new Thread(o => { return _tp_Tilt(-1); }, null);
145 | }
146 | else if (args.Sig.Name == "Left")
147 | {
148 | _ramp = new Thread(o => { return _tp_Pan(-1); }, null);
149 | }
150 | else if (args.Sig.Name == "Right")
151 | {
152 | _ramp = new Thread(o => { return _tp_Pan(1); }, null);
153 | }
154 | }
155 | else // Release
156 | {
157 | if (args.Sig.Name == "Center")
158 | {
159 | // nothing
160 | }
161 | else
162 | {
163 | if (_ramp != null)
164 | _ramp.Abort();
165 | }
166 | }
167 | }
168 |
169 | private object _tp_Tilt(short dir)
170 | {
171 | while (true)
172 | {
173 | if (dir < 0) // Down
174 | {
175 | if (_tilt > -100)
176 | _tilt--;
177 | else
178 | break;
179 | }
180 | else // Up
181 | {
182 | if (_tilt < 100)
183 | _tilt++;
184 | else
185 | break;
186 | }
187 |
188 | CrestronConsole.PrintLine("Pan: {0}\tTilt: {1}", _pan, _tilt);
189 | Thread.Sleep(50);
190 | }
191 |
192 | return null;
193 | }
194 |
195 | private object _tp_Pan(short dir)
196 | {
197 | while (true)
198 | {
199 | if (dir < 0) // Left
200 | {
201 | if (_pan > -180)
202 | _pan--;
203 | else
204 | break;
205 | }
206 | else // Right
207 | {
208 | if (_pan < 180)
209 | _pan++;
210 | else
211 | break;
212 | }
213 |
214 | CrestronConsole.PrintLine("Pan: {0}\tTilt: {1}", _pan, _tilt);
215 | Thread.Sleep(50);
216 | }
217 |
218 | return null;
219 | }
220 |
221 | private object _tp_Zoom(short dir)
222 | {
223 | while (true)
224 | {
225 | if (dir < 0) // Out
226 | {
227 | if (_zoom > -100)
228 | _zoom--;
229 | else
230 | break;
231 | }
232 | else // In
233 | {
234 | if (_zoom < 100)
235 | _zoom++;
236 | else
237 | break;
238 | }
239 |
240 | CrestronConsole.PrintLine("Zoom: {0}", _zoom);
241 | Thread.Sleep(50);
242 | }
243 |
244 | return null;
245 | }
246 |
247 | private void _tp_Online(GenericBase dev, OnlineOfflineEventArgs args)
248 | {
249 | if (args.DeviceOnLine)
250 | {
251 | _tp.UShortInput[11].UShortValue = _volume;
252 | }
253 | }
254 |
255 | private void _tp_SigChange(BasicTriList dev, SigEventArgs args)
256 | {
257 | switch (args.Sig.Type)
258 | {
259 | case eSigType.Bool:
260 | if (args.Sig.BoolValue)
261 | _tp_Press(args.Sig.Number);
262 | else
263 | _tp_Release(args.Sig.Number);
264 | break;
265 | case eSigType.UShort:
266 | switch (args.Sig.Number)
267 | {
268 | case 11: // Volume
269 | _volume = args.Sig.UShortValue;
270 | CrestronConsole.PrintLine("Volume = {0}", _volume);
271 | _tp.UShortInput[11].UShortValue = _volume;
272 | break;
273 | case 51: // Lights Zone 1
274 | case 52: // Lights Zone 2
275 | case 53: // Lights Zone 3
276 | if (!args.Sig.IsRamping)
277 | {
278 | var zn = args.Sig.Number - 51;
279 | _lights[zn] = args.Sig.UShortValue;
280 |
281 | CrestronConsole.PrintLine("Zone {0} level = {1}", zn + 1, args.Sig.UShortValue);
282 |
283 | _tp.UShortInput[51].UShortValue = _lights[0];
284 | _tp.UShortInput[52].UShortValue = _lights[1];
285 | _tp.UShortInput[53].UShortValue = _lights[2];
286 | }
287 |
288 | break;
289 | }
290 | break;
291 | }
292 | }
293 |
294 | private void _tp_Press(uint sig)
295 | {
296 | switch (sig)
297 | {
298 | case 11: // Privacy
299 | _privacy = !_privacy;
300 | _tp.BooleanInput[11].BoolValue = _privacy;
301 | break;
302 | case 12: // Volume Mute
303 | _mute = !_mute;
304 | _tp.BooleanInput[12].BoolValue = _mute;
305 | break;
306 | case 52: // Dial
307 | if (_dialString.Length > 0)
308 | CrestronConsole.PrintLine("Dialing {0}...", _dialString);
309 | break;
310 | case 53: // Hang Up
311 | _delay = new CTimer(o => { _dialString = ""; _tp.StringInput[11].StringValue = _dialString; }, 500);
312 | break;
313 | case 54: // Zoom In
314 | _ramp = new Thread(o => { return _tp_Zoom(1); }, null);
315 | break;
316 | case 55: // Zoom Out
317 | _ramp = new Thread(o => { return _tp_Zoom(-1); }, null);
318 | break;
319 | case 71: // Laptop
320 | case 72: // AirMedia
321 | case 73: // Apple TV
322 | case 74: // Chromecast
323 | var src = (ushort)(sig - 70);
324 |
325 | if (_presentationSource == src)
326 | _presentationSource = 0;
327 | else
328 | _presentationSource = src;
329 |
330 | _tp.BooleanInput[71].BoolValue = (_presentationSource == 1);
331 | _tp.BooleanInput[72].BoolValue = (_presentationSource == 2);
332 | _tp.BooleanInput[73].BoolValue = (_presentationSource == 3);
333 | _tp.BooleanInput[74].BoolValue = (_presentationSource == 4);
334 |
335 | break;
336 | case 111:
337 | case 112:
338 | case 113:
339 | var pre = sig - 111;
340 | CrestronConsole.PrintLine("Recalling preset {0}...", pre);
341 |
342 | _lights[0] = _preset[pre][0];
343 | _lights[1] = _preset[pre][1];
344 | _lights[2] = _preset[pre][2];
345 |
346 | _tp.UShortInput[51].CreateRamp(_lights[0], 100);
347 | _tp.UShortInput[52].CreateRamp(_lights[1], 100);
348 | _tp.UShortInput[53].CreateRamp(_lights[2], 100);
349 |
350 | break;
351 | }
352 | }
353 |
354 | private void _tp_Release(uint sig)
355 | {
356 | switch (sig)
357 | {
358 | case 54: // Zoom In
359 | case 55: // Zoom Out
360 | if (_ramp != null)
361 | _ramp.Abort();
362 | break;
363 | }
364 | }
365 | }
366 | }
--------------------------------------------------------------------------------
/CleanUpExample/CleanUpExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {F0B45EF7-F702-4909-828F-C6D08E2C84F5}
8 | Library
9 | Properties
10 | CleanUpExample
11 | CleanUpExample
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 |
18 |
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.AudioDistribution.dll
38 |
39 |
40 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.CrestronConnected.dll
41 |
42 |
43 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.DeviceSupport.dll
44 |
45 |
46 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.DM.dll
47 |
48 |
49 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.EthernetCommunications.dll
50 |
51 |
52 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.Fusion.dll
53 |
54 |
55 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.Gateways.dll
56 |
57 |
58 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.GeneralIO.dll
59 |
60 |
61 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.Keypads.dll
62 |
63 |
64 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.Lighting.dll
65 |
66 |
67 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.Media.dll
68 |
69 |
70 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.Remotes.dll
71 |
72 |
73 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.Shades.dll
74 |
75 |
76 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.Thermostats.dll
77 |
78 |
79 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.ThreeSeriesCards.dll
80 |
81 |
82 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.UC.dll
83 |
84 |
85 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\Crestron.SimplSharpPro.UI.dll
86 |
87 |
88 | packages\Crestron.SimplSharp.SDK.Library.2.19.58\lib\net47\SimplSharpAutoUpdateInterface.dll
89 |
90 |
91 | packages\Crestron.SimplSharp.SDK.Library.2.19.58\lib\net47\SimplSharpCryptographyInterface.dll
92 |
93 |
94 | packages\Crestron.SimplSharp.SDK.Library.2.19.58\lib\net47\SimplSharpCustomAttributesInterface.dll
95 |
96 |
97 | packages\Crestron.SimplSharp.SDK.Library.2.19.58\lib\net47\SimplSharpCWSHelperInterface.dll
98 |
99 |
100 | packages\Crestron.SimplSharp.SDK.Library.2.19.58\lib\net47\SimplSharpExchangeWebServices.dll
101 |
102 |
103 | packages\Crestron.SimplSharp.SDK.Library.2.19.58\lib\net47\SimplSharpHelperInterface.dll
104 |
105 |
106 | packages\Crestron.SimplSharp.SDK.Library.2.19.58\lib\net47\SimplSharpNewtonsoft.dll
107 |
108 |
109 | packages\Crestron.SimplSharp.SDK.Library.2.19.58\lib\net47\SimplSharpOnvifInterface.dll
110 |
111 |
112 | packages\Crestron.SimplSharp.SDK.ProgramLibrary.2.19.58\lib\net47\SimplSharpPro.exe
113 |
114 |
115 | packages\Crestron.SimplSharp.SDK.Library.2.19.58\lib\net47\SimplSharpProgrammingInterfaces.dll
116 |
117 |
118 | packages\Crestron.SimplSharp.SDK.Library.2.19.58\lib\net47\SimplSharpReflectionInterface.dll
119 |
120 |
121 | packages\Crestron.SimplSharp.SDK.Library.2.19.58\lib\net47\SimplSharpSQLHelperInterface.dll
122 |
123 |
124 | packages\Crestron.SimplSharp.SDK.Library.2.19.58\lib\net47\SimplSharpTimerEventInterface.dll
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
--------------------------------------------------------------------------------