Exemple #1
0
        private ITxPlcLogicBehaviorParameter SegPa(TxPlcLogicBehavior LB, string paName, TxPlcExpression expression)
        {
            TxPlcLogicBehaviorInternalExitParameterCreationData exp1 = new TxPlcLogicBehaviorInternalExitParameterCreationData();

            exp1.Name         = paName;
            exp1.Expression   = expression;
            exp1.HardwareType = TxPlcHardwareType.Bool;
            ITxPlcLogicBehaviorParameter pa = LB.CreateParameter(exp1);

            return(pa);
        }
Exemple #2
0
        private ITxPlcLogicBehaviorEntry SegEn(TxPlcLogicBehavior LB, TxPlcSignalBase sig1)
        {
            TxPlcLogicBehaviorEntryCreationData en1 = new TxPlcLogicBehaviorEntryCreationData(sig1.Name);

            en1.HardwareType = (TxPlcHardwareType)sig1.DataType;
            ITxPlcLogicBehaviorEntry e1 = LB.CreateEntry(en1);

            if (sig1 != null)
            {
                e1.ConnectSignal(sig1);
            }
            return(e1);
        }
Exemple #3
0
        private ITxPlcLogicBehaviorExit SegEx(TxPlcLogicBehavior LB, TxPlcSignalBase sig1, TxPlcExpression expression)
        {
            TxPlcLogicBehaviorExitCreationData ex1 = new TxPlcLogicBehaviorExitCreationData();

            ex1.Name         = sig1.Name;
            ex1.Expression   = expression;
            ex1.HardwareType = TxPlcHardwareType.Bool;
            ITxPlcLogicBehaviorExit ex = LB.CreateExit(ex1);

            if (sig1 != null && !sig1.IsConnectedToLBExit)
            {
                ex.ConnectSignal(sig1);
            }
            return(ex);
        }
Exemple #4
0
        private void ZoneLBS(string Rob1, TxObjectList Rob1Sigs, string Rob2, TxObjectList Rob2Sigs, string[] Zone, TxPlcLogicBehavior LB)
        {
            TxPlcExpressionBuilder eb1 = new TxPlcExpressionBuilder();

            try
            {
                foreach (string z in Zone)
                {
                    string str1 = textBox12.Text.Replace("X", z);
                    string str2 = textBox11.Text.Replace("X", z);

                    ITxPlcLogicBehaviorEntry en1 = SegEn(LB, FindSig(Rob1Sigs, str1, true));
                    ITxPlcLogicBehaviorEntry en2 = SegEn(LB, FindSig(Rob2Sigs, str2, true));
                    ITxPlcLogicBehaviorEntry en3 = SegEn(LB, FindSig(Rob2Sigs, str1, true));

                    eb1.Add(TxPlcExpressionOperator.Not);
                    eb1.Add(en1);
                    eb1.Add(TxPlcExpressionOperator.And);
                    eb1.Add(TxPlcExpressionOperator.LeftParenthesis);
                    eb1.Add(TxPlcExpressionOperator.Not);
                    eb1.Add(en2);
                    eb1.Add(TxPlcExpressionOperator.Or);
                    eb1.Add(en3);
                    eb1.Add(TxPlcExpressionOperator.RightParenthesis);

                    ITxPlcLogicBehaviorExit ex1 = SegEx(LB, FindSig(Rob1Sigs, str2, false), eb1.Expression);
                }
            }
            catch (System.Exception ex)
            {
            }
        }
Exemple #5
0
        private void SegLBS()
        {
            string str1 = textBox9.Text;  //ok
            string str2 = textBox10.Text; //seg
            string str3 = textBox8.Text;  //req

            TxPlcLogicBehavior LB = CreatNewLB("RobSeg");
            Dictionary <string, ITxPlcLogicBehaviorEntry>     LBEnDic  = new Dictionary <string, ITxPlcLogicBehaviorEntry>();
            Dictionary <string, ITxPlcLogicBehaviorParameter> LBPaDic  = new Dictionary <string, ITxPlcLogicBehaviorParameter>();
            Dictionary <string, TxPlcExpressionBuilder>       ExbuDic  = new Dictionary <string, TxPlcExpressionBuilder>();
            Dictionary <string, TxPlcExpressionBuilder>       ExbuDic1 = new Dictionary <string, TxPlcExpressionBuilder>();

            //try
            //{
            for (int i = 0; i < Robots.Length; i++)
            {
                TxRobot r1 = Robots[i];
                ITxPlcLogicBehaviorEntry en1 = SegEn(LB, FindSig(r1.Signals, str2, true));
                ITxPlcLogicBehaviorEntry en2 = SegEn(LB, FindSig(r1.Signals, str3, true));
                LBEnDic.Add(r1.Name + str2, en1);
                LBEnDic.Add(r1.Name + str3, en2);
            }

            for (int i = 0; i < dataGridView2.Rows.Count; i++)
            {
                if (dataGridView2.Rows[i].Cells[0].Value != null && dataGridView2.Rows[i].Cells[1].Value != null && dataGridView2.Rows[i].Cells[0].Value != "" && dataGridView2.Rows[i].Cells[1].Value != "")
                {
                    string  rob1name   = dataGridView2.Rows[i].Cells[0].Value.ToString();
                    string  strseg1    = dataGridView2.Rows[i].Cells[1].Value.ToString();
                    string  rob1segok  = rob1name + str1;
                    string  rob1seg    = rob1name + str2;
                    string  rob1segreq = rob1name + str3;
                    TxRobot r1         = RobDictionary[rob1name];
                    if (!ExbuDic1.ContainsKey(rob1segok))
                    {
                        ExbuDic1.Add(rob1segok, new TxPlcExpressionBuilder());
                        ExbuDic1[rob1segok].Add(LBEnDic[rob1segreq]);
                        ExbuDic1[rob1segok].Add(TxPlcExpressionOperator.And);
                        ExbuDic1[rob1segok].Add(TxPlcExpressionOperator.LeftParenthesis);
                    }

                    //SegPa(LB,rob1name+"_seg_"+c,);
                    string Parob1seg = "";
                    int    c         = 0;
                    if (int.TryParse(strseg1, out c))
                    {
                        Parob1seg = rob1name + "_seg_" + strseg1;
                        if (!ExbuDic.ContainsKey(Parob1seg))
                        {
                            ExbuDic.Add(Parob1seg, new TxPlcExpressionBuilder());
                            TxPlcValue pv = new TxPlcValue();
                            pv.ByteValue = (ushort)c;
                            ExbuDic[Parob1seg].Add(TxPlcExpressionOperator.LeftParenthesis);
                            ExbuDic[Parob1seg].Add(LBEnDic[rob1seg]);
                            ExbuDic[Parob1seg].Add(TxPlcExpressionOperator.IsEqualTo);
                            ExbuDic[Parob1seg].Add(TxPlcSignalDataType.Byte, pv);
                            ExbuDic[Parob1seg].Add(TxPlcExpressionOperator.RightParenthesis);
                            ExbuDic[Parob1seg].Add(TxPlcExpressionOperator.And);
                        }
                    }

                    for (int j = 0; j < dataGridView8.Columns.Count; j++)
                    {
                        string rob2name = dataGridView8.Columns[j].HeaderText;
                        string rob2seg  = rob2name + str2;

                        if (dataGridView8.Rows[i].Cells[j].Value != null && dataGridView8.Rows[i].Cells[j].Value != "")
                        {
                            if (j > 0)
                            {
                                ExbuDic[Parob1seg].Add(TxPlcExpressionOperator.And);
                            }
                            string strseg2 = dataGridView8.Rows[i].Cells[j].Value.ToString();

                            ExbuDic[Parob1seg].Add(TxPlcExpressionOperator.LeftParenthesis);
                            ExbuDic[Parob1seg].Add(LBEnDic[rob2seg]);
                            ExbuDic[Parob1seg].Add(TxPlcExpressionOperator.IsEqualTo);
                            int c1 = 0;
                            if (int.TryParse(strseg2, out c1))
                            {
                                TxPlcValue pv = new TxPlcValue();
                                pv.ByteValue = (ushort)c1;
                                ExbuDic[Parob1seg].Add(TxPlcSignalDataType.Byte, pv);
                                ExbuDic[Parob1seg].Add(TxPlcExpressionOperator.RightParenthesis);
                            }
                        }
                    }

                    LBPaDic.Add(Parob1seg, SegPa(LB, Parob1seg, ExbuDic[Parob1seg].Expression));
                }
            }

            foreach (KeyValuePair <string, TxPlcExpressionBuilder> k in ExbuDic1)
            {
                string   strkey = k.Key;
                string[] str    = strkey.Split('_');
                TxRobot  r1     = RobDictionary[str[0]];
                int      j      = 0;
                foreach (KeyValuePair <string, ITxPlcLogicBehaviorParameter> k1 in LBPaDic)
                {
                    if (k1.Key.Contains(str[0]))
                    {
                        if (j > 0 && j < LBPaDic.Count)
                        {
                            k.Value.Add(TxPlcExpressionOperator.Or);
                        }
                        k.Value.Add(k1.Value);
                        j = j + 1;
                    }
                }

                k.Value.Add(TxPlcExpressionOperator.RightParenthesis);
                SegEx(LB, FindSig(r1.Signals, str[1], false), k.Value.Expression);
            }

            //}
            //catch (System.Exception ex)
            //{

            //}
        }
Exemple #6
0
        private void ZoneLBM(string Rob1, TxObjectList Rob1Sigs, string Rob2, TxObjectList Rob2Sigs, string[] Zone, TxPlcLogicBehavior LB)
        {
            TxPlcExpressionBuilder eb1 = new TxPlcExpressionBuilder();

            try
            {
                foreach (string z in Zone)
                {
                    string str1 = tb_ZoneReq.Text.Replace("Rob", Rob1).Replace("X", z);
                    string str2 = tb_Zonefree.Text.Replace("Rob", Rob2).Replace("X", z);
                    string str3 = tb_ZoneEnable.Text.Replace("Rob", Rob2).Replace("X", z);
                    string str4 = tb_ZoneEnable.Text.Replace("Rob", Rob1).Replace("X", z);


                    ITxPlcLogicBehaviorEntry en1 = SegEn(LB, FindSig(Rob1Sigs, str1, true));
                    ITxPlcLogicBehaviorEntry en2 = SegEn(LB, FindSig(Rob2Sigs, str2, true));
                    ITxPlcLogicBehaviorEntry en3 = SegEn(LB, FindSig(Rob2Sigs, str3, false));

                    eb1.Add(en1);
                    eb1.Add(TxPlcExpressionOperator.And);
                    eb1.Add(en2);
                    eb1.Add(TxPlcExpressionOperator.And);
                    eb1.Add(TxPlcExpressionOperator.Not);
                    eb1.Add(en3);

                    ITxPlcLogicBehaviorExit ex1 = SegEx(LB, FindSig(Rob1Sigs, str4, false), eb1.Expression);
                }
            }
            catch (System.Exception ex)
            {
            }
        }