public override void Add(CompBase child) { CompBase compRead = ReadXmlFile(child.GetType(), child.Name); if (compRead != null) { RecurseConstructChild(child, compRead); child = compRead; } base.Add(child); child.Initialize(); }
/// <summary> /// recursively Export (saveAs) all the settings of the CompBase component /// </summary> /// <param name="filePath"></param> /// <param name="compChild"></param> public static void ExportSettings(string filePath, CompBase compChild) { try { U.EnsureWritable(filePath); DefineXmlSerializer(compChild.GetType()); MCoreXmlSerializer.SaveObjectToFile(filePath, compChild); } catch (Exception ex) { U.LogPopup(ex, "Error Saving '{0}'", compChild.Name); } }
public void Add(CompBase child, eCleanUpMode cleanUpMode = eCleanUpMode.None) { CompBase compRead = ReadXmlFile(child.GetType(), child.Name); if (compRead != null) { RecurseConstructChild(child, compRead); RecurseCleanUpChild(child, compRead, cleanUpMode); child = compRead; } base.Add(child); child.Initialize(); }
private void MoveAbsAxis(CompBase compAxis, double pos, float velocity, bool waitForCompletion) { if (listAxis.ContainsKey(compAxis)) { MMCSingleAxis singleAxis = listAxis[compAxis]; if (!WaitForMoveReady(singleAxis, 20000.0)) { return; } MMC_MOTIONPARAMS_SINGLE singleParam = new MMC_MOTIONPARAMS_SINGLE(); if (compAxis is RotaryBase) { singleParam.fAcceleration = 250f; singleParam.fDeceleration = 250f; } else { singleParam.fAcceleration = 1000f; singleParam.fDeceleration = 1000f; } singleParam.fVelocity = velocity; singleParam.eDirection = MC_DIRECTION_ENUM.MC_SHORTEST_WAY; singleParam.fJerk = 100f; singleParam.eBufferMode = MC_BUFFERED_MODE_ENUM.MC_BUFFERED_MODE; singleParam.ucExecute = 1; singleAxis.SetDefaultParams(singleParam); OPM402 opMode = singleAxis.GetOpMode(); if (opMode != OPM402.OPM402_CYCLIC_SYNC_POSITION_MODE) { try { singleAxis.SetOpMode(OPM402.OPM402_CYCLIC_SYNC_POSITION_MODE); Thread.Sleep(500); //'Wait Mode change before move' } catch (Exception ex) { U.LogPopup(ex, "Cannot set to OPM402_CYCLIC_SYNC_POSITION_MODE mode axis {0}", compAxis.Name); return; } } try { double actualPos = singleAxis.GetActualPosition(); if (actualPos != pos) { singleAxis.MoveAbsolute(pos, velocity, MC_BUFFERED_MODE_ENUM.MC_BUFFERED_MODE); if (waitForCompletion) { double curPos = 0.0; if (compAxis is RotaryBase) { curPos = (compAxis as RotaryBase).CurrentPosition; } else if (compAxis is RealAxis) { curPos = (compAxis as RealAxis).CurrentPosition; } else { U.LogPopup("Unexpected Axis type for MoveAbsAxis: Type={0} Axis={1}", compAxis.GetType().Name, compAxis.Nickname); } // Calculate approximate time to wait for completion (a little less than) double mSecWait = Math.Abs(pos - curPos) * 950.0 / velocity; if (!WaitMoveDone(singleAxis, (int)mSecWait)) { U.LogPopup("Timeout moving {0}", compAxis.Name); } } } } catch (Exception ex) { U.LogError(ex, "Failed To Move '{0}'", compAxis.Name); } } }
private void OnNewSelection(object sender, TreeViewEventArgs e) { if (tabPages.Controls.Count > 0) { foreach (TabPage page in tabPages.Controls) { foreach (Control control in page.Controls) { control.Dispose(); } //page.Dispose(); } tabPages.Controls.Clear(); } CompBase comp = null; Type tyComp = null; try { comp = e.Node.Tag as CompBase; tyComp = comp.GetType(); } catch (Exception ex) { U.LogPopup(ex, "Problem with selection"); return; } List <Control> controls = new List <Control>(); try { do { Type[] controlTypes = CompRoot.GetControlPages(tyComp); if (controlTypes != null) { for (int i = 0; i < controlTypes.Length; i++) { Type controlType = controlTypes[i]; if (comp.IgnorePageList.Contains(controlType)) { continue; } Control control = Activator.CreateInstance(controlType) as Control; PropertyInfo pi = controlType.GetProperty("Bind"); pi.SetValue(control, comp, null); controls.Insert(0, control); } } tyComp = tyComp.BaseType; }while (tyComp != null && !Type.Equals(tyComp, typeof(Object))); } catch (Exception ex) { U.LogPopup(ex, "Problem with selection"); } try { for (int i = 0; i < controls.Count; i++) { Control control = controls[i]; TabPage tabPage = new TabPage(control.ToString()); tabPage.Location = new System.Drawing.Point(4, 22); tabPage.Name = string.Format("tabPage{0}", i); tabPage.Padding = new System.Windows.Forms.Padding(3); tabPage.TabIndex = i; tabPage.UseVisualStyleBackColor = true; tabPage.Controls.Add(control); tabPages.Controls.Add(tabPage); } } catch (Exception ex) { U.LogPopup(ex, "Problem with selection"); } OnSizedChanged(null, null); }