Example #1
0
        /// <summary>
        /// Register all the possible unique names for this component
        /// </summary>
        /// <param name="comp"></param>
        public void RegisterComponent(CompBase comp)
        {
            List <string> namelist = GetNameList(comp);

            lock (_dictComponents)
            {
                string[] ids = namelist.ToArray();
                for (int i = 0; i < ids.Length; i++)
                {
                    string id = ids[i];
                    if (_dictComponents.ContainsKey(id))
                    {
                        if (i == ids.Length - 1)
                        {
                            // It is entitled to own this key because it is the full path to the component
                            _dictComponents[id] = comp;
                        }
                        else
                        {
                            // Not unique.  Make list or add to it
                            object obj = _dictComponents[id];
                            if (obj is CompBase && (obj as CompBase).ID != id)
                            {
                                // Convert to List
                                List <CompBase> compList = new List <CompBase>();
                                compList.Add(obj as CompBase);
                                compList.Add(comp);
                                _dictComponents[id] = compList;
                            }
                            else if (obj is List <CompBase> )
                            {
                                (obj as List <CompBase>).Add(comp);
                            }
                        }
                    }
                    else
                    {
                        _dictComponents.Add(id, comp);
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Get the list of all IDs for this component
        /// </summary>
        /// <param name="comp"></param>
        /// <returns></returns>
        public List <string> GetNameList(CompBase comp)
        {
            List <string> list = new List <string>();

            if (!(comp is CompRoot))
            {
                string id = comp.Name;
                while (true)
                {
                    list.Add(id);
                    comp = comp.Parent;
                    if (comp == null || comp is CompRoot)
                    {
                        break;
                    }
                    id = string.Format("{0}.{1}", comp.Name, id);
                }
            }
            return(list);
        }
        /// <summary>
        /// Called after Initialize
        /// </summary>
        public override void InitializeIDReferences()
        {
            base.InitializeIDReferences();

            /*Example Get Component
             * _redLamp = U.GetComponent(AppConstStaticName.RED_TOWER_LIGHT) as BoolOutput;
             * _amberLamp = U.GetComponent(AppConstStaticName.AMBER_TOWER_LIGHT) as BoolOutput;
             * _greenLamp = U.GetComponent(AppConstStaticName.GREEN_TOWER_LIGHT) as BoolOutput;
             * _buzzer = U.GetComponent(AppConstStaticName.BUZZER) as BoolOutput;
             */

            _allRecipe        = U.GetComponent(AppConstStaticName.ALL_RECIPES);
            _refCurrentRecipe = U.GetComponent(AppConstStaticName.REF_CURRENT_RECIPE) as AppProductRecipe;

            U.RegisterOnChanged(() => RunStatus, RunStatusOnChange);
            U.RegisterOnChanged(() => IsAlarm, AlarmOnChange);

            U.RegisterOnChanged(() => LotId, LotIDOnChanged);
            U.RegisterOnChanged(() => AppMachine.This.CurrentProdRecipeName, CurrentRecipeOnChange);
        }
Example #4
0
        private void InitialSemiAutoOperationGUI()
        {
            CompBase _allSemiStateMachine = U.GetComponent(AppConstStaticName.ALL_SEMI_AUTO_STATE_MACHINE) as CompBase;
            CompBase _allStation          = U.GetComponent(AppConstStaticName.ALL_STATIONS) as CompBase;


            foreach (CompBase childState in _allSemiStateMachine.ChildArray)
            {
                SMStateMachine sm = childState as SMStateMachine;
                if (sm != null)
                {
                    System.Windows.Forms.Panel smStorePanel = new System.Windows.Forms.Panel();;
                    smStorePanel.Size = new System.Drawing.Size(1100, 30);
                    AppFloatableSMOperate floatSMFlowChart = new AppFloatableSMOperate();
                    floatSMFlowChart.Bind = sm;
                    switch (sm.Name)
                    {
                    case AppConstStaticName.SM_SEMI_MAIN:
                    {
                        StringCtl plugInCtrlParam = new StringCtl();
                        plugInCtrlParam.BindTwoWay(() => AppMachine.Comp.AppMachine.This.SemiAutoMainParam);
                        floatSMFlowChart.PluginControlParameter(plugInCtrlParam, "Param");
                        floatSMFlowChart.BackColor = Color.Green;
                    }
                    break;

                    case AppConstStaticName.SM_SEMI_RESET:
                    {
                        StringCtl plugInCtrlParam = new StringCtl();
                        plugInCtrlParam.BindTwoWay(() => AppMachine.Comp.AppMachine.This.SemiAutoResetParam);
                        floatSMFlowChart.PluginControlParameter(plugInCtrlParam, "Param");
                        floatSMFlowChart.BackColor = Color.MediumPurple;
                    }
                    break;
                    }

                    smStorePanel.Controls.Add(floatSMFlowChart);
                    flpSemiAutoOpr.Controls.Add(smStorePanel);
                }
            }
        }
        private void BuildTree(TreeNodeCollection treeNode, CompBase compParent)
        {
            if (compParent.HasChildren)
            {
                foreach (CompBase compChild in compParent.ChildArray)
                {
                    TreeNode nd = null;
                    if (treeNode.ContainsKey(compChild.ID))
                    {
                        nd     = treeNode.Find(compChild.ID, false)[0];
                        nd.Tag = compChild;
                    }
                    else
                    {
                        string nodeDisplayText = "";
                        if (compChild is SMAndCond)
                        {
                            nodeDisplayText = "AND";
                        }
                        else if (compChild is SMOrCond)
                        {
                            nodeDisplayText = "OR";
                        }
                        else if (compChild is SMSubCond)
                        {
                            nodeDisplayText = string.Format("{0} {1} [{2}]", (compChild as SMSubCond).ConditionID, (compChild as SMSubCond).OperatorString, (compChild as SMSubCond).ConditionValueString);
                        }
                        else
                        {
                            nodeDisplayText = compChild.Name;
                        }

                        nd     = treeNode.Add(compChild.ID, nodeDisplayText);
                        nd.Tag = compChild;
                    }

                    BuildTree(nd.Nodes, compChild);
                    (compChild as SMSubCondBase).RefNode = nd;
                }
            }
        }
        private void GetFlowList(CompBase SMParent)
        {
            if (SMParent is SMStateMachine)
            {
                _flowNameList.Clear();
                _flowNameList2.Clear();
            }

            SMFlowBase[] _smFlows = null;
            _smFlows = SMParent.FilterByType <SMFlowBase>();
            foreach (SMFlowBase flow in _smFlows)
            {
                _flowNameList.Add(flow.ID);
                _flowNameList2.Add(flow.ID);

                if (flow is SMFlowContainer && flow.HasChildren)
                {
                    GetFlowList(flow);
                }
            }
        }
        /// <summary>
        /// Provide two-way binding
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="propertyLambda"></param>
        public void BindTwoWay(Expression <Func <string> > propertyLambda)
        {
            UnBind();
            _propertyLambda = propertyLambda;
            MemberExpression member   = propertyLambda.Body as MemberExpression;
            PropertyInfo     propInfo = member.Member as PropertyInfo;

            // Get the getter delegate
            _propertyGetter = propertyLambda.Compile();
            // Get the target object
            Func <Object> delObj = Expression.Lambda <Func <Object> >(member.Expression).Compile();

            _objTarget      = delObj();
            _propertySetter = Delegate.CreateDelegate(typeof(Action <string>), _objTarget, "set_" + propInfo.Name) as Action <string>;
            if (_objTarget is CompBase)
            {
                _compObj = _objTarget as CompBase;
                U.RegisterOnChanged(propertyLambda, OnChanged);
            }
            OnChanged(_propertyGetter());
        }
Example #8
0
 /// <summary>
 /// Rebuild all the tree components
 /// </summary>
 public void Rebuild()
 {
     treeComponents.Nodes.Clear();
     tabPages.Controls.Clear();
     try
     {
         _rootComp = U.RootComp;
         treeComponents.BeginUpdate();
         BuildTree(treeComponents.Nodes, U.RootComp);
         treeComponents.EndUpdate();
     }
     catch (Exception ex)
     {
         U.LogPopup(ex, "Could not rebuild component tree.");
     }
     //treeComponents.ExpandAll();
     CompBase.OnChangedName             += new CompBase.NameChangedEventHandler(OnChangedCompName);
     CompBase.OnRemovingComponent       += new CompBase.ComponentEventHandler(OnRemovingComponent);
     CompBase.OnAddedComponent          += new CompBase.ComponentEventHandler(OnAddedComponent);
     CompBase.OnSortedComponentChildren += new CompBase.ComponentEventHandler(OnSortedComponentChildren);
 }
Example #9
0
 private void RecurseConstructChild(CompBase child, CompBase readComp)
 {
     if (child.ChildArray != null)
     {
         foreach (CompBase subChild in child.ChildArray)
         {
             CompBase foundChild = readComp.FindChild(subChild.Name);
             if (foundChild != null)
             {
                 if (subChild.ChildArray != null)
                 {
                     RecurseConstructChild(subChild, foundChild);
                 }
             }
             else
             {
                 readComp.Add(subChild);
             }
         }
     }
 }
Example #10
0
        private void OnChanged(string id)
        {
            if (_editing)
            {
                return;
            }
            _id = id;
            // Clean up
            _returnType = Type.GetType("System." + _sReturnType.ToString());

            if (U.ComponentExists(ScopeID))
            {
                _rootNode = U.GetComponent(ScopeID);
            }
            else
            {
                _rootNode = U.RootComp;
            }

            BuildAllSections();
            RepositionControls();
        }
Example #11
0
        private void BuildTree(TreeNodeCollection treeNode, CompBase compParent)
        {
            if (compParent.HasChildren)
            {
                foreach (CompBase compChild in compParent.ChildArray)
                {
                    TreeNode nd = null;
                    if (treeNode.ContainsKey(compChild.ID))
                    {
                        nd     = treeNode.Find(compChild.ID, false)[0];
                        nd.Tag = compChild;
                    }
                    else
                    {
                        nd     = treeNode.Add(compChild.ID, compChild.Name);
                        nd.Tag = compChild;
                    }

                    BuildTree(nd.Nodes, compChild);
                }
            }
        }
        private void DeletedCond()
        {
            CompBase selComp = null;

            if (treeComponents.SelectedNode == null)
            {
                return;
            }
            else
            {
                selComp = treeComponents.SelectedNode.Tag as CompBase;
            }

            if (!(selComp is SMSubCondBase))
            {
                return;
            }

            selComp.Parent.Remove(selComp);
            treeComponents.Nodes.Clear();
            Rebuild();
        }
        private void btnAddAND_Click(object sender, EventArgs e)
        {
            CompBase selComp = null;

            if (treeComponents.SelectedNode == null)
            {
                selComp = null;
            }
            else
            {
                selComp = treeComponents.SelectedNode.Tag as CompBase;
                if (selComp is SMTransition)
                {
                    _currentTransitionItem = selComp as SMTransition;
                }
                else
                {
                    _currentTransitionItem = GetTransitionParent(selComp);
                }
            }

            if (selComp == null)
            {
                return;
            }

            //Prevent incorrect added
            if (((selComp is SMTransition) && ((selComp as SMTransition).ChildArray != null && (selComp as SMTransition).ChildArray.Length != 0)) ||
                selComp is SMSubCond)
            {
                return;
            }


            selComp.Add(new SMAndCond());
            treeComponents.Nodes.Clear();
            Rebuild();
        }
Example #14
0
        /// <summary>
        ///Unregister all the unique ids for this component
        /// </summary>
        /// <param name="ID"></param>
        public void UnregisterComponent(CompBase comp)
        {
            List <string> namelist = GetNameList(comp);

            lock (_dictComponents)
            {
                foreach (string name in namelist)
                {
                    if (_dictComponents.ContainsKey(name))
                    {
                        object obj = _dictComponents[name];
                        if (obj is CompBase)
                        {
                            _dictComponents.Remove(name);
                        }
                        else if (obj is List <CompBase> )
                        {
                            (obj as List <CompBase>).Remove(comp);
                        }
                        _dictComponents.Remove(name);
                    }
                }
            }
        }
Example #15
0
        public void Add(ComponentDefinition compDef, eCleanUpMode cleanUpMode = eCleanUpMode.None)
        {
            foreach (Type tyLoaded in s_loadedCompTypes)
            {
                compDef.ConfirmNotPluginType(tyLoaded);
            }
            foreach (Type tyPlugIn in s_pluginCompTypes)
            {
                compDef.AssignPlugInType(tyPlugIn);
            }

            List <ComponentDefinition> unresolvedPlugins = new List <ComponentDefinition>();

            compDef.GetUnloadedPlugins(unresolvedPlugins);
            // Assigns Sims, adds overrides to Serializer
            CreateSimClasses(compDef, unresolvedPlugins);

            AppStatus(string.Format("Reading {0}", compDef.Name));

            //
            CompBase compRead = ReadXmlFile(compDef.CompType, compDef.Name);

            if (compRead == null)
            {
                compRead = Activator.CreateInstance(compDef.CompType, compDef.Name) as CompBase;
            }
            else
            {
                CompBase child = Activator.CreateInstance(compDef.CompType, compDef.Name) as CompBase;
                compDef.CreateComponents(child);
                RecurseCleanUpChild(child, compRead, cleanUpMode);
            }
            compDef.CreateComponents(compRead);
            base.Add(compRead);
            compRead.Initialize();
        }
Example #16
0
        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);
                }
            }
        }
Example #17
0
        private bool HomeAxisDS402(CompBase compAxis, int homeMethod)
        {
            if (listAxis.ContainsKey(compAxis))
            {
                MMCSingleAxis singleAxis = listAxis[compAxis];
                if (!OKtoCmdMove(singleAxis))
                {
                    return(false);
                }
                try
                {
                    OPM402 opMode = singleAxis.GetOpMode();
                    if (opMode != OPM402.OPM402_HOMING_MODE)
                    {
                        try
                        {
                            singleAxis.SetOpMode(OPM402.OPM402_HOMING_MODE);
                            Thread.Sleep(500); //wait Mode Change;
                        }
                        catch (Exception ex)
                        {
                            U.LogPopup(ex, "Cannot change to Homing mode for axis '{0}'", compAxis.Name);
                            return(false);;
                        }
                    }
                    MMC_HOMEDS402Params hParam = new MMC_HOMEDS402Params();
                    hParam.dbPosition     = 0;
                    hParam.eBufferMode    = MC_BUFFERED_MODE_ENUM.MC_BUFFERED_MODE;
                    hParam.uiHomingMethod = homeMethod;  // Index_Axis = 33, X_Axis = 1, Y_Axis = 1, Z_Axis = 2
                    hParam.fAcceleration  = 200f;
                    //hParam.fDistanceLimit = 200f;
                    //hParam.uiTimeLimit = 10000;
                    //hParam.fTorqueLimit = 0f;
                    hParam.fVelocity = 20f;
                    hParam.ucExecute = 1;
                    if (GetOperatingMode(singleAxis) != OPM402.OPM402_HOMING_MODE)
                    {
                        try
                        {
                            singleAxis.SetOpMode(OPM402.OPM402_HOMING_MODE);
                            Thread.Sleep(500); //wait Mode Change;
                        }
                        catch (MMCException ex)
                        {
                            U.LogPopup(ex, "Cannot change to Homing mode for '{0}'", singleAxis.AxisName);
                            return(false);;
                        }
                    }

                    try
                    {
                        singleAxis.HomeDS402(hParam);
                        U.SleepWithEvents(200);
                        WaitHomingDone(singleAxis, 25000);//(int)hParam.uiTimeLimit);
                    }
                    catch (MMCException ex)
                    {
                        U.LogPopup(ex, "Homing error for '{0}'", singleAxis.AxisName);
                        singleAxis.Reset();
                        return(false);
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    U.LogError(ex, "Failed to home '{0}'", compAxis.Name);
                    singleAxis.Reset();
                }
            }
            return(false);
        }
Example #18
0
        /// <summary>
        /// Set a digital output
        /// </summary>
        /// <param name="boolOutput"></param>
        /// <param name="value"></param>
        public override void Set(BoolOutput boolOutput, bool value)
        {
            VAR_TYPE     varT     = VAR_TYPE.BYTE_ARR;
            PI_VAR_UNION varUnion = new PI_VAR_UNION();


            CompBase compAxis = boolOutput.GetParent <RealAxis>();

            if (compAxis == null)
            {
                compAxis = boolOutput.GetParent <RealRotary>();
                if (compAxis == null)
                {
                    compAxis = boolOutput.GetParent <IOBoolChannel>();
                }
            }


            if (listAxis.ContainsKey(compAxis))
            {
                try
                {
                    MMCSingleAxis singleAxis = listAxis[compAxis];

                    if (compAxis is RealRotary)
                    {
                        int val = value ? 1 : 0;
                        //singleAxis.SetDigOutputs(boolOutput.Channel << 16, (byte)(value ? 0x1 : 0x0), 0x0);
                        singleAxis.SendIntCmdViaSDO(string.Format("OB[{0}]={1}", boolOutput.Channel, val), 1000);
                    }
                    else if (compAxis is RealAxis)
                    {
                        uint val     = outputVal[compAxis];
                        uint chanBit = (uint)(1 << (16 + boolOutput.Channel));
                        if (value)
                        {
                            val |= chanBit;
                        }
                        else
                        {
                            val &= ~chanBit;
                        }
                        singleAxis.SetDigOutputs32Bit(0, val);
                        outputVal[compAxis] = val;
                    }

                    else
                    {
                        UInt16 index = (UInt16)boolOutput.Channel;

                        if (value)
                        {
                            varUnion.s_byte = 0;
                        }
                        else
                        {
                            varUnion.s_byte = 1;
                        }
                        singleAxis.WritePIVar(index, varUnion, varT);
                    }

                    boolOutput.Value = value;
                    //singleAxis.SetDigOutputs(chan, (byte)(value ? 1 : 0), (byte)1);
                }
                catch (Exception ex)
                {
                    U.LogPopup(ex, "Trouble setting Digital Output ({0})", boolOutput.Name);
                }
            }
        }
Example #19
0
        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);
        }
Example #20
0
 public AppChangeUserFrm()
 {
     InitializeComponent();
     _allUser = U.GetComponent(AppConstStaticName.ALL_USER);
 }
 /// <summary>
 /// Create the components in case they do not exist
 /// </summary>
 /// <param name="comp"></param>
 public void CreateComponents(CompBase comp)
 {
     CreateComponent(comp);
 }
Example #22
0
 /// <summary>
 /// Called when we add a Method to this action flow item
 /// </summary>
 /// <param name="child"></param>
 public override void Add(CompBase child)
 {
     base.Add(child);
     NeedsRebuild = true;
 }
        private void AddSubCondition()
        {
            if (smPropID.ID == null || smPropID.ID == "")
            {
                return;
            }

            CompBase selComp = null;

            if (treeComponents.SelectedNode == null)
            {
                selComp = _transitionItem;
            }
            else
            {
                selComp = treeComponents.SelectedNode.Tag as CompBase;
            }

            //Prevent incorrect added
            if ((selComp == _transitionItem && (_transitionItem.ChildArray != null && _transitionItem.ChildArray.Length != 0)) ||
                selComp is SMSubCond)
            {
                return;
            }


            if (ConditionaValue == "")
            {
                MessageBox.Show("Please sepicify condition value.");
                return;
            }

            //System.Reflection.PropertyInfo propInfo = U.GetPropertyInfo(smPropID.ID);
            //Type propType = propInfo.PropertyType;

            //try
            //{
            //    TypeDescriptor.GetConverter(propType).ConvertFromString(ConditionaValue);
            //}
            //catch(Exception ex)
            //{
            //    MessageBox.Show(ex.ToString());
            //    return;
            //}


            SMSubCond subCond = new SMSubCond();

            subCond.ConditionID          = smPropID.ID;
            subCond.ConditionValueString = ConditionaValue;
            subCond.OperatorString       = cbOperator.Text;

            try
            {
                subCond.Rebuild();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return;
            }


            selComp.AppendAt(null, subCond);

            treeComponents.Nodes.Clear();
            Rebuild();

            smPropID.PrimaryStatement.Clear();
            DummyID          = String.Empty;
            smPropID.ScopeID = _transitionItem.ParentContainer.ScopeID;
            smPropID.BindTwoWay(() => DummyID);

            smValueID.PrimaryStatement.Clear();
            ConditionaValue   = String.Empty;
            smValueID.ScopeID = _transitionItem.ParentContainer.ScopeID;
            smValueID.BindTwoWay(() => ConditionaValue);

            cbOperator.SelectedIndex = 0;
        }
        private void InitializeApplication()
        {
            try
            {
                #region  Machine Standard Pattern
                // Essential
                U.RootComp.Add(new DefaultLogger(AppConstStaticName.DEFAULT_LOGGER));
                // Force load of certain references
                Type ty = typeof(SMFlowChartCtlBasic);
                //Machine
                ComponentDefinition machineDef = new ComponentDefinition(typeof(AppMachine.Comp.AppMachine), AppConstStaticName.APP_MACHINE);
                //Essential add Machine to Root

                #endregion

                #region Standard Machine Common Param Pattern
                U.RootComp.Add(new AppCommonParam(AppConstStaticName.COMMON_PARAMETER));
                #endregion

                #region Station Standard Pattern
                //Station
                CompBase stations = new CompBase(AppConstStaticName.ALL_STATIONS);
                #endregion

                //Station Define

                /*Add New Station Here (Example in Below)
                 * stations.Add(new AppFeederStation(AppConstStaticName.FEEDSTATION));
                 * stations.Add(new AppVisionStation(AppConstStaticName.VISIONSTATION));
                 */

                stations.Add(new AppStationBase("Sample Station"));

                #region Station Standard Pattern
                U.RootComp.Add(stations, CompRoot.eCleanUpMode.AllLayer);
                #endregion


                //IO System Define
                //Add IO Component Here (Example in Below)
                //ComponentDefinition ioSystem = new ComponentDefinition(IOSystemBase.PlugIns.ModbusTcpIO, AppConstStaticName.ALL_IO);
                ComponentDefinition ioSystem = new ComponentDefinition(typeof(IOSystemBase), "ModbusTcpIO", AppConstStaticName.ALL_IO);
                Inputs inputsIO            = new Inputs(AppConstStaticName.INPUTS);
                ComponentDefinition inputs = ioSystem.Add(inputsIO);


                //Inputs List Define

                /* Add IO Component Here (Example in Below)
                 * inputs.Add(new AppSafetyInput(AppConstStaticName.STARTPB) { Channel = 0 });//X1
                 * inputs.Add(new AppSafetyInput(AppConstStaticName.STOPPB) { Channel = 1 });//X2
                 * inputs.Add(new AppSafetyInput(AppConstStaticName.RESETPB) { Channel = 2 });//X3
                 */


                Outputs             outputsIO = new Outputs(AppConstStaticName.OUTPUTS);
                ComponentDefinition outputs   = ioSystem.Add(outputsIO);

                //Outputs List Define

                /*
                 * outputs.Add(new BoolOutput(AppConstStaticName.REDLIGHT) { Channel = 0 });
                 * outputs.Add(new BoolOutput(AppConstStaticName.AMBERLIGHT) { Channel = 1 });
                 * outputs.Add(new BoolOutput(AppConstStaticName.GREENLIGHT) { Channel = 2 });
                 * outputs.Add(new BoolOutput(AppConstStaticName.BUZZER) { Channel = 3 });
                 */

                try
                {
                    U.RootComp.Add(ioSystem, CompRoot.eCleanUpMode.AllLayer);
                }
                catch (Exception ex)
                {
                    U.LogPopup(ex, "IO System Initialize Unsuccessful in loading of application");
                }



                //Vision System Define

                /* Add Vision Conponent Here (Example in Below)
                 * //Vision
                 * ComponentDefinition visionSys = machineDef.Add(VisionSystemBase.PlugIns.Cognex9, AppConstStaticName.VISIONSYSTEM);
                 * ComponentDefinition camAOI = visionSys.Add(CameraBase.PlugIns.CognexCamera9, AppConstStaticName.VISIONCAMERA);
                 * ComponentDefinition aoiJob = camAOI.Add(VisionJobBase.PlugIns.CognexJob9, AppConstStaticName.VISIONJOB);
                 * aoiJob.Add(new AppVisionAOIResult(AppConstStaticName.VISIONJOBRESULT));
                 */



                //Motion System Define

                /* Add Motion Conponent Here (Example in Below)
                 *
                 * //Feed Motion
                 * ComponentDefinition feedMotionSys = machineDef.Add(MotionSystemBase.PlugIns.YamahaTrServo, AppConstStaticName.FEEDMOTIONSYSTEM);
                 * ComponentDefinition feedMotionAxes = feedMotionSys.Add(new AppRealAxes(AppConstStaticName.FEEDMOTIONAXES));
                 * ComponentDefinition feedYAxis = feedMotionAxes.Add(new AppRealAxis(AppConstStaticName.FEEDYAXIS) { AxisNo = 0, MaxLimit = 75, MinLimit = 0, DefaultSpeed = 70.0, AccelDecel = 100.0 });
                 *
                 * //Lift1 Motion
                 * ComponentDefinition lift1MotionSys = machineDef.Add(MotionSystemBase.PlugIns.IAIScon, AppConstStaticName.LIFT1MOTIONSYSTEM);
                 * ComponentDefinition lift1MotionAxes = lift1MotionSys.Add(new AppRealAxes(AppConstStaticName.LIFT1MOTIONAXES));
                 * ComponentDefinition lift1ZAxis = lift1MotionAxes.Add(new AppRealAxis(AppConstStaticName.LIFT1ZAXIS) { AxisNo = 0, MaxLimit = 75, MinLimit = 0, DefaultSpeed = 70.0, AccelDecel = 0.1  });
                 *
                 * //Lift2 Motion
                 * ComponentDefinition lift2MotionSys = machineDef.Add(MotionSystemBase.PlugIns.IAIScon, AppConstStaticName.LIFT2MOTIONSYSTEM);
                 * ComponentDefinition lift2MotionAxes = lift2MotionSys.Add(new AppRealAxes(AppConstStaticName.LIFT2MOTIONAXES));
                 * ComponentDefinition lift2ZAxis = lift2MotionAxes.Add(new AppRealAxis(AppConstStaticName.LIFT2ZAXIS) { AxisNo = 0, MaxLimit = 75, MinLimit = 0, DefaultSpeed = 70.0, AccelDecel = 0.1 });
                 */


                #region State Machine Standard Pattern
                //Define Stae Machine Component
                ComponentDefinition smDef = new ComponentDefinition(typeof(CompBase), AppConstStaticName.ALL_STATE_MACHINE);

                smDef.Add(new SMStateMachine(AppConstStaticName.SM_RESET));
                smDef.Add(new SMStateMachine(AppConstStaticName.SM_MAIN));
                #endregion

                //State Machine Define

                /* Add New State Machine Here (Example in Below)
                 * smDef.Add(new SMStateMachine(AppConstStaticName.SM_FEED));
                 * smDef.Add(new SMStateMachine(AppConstStaticName.SM_VISION));
                 */


                #region State Semi-Auto Machine Standard Pattern
                //Define Stae Machine Component
                ComponentDefinition smSemiAutoDef = new ComponentDefinition(typeof(CompBase), AppConstStaticName.ALL_SEMI_AUTO_STATE_MACHINE);
                smSemiAutoDef.Add(new SMStateMachine(AppConstStaticName.SM_SEMI_RESET));
                smSemiAutoDef.Add(new SMStateMachine(AppConstStaticName.SM_SEMI_MAIN));
                #endregion

                //Semi State Machine Define

                /* Add New State Machine Here (Example in Below)
                 * smSemiAutoDef.Add(new SMStateMachine(AppConstStaticName.SM_SEMI_FEED));
                 * smSemiAutoDef.Add(new SMStateMachine(AppConstStaticName.SM_SEMI_VISION));
                 */


                #region State Machine Standard Pattern
                U.RootComp.Add(smDef, CompRoot.eCleanUpMode.FirstLayer);
                #endregion

                #region Semi Auto State Machine Standard Pattern
                U.RootComp.Add(smSemiAutoDef, CompRoot.eCleanUpMode.FirstLayer);
                #endregion

                #region Recipe Standard Pattern
                ComponentDefinition recipeDef = new ComponentDefinition(typeof(CompBase), AppConstStaticName.ALL_RECIPES);
                recipeDef.Add(new AppProductRecipe(AppConstStaticName.REF_CURRENT_RECIPE));
                recipeDef.Add(new AppProductRecipe(AppConstStaticName.SAMPLE_RECIPE));
                U.RootComp.Add(recipeDef);
                #endregion

                #region User Standard Pattern
                ComponentDefinition users     = new ComponentDefinition(typeof(CompBase), AppConstStaticName.ALL_USER);
                AppUserInfo         adminUser = new AppUserInfo(AppConstStaticName.ADMIN_USER)
                {
                    UserEN = "00000", UserCode = "00000", UserLevel = Comp.AppEnums.eAccessLevel.Supervisor
                };
                users.Add(adminUser);
                AppUserInfo guestUser = new AppUserInfo(AppConstStaticName.GUEST_USER)
                {
                    UserEN = "00001", UserCode = "00001", UserLevel = Comp.AppEnums.eAccessLevel.Operator
                };
                users.Add(adminUser);
                users.Add(guestUser);

                U.RootComp.Add(users);
                #endregion

                #region Standard Pattern

                try
                {
                    //Add machine to root comp after add all components belong to the machine.
                    U.RootComp.Add(machineDef);
                    AppMachine.Comp.AppMachine.This.IOList.Initialize();
                }
                catch (Exception ex)
                {
                    U.LogPopup(ex, "Machine Initialize Unsuccessful in loading of application");
                }


                // Essential call after all component definitions
                U.RootComp.InitializeIDReferences();

                this.BeginInvoke((MethodInvoker) delegate
                {
                    _mainPanel.RebuildCompBrowser();


                    // //State Machine Instance with bind to control
                    GetSMInstanceWithBindControl();


                    // //Semi Auto State Machine Instance with bind to control
                    GetSMSemiAutoInstanceWithBindControl();


                    //Initiate User
                    if (AppMachine.Comp.AppMachine.This.CurrentUser == null)
                    {
                        AppMachine.Comp.AppMachine.This.CurrentUser = U.GetComponent(AppConstStaticName.ADMIN_USER) as AppUserInfo;
                    }

                    //Prepare Stop When Finish
                    mcbStopWhenFinished.DataBindings.Add("Checked", AppMachine.Comp.AppMachine.This, "StopWhenFinished");

                    //Prepare All Panel
                    _mainPanel.PrepareAllPanel();


                    //Update Operation Button
                    UpdateControlButtons();

                    //Set User Access for Current User
                    SetUserAccess(AppMachine.Comp.AppMachine.This.CurrentUser);
                });


                U.RegisterOnChanged(() => AppMachine.Comp.AppMachine.This.CurrentUser, CurrentUserOnChange);

                AppMachine.Comp.AppMachine.This.LoadStartupRecipe();
                VerifyCriticalSimulateComponent();
                _mainPanel.RegisterMachineStatusEvent();
                #endregion
            }

            #region Standard Pattern
            catch (Exception ex)
            {
                U.LogPopup(ex + " " + ex.StackTrace, "Unsuccessful in loading of application");
            }
            finally
            {
                this.BeginInvoke((MethodInvoker) delegate
                {
                    _splashThread.Abort();
                });
            }
            #endregion


            #region Auto Lockout Standard Pattern
            _autoLockoutTimer.Interval = 500;
            _autoLockoutTimer.Elapsed += new System.Timers.ElapsedEventHandler(AutoLockoutTimer_OnElapse);
            _autoLockoutTimer.Enabled  = true;
            #endregion
        }
 /// <summary>
 /// Constructor for Component
 /// </summary>
 public ComponentDefinition(CompBase comp)
 {
     _comp = comp;
     _name = comp.Name;
 }
Example #26
0
 public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
 {
     var data = new CompBase {
         Value = Variable
     };
 }
 public AppUserControlBase(CompBase comp)
 {
     _comp = comp;
     this.Handle.ToString();
     InitializeComponent();
 }
Example #28
0
 /// <summary>
 /// Copy certain non-unique properties
 /// </summary>
 /// <param name="compTo"></param>
 public override void ShallowCopyTo(CompBase compTo)
 {
     base.ShallowCopyTo(compTo);
     _shallowCopyTo(compTo);
 }