Beispiel #1
0
 private void RefreshPAN_CycleCommands(Cycle c)
 {
     PAN_CycleCommands.Controls.Clear();
     foreach (KeyValueProperty kvp in c.RequiredKeys)
     {
         CapabilityItem capi = new CapabilityItem(kvp);
         capi.Top  = PAN_CycleCommands.Controls.Count * capi.Height;
         capi.Left = 0;
         PAN_CycleCommands.Controls.Add(capi);
     }
     foreach (KeyValueProperty kvpo in c.OptionalKeys)
     {
         CapabilityItem capi = new CapabilityItem(kvpo);
         capi.Top  = PAN_CycleCommands.Controls.Count * capi.Height;
         capi.Left = 0;
         PAN_CycleCommands.Controls.Add(capi);
     }
 }
Beispiel #2
0
        private void BTN_Generate_Click(object sender, EventArgs e)
        {
            if (LB_Cycle[TAB_Cavities.SelectedIndex].SelectedIndices.Count > 0)
            {
                XmlDocument batch = new XmlDocument();
                XmlNode     node  = batch.CreateNode(XmlNodeType.Element, "Batch", null);
                batch.AppendChild(node);

                Cycle curcycle;
                int   stepcount = 0;
                foreach (int i in LB_Cycle[TAB_Cavities.SelectedIndex].SelectedIndices)
                {
                    curcycle = cycles[TAB_Cavities.SelectedIndex][i];
                    List <string> inkeys     = new List <string>();
                    List <string> outkeys    = new List <string>();
                    List <string> cancelkeys = new List <string>();
                    outkeys.Add(curcycle.KeyID + "," + (curcycle.KeyValue.EnumName != null ? curcycle.Enum.ToString("X2") : curcycle.CCID.ToString()));
                    inkeys.Add(curcycle.KeyID + "," + (curcycle.KeyValue.EnumName != null ? curcycle.Enum.ToString("X2") : curcycle.CCID.ToString()));
                    cancelkeys.Add(curcycle.KeyID + "," + "00");

                    foreach (KeyValueProperty kvpr in curcycle.RequiredKeys)
                    {
                        CapabilityItem capi = new CapabilityItem(kvpr);

                        int cooktime;
                        if (CB_CookTime.Checked && int.TryParse(TB_CookTime.Text, out cooktime) && capi.KVP.KeyValue.CapabilityName.EndsWith("CookTimeSet"))
                        {
                            capi.SetSelectedValue = capi.KVP.KeyValue.Process((cooktime * 60).ToString("X8"));
                        }

                        else if (capi.KVP.KeyValue.CapabilityName.EndsWith("TargetTemp"))
                        {
                            capi.SetSelectedValue = SetTargetTemp(capi.KVP);
                        }
                        else
                        {
                            if (CB_Randomize.Checked)
                            {
                                capi.SetSelectedValue = capi.ReturnRandom();
                            }
                        }

                        if (!(capi.KVP.KeyValue.Format == "time" && capi.SelectedItem == "0:00:00"))
                        {
                            outkeys.Add(capi.KVP.KeyValue.KeyID + "," + (capi.KVP.IsEnum ? capi.SelectedItem.Substring(0, 2) : capi.SelectedItem));
                            inkeys.Add(capi.KVP.KeyValue.KeyID + "," + (capi.KVP.IsEnum ? capi.SelectedItem.Substring(0, 2) : capi.SelectedItem));
                            cancelkeys.Add(capi.KVP.KeyValue.KeyID + "," + (capi.KVP.IsEnum ? "00" : capi.KVP.KeyValue.Process(0.ToString("X" + capi.KVP.KeyValue.Length))));
                        }
                    }
                    if (!CB_Optional.Checked)
                    {
                        foreach (KeyValueProperty kvpr in curcycle.OptionalKeys)
                        {
                            CapabilityItem capi = new CapabilityItem(kvpr);

                            int cooktime;
                            int delaytime;
                            if (CB_CookTime.Checked && int.TryParse(TB_CookTime.Text, out cooktime) && capi.KVP.KeyValue.CapabilityName.EndsWith("CookTimeSet"))
                            {
                                capi.SetSelectedValue = capi.KVP.KeyValue.Process((cooktime * 60).ToString("X8"));
                            }
                            else if (CB_DelayTime.Checked && int.TryParse(TB_DelayTime.Text, out delaytime) && capi.KVP.KeyValue.CapabilityName.EndsWith("DelayTime"))
                            {
                                capi.SetSelectedValue = capi.KVP.KeyValue.Process((delaytime * 60).ToString("X8"));
                            }
                            else
                            {
                                if (CB_Randomize.Checked)
                                {
                                    capi.SetSelectedValue = capi.ReturnRandom();
                                }
                            }

                            if (!(capi.KVP.KeyValue.Format == "time" && capi.SelectedItem == "0:00:00"))
                            {
                                outkeys.Add(capi.KVP.KeyValue.KeyID + "," + (capi.KVP.IsEnum ? capi.SelectedItem.Substring(0, 2) : capi.SelectedItem));
                                inkeys.Add(capi.KVP.KeyValue.KeyID + "," + (capi.KVP.IsEnum ? capi.SelectedItem.Substring(0, 2) : capi.SelectedItem));
                                cancelkeys.Add(capi.KVP.KeyValue.KeyID + "," + (capi.KVP.IsEnum ? "00" : capi.KVP.KeyValue.Process(0.ToString("X" + capi.KVP.KeyValue.Length))));
                            }
                        }
                    }

                    outkeys.Add(curcycle.OperationKey.KeyID + "," + "02");
                    inkeys.Add(curcycle.OperationKey.KeyID + "," + "02");
                    inkeys.Add(curcycle.StateKey.KeyID + ",");
                    inkeys.Add(curcycle.DisplayTempKey.KeyID + ",");
                    cancelkeys.Add(curcycle.StateKey.KeyID + "," + "00");
                    cancelkeys.Add(curcycle.DisplayTempKey.KeyID + "," + curcycle.DisplayTempKey.Process("0000"));

                    int canceltime = 10000;
                    if (CB_Cancel.Checked && int.TryParse(TB_CancelTime.Text, out canceltime))
                    {
                        canceltime = canceltime * 1000;
                    }
                    stepcount++;
                    XmlNode newscript = batch.ImportNode(CreateScript(stepcount.ToString("00") + ". " + curcycle.Name, outkeys, inkeys, canceltime).SelectSingleNode("Script"), true);
                    batch.SelectSingleNode("Batch").AppendChild(newscript);
                    if (CB_Cancel.Checked)
                    {
                        stepcount++;
                        outkeys.Clear();
                        outkeys.Add(curcycle.OperationKey.KeyID + ",01");
                        XmlNode cancelscript = batch.ImportNode(CreateScript(stepcount.ToString("00") + ". " + curcycle.Name + " Cancel", outkeys, cancelkeys, 10000).SelectSingleNode("Script"), true);
                        batch.SelectSingleNode("Batch").AppendChild(cancelscript);
                    }
                }

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.FileName = "SymbIOT_Script-" + capabilityname + ".xml";
                sfd.Filter   = "Script Files (*.xml)|*.xml";
                DialogResult result = sfd.ShowDialog();
                if (result == DialogResult.OK && sfd.FileName != "")
                {
                    batch.Save(sfd.FileName);
                }
            }
        }