protected override void validateFields() { base.validateFields(); LeitchRouter leitchRouter = (LeitchRouter)EditedModel; if (leitchRouter == null) { return; } }
protected override void validateFields() { base.validateFields(); LeitchRouter leitchRouter = router as LeitchRouter; if (leitchRouter == null) { return; } }
protected override void writeFields() { base.writeFields(); LeitchRouter leitchRouter = (LeitchRouter)EditedModel; if (leitchRouter == null) { return; } leitchRouter.Port = portDropDown.SelectedValue as SerialPort; leitchRouter.Level = (int)levelNumericField.Value; }
protected override void loadData() { base.loadData(); LeitchRouter leitchRouter = (LeitchRouter)EditedModel; if (leitchRouter == null) { return; } portDropDown.SelectByValue(leitchRouter.Port); levelNumericField.Value = leitchRouter.Level; }
private static void loadXML_routers(XmlNode routersNode) { foreach (XmlNode node in routersNode.ChildNodes) { string id = node.Attributes.GetNamedItem("id").Value; string name = node.Attributes.GetNamedItem("name").Value; if (node.Name == "leitchrouter") { string serialport = node.Attributes.GetNamedItem("serialport").Value; IRouter router = new LeitchRouter(name, serialport); _routers.Add(id, router); } } }
private static void loadXML_vtrs(XmlNode vtrsNode) { foreach (XmlNode node in vtrsNode.ChildNodes) { string name = node.Attributes.GetNamedItem("name").Value; string captureDeviceId = node.Attributes.GetNamedItem("capturedevice").Value; string controllerId = node.Attributes.GetNamedItem("controller").Value; string controllerChannelStr = node.Attributes.GetNamedItem("controllerchannel").Value; if (!_captureDevices.ContainsKey(captureDeviceId)) { throw new Exception(string.Format("Can't find capture device with the ID '{0}'!", captureDeviceId)); } ICaptureDevice captureDevice = _captureDevices[captureDeviceId]; if (!_controllers.ContainsKey(controllerId)) { throw new Exception(string.Format("Can't find controller with the ID '{0}'!", captureDeviceId)); } Controller controller = _controllers[controllerId]; if (!int.TryParse(controllerChannelStr, out int controllerChannel) || (controllerChannel < 0)) { throw new Exception(string.Format("'{0}' is not a valid number for controller channel!", controllerChannelStr)); } Controller.Adapter controllerAdapter = controller.GetAdapter(controllerChannel); List <IRouterCrosspoint> routerCrosspoints = new List <IRouterCrosspoint>(); foreach (XmlNode childNode in node.ChildNodes) { string routerId = childNode.Attributes.GetNamedItem("router").Value; if (!_routers.ContainsKey(routerId)) { throw new Exception(string.Format("Can't find router with the ID '{0}'!", routerId)); } IRouter router = _routers[routerId]; if (childNode.Name == "leitchcrosspoint") { LeitchRouter leitchRouter = router as LeitchRouter; if (leitchRouter == null) { throw new Exception(string.Format("The router with ID '{0}' is not a Leitch router!", routerId)); } string levelStr = childNode.Attributes.GetNamedItem("level").Value; if (!int.TryParse(levelStr, out int level) || (level < 0)) { throw new Exception(string.Format("'{0}' is not a valid number for Leitch crosspoint level!", level)); } string destinationStr = childNode.Attributes.GetNamedItem("destination").Value; if (!int.TryParse(destinationStr, out int destination) || (destination < 0)) { throw new Exception(string.Format("'{0}' is not a valid number for Leitch crosspoint destination!", destination)); } string sourceStr = childNode.Attributes.GetNamedItem("source").Value; if (!int.TryParse(sourceStr, out int source) || (source < 0)) { throw new Exception(string.Format("'{0}' is not a valid number for Leitch crosspoint source!", source)); } IRouterCrosspoint crosspoint = leitchRouter.GetCrosspoint(level, destination, source); routerCrosspoints.Add(crosspoint); } } VTR vtr = new VTR(name, routerCrosspoints, captureDevice, controllerAdapter); _vtrs.Add(vtr); } }