protected OpCode InstantiateOpCodeClass(string name) { string fullname = OpCodeNamespacePrefix + "." + name; Type type = ParentDevice.GetType().Assembly.GetType(fullname); if (type != null) { return(Activator.CreateInstance(type, this.ParentDevice) as OpCode); } return(null); }
public AirMediaDevice(uint ipId, CrestronControlSystem controlSystem, string deviceType, string description) { try { var type = typeof(Am101); if (!string.IsNullOrEmpty(deviceType)) { try { var assembly = Assembly.Load(typeof(Am200).AssemblyName()); type = assembly.GetType(deviceType).GetCType(); } catch { var assembly = Assembly.Load(typeof(Am101).AssemblyName()); type = assembly.GetType(deviceType).GetCType(); } } var ctor = type.GetConstructor(new CType[] { typeof(uint), typeof(CrestronControlSystem) }); _device = (GenericDevice)ctor.Invoke(new object[] { ipId, controlSystem }); _device.Description = description; _device.IpInformationChange += AmOnIpInformationChange; _device.OnlineStatusChange += AmOnOnlineStatusChange; if (_device is AmX00) { ((AmX00)_device).AirMedia.AirMediaChange += AirMediaOnAirMediaChange; } var regResult = _device.Register(); if (regResult != eDeviceRegistrationUnRegistrationResponse.Success) { CloudLog.Error("Error registering {0} with ID 0x{1}, {2}", _device.GetType().Name, _device.ID.ToString("X2"), regResult); } } catch (Exception e) { CloudLog.Exception(e, "Error loading Air Media Device"); } }
public FusionAssetBase Add(GenericDevice device) { uint newId = 0; for (uint id = 1; id <= 249; id++) { if (!this.Fusion.Room.Fusion.FusionRoom.UserConfigurableAssetDetails.Contains(id)) { newId = id; break; } } if (newId > 0) { this.Fusion.Room.Fusion.FusionRoom.AddAsset(eAssetType.StaticAsset, newId, device.GetType().Name.SplitCamelCase(), device.Type.ToString().SplitCamelCase(), Guid.NewGuid().ToString()); Assets[newId] = this.Fusion.Room.Fusion.FusionRoom.UserConfigurableAssetDetails[newId].Asset; Devices[device] = Assets[newId]; ((FusionStaticAsset)Devices[device]).AddSig(eSigType.String, 1, "IP Address", eSigIoMask.InputSigOnly); device.OnlineStatusChange += new OnlineStatusChangeEventHandler(device_OnlineStatusChange); device.IpInformationChange += new IpInformationChangeEventHandler(device_IpInformationChange); return(Assets[newId]); } return(null); }