示例#1
0
        private void bBrowseQueriesVerification_Click(object sender, EventArgs e)
        {
            OpenFileDialog opd = new OpenFileDialog();

            opd.Filter = "Query files (*.kpq)|*.kpq";
            if (opd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string kpxFileName = opd.FileName;
                tbQueriesVerification.Text = opd.FileName;
                string[]   lines        = File.ReadAllLines(opd.FileName);
                Experiment kpExperiment = null;
                if (!string.IsNullOrEmpty(kpxFileName))
                {
                    if (new FileInfo(kpxFileName).Exists)
                    {
                        try
                        {
                            kpExperiment = KP.FromKpx(kpxFileName);
                        }
                        catch (Exception exception)
                        {
                            throw new Exception(string.Format("Failed to parse input file {0}. Reason: {1}", kpxFileName, exception.Message));
                        }
                    }
                    else
                    {
                        throw new Exception(string.Format("File '{0}' does not exist. Please specify a valid experiment file.", kpxFileName));
                    }
                }
                properties.Load(new List <string>(lines), kpExperiment);
            }
        }
示例#2
0
 private static void CREATE_plane()
 {
     EditorGUILayout.BeginVertical();
     EditorGUI.BeginChangeCheck();
     GUILayout.BeginHorizontal();
     // Editor value reset button
     if (GUILayout.Button(new GUIContent("Reset Editor"), EditorStyles.miniButton))
     {
         KP.Reset_create();
     }
     GUILayout.EndHorizontal();
     EditorGUILayout.Space();
     // Editor value for width and height of the created mesh [ float ]
     KP._width  = EditorGUILayout.FloatField("Width", KP._width);
     KP._height = EditorGUILayout.FloatField("Height", KP._height);
     EditorGUILayout.Space();
     // Editor value for width and height segments of the created mesh [ int ]
     KP._uSegments = EditorGUILayout.IntField("uSegments", KP._uSegments);
     KP._vSegments = EditorGUILayout.IntField("vSegments", KP._vSegments);
     EditorGUILayout.Space();
     GUILayout.BeginHorizontal();
     // Editor value for the pivot point of the created mesh Unity.TextAnchor
     GUILayout.Label("Pivot ");
     GUILayout.Space(18);
     KP._pivotIndex = EditorGUILayout.Popup(KP._pivotIndex, KP._pivotLabels);
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     // Editor value for the mesh face direction FACING.XZ
     GUILayout.Label("Facing ");
     GUILayout.Space(10);
     KP._faceIndex = EditorGUILayout.Popup(KP._faceIndex, kPoly.FACING);
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     // Editor value for triangle winding order
     GUILayout.Label("Winding");
     GUILayout.Space(2);
     KP._windinIndex = EditorGUILayout.Popup(KP._windinIndex, KP._windinLabels);
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     // Editor value for collider export
     GUILayout.Label("Collider ");
     GUILayout.Space(3);
     KP._colliderIndex = EditorGUILayout.Popup(KP._colliderIndex, KP._colliderLabels);
     GUILayout.EndHorizontal();
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     // Starting GUI changes check
     if (EditorGUI.EndChangeCheck())
     {
         KP._width     = Mathf.Clamp(KP._width, 0, int.MaxValue);
         KP._height    = Mathf.Clamp(KP._height, 0, int.MaxValue);
         KP._uSegments = Mathf.Clamp(KP._uSegments, 1, int.MaxValue);
         KP._vSegments = Mathf.Clamp(KP._vSegments, 1, int.MaxValue);
         //   Debug.Log("Change Editor");
     }
     EditorGUILayout.EndVertical();
 }
示例#3
0
文件: Role.cs 项目: d503e16/code
        public virtual List <string> GetData()
        {
            List <string> list = new List <string>();

            list.Add(convertBool(FirstBlood).ToString(CultureInfo.InvariantCulture));
            list.Add(convertBool(FirstTurret).ToString(CultureInfo.InvariantCulture));
            list.Add(KP.ToString(CultureInfo.InvariantCulture));
            list.Add(KDA.ToString(CultureInfo.InvariantCulture));
            return(list);
        }
示例#4
0
 /// <summary>
 /// Creates a table filter for filtering by device.
 /// </summary>
 private TableFilter CreateFilterByDevice(KP kp)
 {
     return(kp == null ?
            new TableFilter("KPNum", null)
     {
         Title = AppPhrases.EmptyDeviceFilter
     } :
            new TableFilter("KPNum", kp.KPNum)
     {
         Title = string.Format(AppPhrases.DeviceFilter, kp.KPNum)
     });
 }
示例#5
0
        /// <summary>
        /// Imports communication lines and devices.
        /// </summary>
        private void Import(out bool noData)
        {
            noData            = true;
            ImportedCommLines = new List <Settings.CommLine>();
            ImportedDevices   = new List <Settings.KP>();
            Settings settings = instance.CommApp.Settings;

            foreach (TreeNode commLineNode in treeView.Nodes)
            {
                if (commLineNode.Checked)
                {
                    CommLine          commLineEntity   = (CommLine)commLineNode.Tag;
                    Settings.CommLine commLineSettings = CommLineSettings;

                    if (commLineSettings == null)
                    {
                        // import communication line
                        noData                  = false;
                        commLineSettings        = SettingsConverter.CreateCommLine(commLineEntity);
                        commLineSettings.Parent = settings;
                        settings.CommLines.Add(commLineSettings);
                        ImportedCommLines.Add(commLineSettings);
                    }

                    foreach (TreeNode kpNode in commLineNode.Nodes)
                    {
                        if (kpNode.Checked)
                        {
                            // import device
                            noData = false;
                            KP          kpEntity   = (KP)kpNode.Tag;
                            Settings.KP kpSettings = SettingsConverter.CreateKP(kpEntity,
                                                                                project.ConfigBase.KPTypeTable);
                            kpSettings.Parent = commLineSettings;

                            if (commEnvironment.TryGetKPView(kpSettings, true, null, out KPView kpView, out string errMsg))
                            {
                                kpSettings.SetReqParams(kpView.DefaultReqParams);
                            }

                            commLineSettings.ReqSequence.Add(kpSettings);
                            ImportedDevices.Add(kpSettings);
                        }
                    }
                }
            }
        }
示例#6
0
文件: Settings.cs 项目: iyus/scada
            /// <summary>
            /// Создать полную копию КП
            /// </summary>
            public KP Clone()
            {
                KP kp = new KP();

                kp.Active  = Active;
                kp.Bind    = Bind;
                kp.Number  = Number;
                kp.Name    = Name;
                kp.Dll     = Dll;
                kp.Address = Address;
                kp.CallNum = CallNum;
                kp.Timeout = Timeout;
                kp.Delay   = Delay;
                kp.Time    = Time;
                kp.Period  = Period;
                kp.CmdLine = CmdLine;

                return(kp);
            }
示例#7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (ValidateFields() && CheckFeasibility(out Comm.Settings.CommLine commLineSettings))
            {
                // create a new device
                int commLineNum = (int)cbCommLine.SelectedValue;
                KP  kpEntity    = new KP
                {
                    KPNum       = Convert.ToInt32(numKPNum.Value),
                    Name        = txtName.Text,
                    KPTypeID    = (int)cbKPType.SelectedValue,
                    Address     = txtAddress.Text == "" ? null : (int?)int.Parse(txtAddress.Text),
                    CallNum     = txtCallNum.Text,
                    CommLineNum = commLineNum > 0 ? (int?)commLineNum : null,
                    Descr       = txtDescr.Text
                };

                // insert the device in the configuration database
                project.ConfigBase.KPTable.AddItem(kpEntity);
                project.ConfigBase.KPTable.Modified = true;

                // insert the line in the Communicator settings
                if (chkAddToComm.Checked && cbInstance.SelectedItem is Instance instance)
                {
                    if (instance.CommApp.Enabled)
                    {
                        KPSettings        = SettingsConverter.CreateKP(kpEntity, project.ConfigBase.KPTypeTable);
                        KPSettings.Parent = commLineSettings;
                        commLineSettings.ReqSequence.Add(KPSettings);
                        CommLineSettings = commLineSettings;
                    }

                    InstanceName = recentSelection.InstanceName = instance.Name;
                }

                recentSelection.CommLineNum = commLineNum;
                recentSelection.KPNum       = kpEntity.KPNum;
                recentSelection.KPTypeID    = kpEntity.KPTypeID;
                DialogResult = DialogResult.OK;
            }
        }
示例#8
0
 private static void CREATE_cube()
 {
     EditorGUILayout.BeginVertical();
     // Editor value reset button
     if (GUILayout.Button(new GUIContent("Reset Editor"), EditorStyles.miniButton))
     {
         KP.Reset_create();
     }
     EditorGUILayout.Space();
     // Editor value for width and height of the created mesh [ float ]
     KP._width  = EditorGUILayout.FloatField("Width", KP._width);
     KP._height = EditorGUILayout.FloatField("Height", KP._height);
     KP._depth  = EditorGUILayout.FloatField("Depth", KP._depth);
     EditorGUILayout.Space();
     // Editor value for width and height segments of the created mesh [ int ]
     KP._uSegments = EditorGUILayout.IntField("uSegments", KP._uSegments);
     KP._vSegments = EditorGUILayout.IntField("vSegments", KP._vSegments);
     KP._zSegments = EditorGUILayout.IntField("zSegments", KP._zSegments);
     EditorGUILayout.Space();
     EditorGUILayout.EndVertical();
 }
示例#9
0
        public async Task Verify(FileInfo kplModelFile, IEnumerable <IProperty> properties, FileInfo verificationDirectory, IModelCheckingProgressMonitor monitor)
        {
            await Task.Run(() =>
            {
                try
                {
                    monitor.Start(2, string.Format("Verifying the {0} model using the NuSMV modelchecker...", kplModelFile.Name));

                    monitor.LogProgress(0, "Generating the correspoding NuSMV model...");
                    KpModel kpModel = null;
                    try
                    {
                        kpModel = KP.FromKpl(kplModelFile.FullName);
                    }
                    catch (KplParseException kplException)
                    {
                        throw new Exception(string.Format("Failed to parse input file {0}. Reason: {1}", kplModelFile.Name, kplException.Message));
                    }

                    var experiment = new Experiment
                    {
                        LtlProperties = properties.Where(p => !(p is ICtlProperty)).Cast <ILtlProperty>().ToList(),
                        CtlProperties = properties.Where(p => p is ICtlProperty).Cast <ICtlProperty>().ToList(),
                    };

                    var verificationModelFileName = string.Format("{0}\\{1}.smv", verificationDirectory.FullName, Path.GetFileNameWithoutExtension(kplModelFile.Name));
                    TranslateSMV.Translate(kpModel, experiment, verificationModelFileName);

                    monitor.LogProgress(1, "Performing model checking...");
                    ExecuteModel(verificationDirectory, verificationModelFileName);

                    monitor.Done("Finished the verification process");
                }
                catch (Exception e)
                {
                    monitor.Terminate("Verification failed: " + e.Message);
                }
            });
        }
示例#10
0
            /// <summary>
            /// Создать полную копию настроек линии связи
            /// </summary>
            public CommLine Clone()
            {
                CommLine commLine = new CommLine();

                commLine.Active = Active;
                commLine.Bind   = Bind;
                commLine.Number = Number;
                commLine.Name   = Name;

                commLine.CommCnlType   = CommCnlType;
                commLine.CommCnlParams = new SortedList <string, string>();
                foreach (KeyValuePair <string, string> commCnlParam in CommCnlParams)
                {
                    commLine.CommCnlParams.Add(commCnlParam.Key, commCnlParam.Value);
                }

                commLine.ReqTriesCnt = ReqTriesCnt;
                commLine.CycleDelay  = CycleDelay;
                commLine.CmdEnabled  = CmdEnabled;
                commLine.ReqAfterCmd = ReqAfterCmd;
                commLine.DetailedLog = DetailedLog;

                commLine.CustomParams = new SortedList <string, string>();
                foreach (KeyValuePair <string, string> customParam in CustomParams)
                {
                    commLine.CustomParams.Add(customParam.Key, customParam.Value);
                }

                commLine.ReqSequence = new List <KP>();
                foreach (KP kp in ReqSequence)
                {
                    KP kpCopy = kp.Clone();
                    kpCopy.Parent = commLine;
                    commLine.ReqSequence.Add(kpCopy);
                }

                commLine.Parent = Parent;
                return(commLine);
            }
示例#11
0
        /// <summary>
        /// Fills the device node by channel nodes.
        /// </summary>
        private void FillDeviceNode(TreeNode deviceNode, KP kp)
        {
            try
            {
                tvCnl.BeginUpdate();
                deviceNode.Nodes.Clear();
                TableFilter tableFilter = new TableFilter("KPNum", kp.KPNum);

                if (cbCnlKind.SelectedIndex == 0)
                {
                    foreach (InCnl inCnl in baseTables.InCnlTable.SelectItems(tableFilter, true))
                    {
                        string   nodeText  = string.Format("[{0}] {1}", inCnl.CnlNum, inCnl.Name);
                        TreeNode inCnlNode = TreeViewUtils.CreateNode(nodeText, "in_cnl.png");
                        inCnlNode.Tag = inCnl;
                        deviceNode.Nodes.Add(inCnlNode);
                    }
                }
                else
                {
                    foreach (CtrlCnl ctrlCnl in baseTables.CtrlCnlTable.SelectItems(tableFilter, true))
                    {
                        string   nodeText    = string.Format("[{0}] {1}", ctrlCnl.CtrlCnlNum, ctrlCnl.Name);
                        TreeNode ctrlCnlNode = TreeViewUtils.CreateNode(nodeText, "out_cnl.png");
                        ctrlCnlNode.Tag = ctrlCnl;
                        deviceNode.Nodes.Add(ctrlCnlNode);
                    }
                }
            }
            catch (Exception ex)
            {
                ProcError(ex, TablePhrases.FillCnlTreeError);
            }
            finally
            {
                tvCnl.EndUpdate();
            }
        }
示例#12
0
        private static void CREATE_cone()
        {
            EditorGUILayout.BeginVertical();
            // Editor value reset button
            if (GUILayout.Button(new GUIContent("Reset Editor"), EditorStyles.miniButton))
            {
                KP.Reset_create();
            }
            // if openingAngle>0, create a cone with this angle by setting radiusTop to 0, and adjust radiusBottom according to length;
            EditorGUILayout.Space();
            KP._uSegments = EditorGUILayout.IntField("Segments", KP._uSegments); // numVertices
            EditorGUILayout.Space();
            KP._width  = EditorGUILayout.FloatField("Radius Top", KP._width);    //radiusTop
            KP._depth  = EditorGUILayout.FloatField("Radius Bottom", KP._depth); //radiusBottom
            KP._height = EditorGUILayout.FloatField("Height", KP._height);       //length
            EditorGUILayout.Space();
            KP.openingAngle = EditorGUILayout.FloatField("Open Angle", KP.openingAngle);
            EditorGUILayout.Space();
            KP.outside = EditorGUILayout.Toggle("Outside", KP.outside);
            KP.inside  = EditorGUILayout.Toggle("Inside", KP.inside);
            EditorGUILayout.Space();

            EditorGUILayout.EndVertical();
        }
示例#13
0
        /// <summary>
        /// Загрузить одну линию связи
        /// </summary>
        private CommLine LoadCommLine(XmlElement commLineElem)
        {
            CommLine commLine = new CommLine();
            commLine.Active = commLineElem.GetAttrAsBool("active");
            commLine.Bind = commLineElem.GetAttrAsBool("bind");
            commLine.Name = commLineElem.GetAttribute("name");
            commLine.Number = commLineElem.GetAttrAsInt("number");

            // загрузка канала связи 
            XmlElement commChannelElem = commLineElem.SelectSingleNode("CommChannel") as XmlElement;
            if (commChannelElem == null)
            {
                // поддержка обратной совместимости
                XmlElement connElem = commLineElem.SelectSingleNode("Connection") as XmlElement;
                if (connElem != null)
                {
                    XmlElement connTypeElem = connElem.SelectSingleNode("ConnType") as XmlElement;
                    XmlElement commSettElem = connElem.SelectSingleNode("ComPortSettings") as XmlElement;

                    if (connTypeElem != null && commSettElem != null &&
                        connTypeElem.GetAttribute("value").Equals("ComPort", StringComparison.OrdinalIgnoreCase))
                    {
                        commLine.CommCnlType = CommSerialLogic.CommCnlType;
                        commLine.CommCnlParams.Add("PortName", commSettElem.GetAttribute("portName"));
                        commLine.CommCnlParams.Add("BaudRate", commSettElem.GetAttribute("baudRate"));
                        commLine.CommCnlParams.Add("Parity", commSettElem.GetAttribute("parity"));
                        commLine.CommCnlParams.Add("DataBits", commSettElem.GetAttribute("dataBits"));
                        commLine.CommCnlParams.Add("StopBits", commSettElem.GetAttribute("stopBits"));
                        commLine.CommCnlParams.Add("DtrEnable", commSettElem.GetAttribute("dtrEnable"));
                        commLine.CommCnlParams.Add("RtsEnable", commSettElem.GetAttribute("rtsEnable"));
                    }
                }
            }
            else
            {
                commLine.CommCnlType = commChannelElem.GetAttribute("type");
                XmlNodeList paramNodes = commChannelElem.SelectNodes("Param");
                foreach (XmlElement paramElem in paramNodes)
                {
                    string name = paramElem.GetAttribute("name");
                    if (name != "" && !commLine.CommCnlParams.ContainsKey(name))
                        commLine.CommCnlParams.Add(name, paramElem.GetAttribute("value"));
                }
            }

            // загрузка параметров связи
            XmlElement lineParamsElem = commLineElem.SelectSingleNode("LineParams") as XmlElement;
            if (lineParamsElem != null)
            {
                XmlNodeList paramNodes = lineParamsElem.SelectNodes("Param");
                foreach (XmlElement paramElem in paramNodes)
                {
                    string name = paramElem.GetAttribute("name");
                    string nameL = name.ToLowerInvariant();
                    string val = paramElem.GetAttribute("value");

                    try
                    {
                        if (nameL == "reqtriescnt")
                            commLine.ReqTriesCnt = int.Parse(val);
                        else if (nameL == "cycledelay")
                            commLine.CycleDelay = int.Parse(val);
                        else if (nameL == "cmdenabled")
                            commLine.CmdEnabled = bool.Parse(val);
                        else if (nameL == "detailedlog")
                            commLine.DetailedLog = bool.Parse(val);
                    }
                    catch
                    {
                        throw new Exception(string.Format(CommonPhrases.IncorrectXmlParamVal, name));
                    }
                }
            }

            // загрузка пользовательских параметров линии связи
            XmlElement customParamsElem = commLineElem.SelectSingleNode("CustomParams") as XmlElement;
            if (customParamsElem == null)
                customParamsElem = commLineElem.SelectSingleNode("UserParams") as XmlElement; // обратная совместимость

            if (customParamsElem != null)
            {
                XmlNodeList paramNodes = customParamsElem.SelectNodes("Param");
                foreach (XmlElement paramElem in paramNodes)
                {
                    string name = paramElem.GetAttribute("name");
                    if (name != "" && !commLine.CustomParams.ContainsKey(name))
                        commLine.CustomParams.Add(name, paramElem.GetAttribute("value"));
                }
            }

            // загрузка последовательности опроса линии связи
            XmlElement reqSeqElem = commLineElem.SelectSingleNode("ReqSequence") as XmlElement;
            if (reqSeqElem != null)
            {
                XmlNodeList kpNodes = reqSeqElem.SelectNodes("KP");
                foreach (XmlElement kpElem in kpNodes)
                {
                    string kpNumStr = kpElem.GetAttribute("number");
                    try
                    {
                        KP kp = new KP();
                        kp.Active = kpElem.GetAttrAsBool("active");
                        kp.Bind = kpElem.GetAttrAsBool("bind");
                        kp.Number = kpElem.GetAttrAsInt("number");
                        kp.Name = kpElem.GetAttribute("name");
                        kp.Dll = kpElem.GetAttribute("dll");
                        if (!kp.Dll.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
                            kp.Dll += ".dll";
                        kp.CallNum = kpElem.GetAttribute("callNum");
                        kp.CmdLine = kpElem.GetAttribute("cmdLine");
                        commLine.ReqSequence.Add(kp);

                        string address = kpElem.GetAttribute("address");
                        if (address != "")
                            kp.Address = kpElem.GetAttrAsInt("address");

                        kp.Timeout = kpElem.GetAttrAsInt("timeout");
                        kp.Delay = kpElem.GetAttrAsInt("delay");

                        string time = kpElem.GetAttribute("time");
                        if (time != "")
                            kp.Time = kpElem.GetAttrAsDateTime("time");

                        string period = kpElem.GetAttribute("period");
                        if (period != "")
                            kp.Period = kpElem.GetAttrAsTimeSpan("period");
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(string.Format(CommPhrases.IncorrectKPSettings, kpNumStr) +
                            ":" + Environment.NewLine + ex.Message);
                    }
                }
            }

            return commLine;
        }
示例#14
0
        public async Task Verify(FileInfo kplModelFile, IEnumerable <IProperty> properties, FileInfo verificationDirectory, IModelCheckingProgressMonitor monitor)
        {
            await Task.Run(() =>
            {
                try
                {
                    monitor.Start(4, string.Format("Verifying the {0} model using the SPIN modelchecker...", kplModelFile.Name));

                    monitor.LogProgress(0, "Generating the correspoding PROMELA model...");

                    var verificationModelFileName = string.Format("{0}\\{1}.pml", verificationDirectory.FullName, Path.GetFileNameWithoutExtension(kplModelFile.Name));
                    using (var fileWriter = new FileInfo(verificationModelFileName).CreateText())
                    {
                        //Old translator

                        /*
                         * var translationParameters = PromelaTranslationParams.Default();
                         * translationParameters.PrintRuleExecution = false;
                         * translationParameters.PrintConfiguration = false;
                         * translationParameters.PrintTargetSelection = false;
                         * translationParameters.PrintLinks = false;
                         */

                        var translationParameters = VerificationModelParams.Default();

                        KpModel kpModel = null;
                        try
                        {
                            kpModel = KP.FromKpl(kplModelFile.FullName);
                        }
                        catch (KplParseException kplException)
                        {
                            throw new Exception(string.Format("Failed to parse input file {0}. Reason: {1}", kplModelFile.Name, kplException.Message));
                        }

                        var experiment = new Experiment
                        {
                            LtlProperties = properties.Where(p => p is ILtlProperty).Cast <ILtlProperty>().ToList(),
                        };

                        //Old translator
                        //KP.WritePromela(kpModel.KPsystem, experiment, translationParameters, fileWriter);

                        KP.WriteVerificationPromelaModel(kpModel, experiment, translationParameters, fileWriter);
                    }

                    monitor.LogProgress(1, "Translating the PROMELA model into its computationally equivalent verification model...");
                    GenerateModel(verificationDirectory, verificationModelFileName);

                    monitor.LogProgress(2, "Compiling the verification model...");
                    CompileModel(verificationDirectory, verificationModelFileName);

                    monitor.LogProgress(3, "Performing model checking...");
                    ExecuteModel(verificationDirectory, verificationModelFileName);

                    //monitor.LogProgress(4, "Generating the output trail file...");
                    //GenerateTrail(verificationDirectory, verificationModelFileName);

                    monitor.Done("Finished the verification process");
                }
                catch (Exception e)
                {
                    monitor.Terminate("Verification failed: " + e.Message);
                }
            });
        }
示例#15
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus setCurrentDBRootGroup___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     string uuid;
     uuid = is__.readString();
     is__.endReadEncaps();
     IceInternal.BasicStream os__ = inS__.ostr();
     bool ret__ = obj__.setCurrentDBRootGroup(uuid, current__);
     os__.writeBool(ret__);
     return Ice.DispatchStatus.DispatchOK;
 }
示例#16
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus setCurrentKFConfig___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     KeeICE.KPlib.KFConfiguration config;
     config = null;
     if(config == null)
     {
         config = new KeeICE.KPlib.KFConfiguration();
     }
     config.read__(is__);
     is__.endReadEncaps();
     IceInternal.BasicStream os__ = inS__.ostr();
     bool ret__ = obj__.setCurrentKFConfig(config, current__);
     os__.writeBool(ret__);
     return Ice.DispatchStatus.DispatchOK;
 }
示例#17
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus checkVersion___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     float keeFoxVersion;
     keeFoxVersion = is__.readFloat();
     float keeICEVersion;
     keeICEVersion = is__.readFloat();
     is__.endReadEncaps();
     int result;
     IceInternal.BasicStream os__ = inS__.ostr();
     bool ret__ = obj__.checkVersion(keeFoxVersion, keeICEVersion, out result, current__);
     os__.writeInt(result);
     os__.writeBool(ret__);
     return Ice.DispatchStatus.DispatchOK;
 }
示例#18
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus ModifyLogin___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     KeeICE.KPlib.KPEntry oldLogin;
     oldLogin = null;
     if(oldLogin == null)
     {
         oldLogin = new KeeICE.KPlib.KPEntry();
     }
     oldLogin.read__(is__);
     KeeICE.KPlib.KPEntry newLogin;
     newLogin = null;
     if(newLogin == null)
     {
         newLogin = new KeeICE.KPlib.KPEntry();
     }
     newLogin.read__(is__);
     is__.endReadEncaps();
     IceInternal.BasicStream os__ = inS__.ostr();
     try
     {
         obj__.ModifyLogin(oldLogin, newLogin, current__);
         return Ice.DispatchStatus.DispatchOK;
     }
     catch(KeeICE.KPlib.KeeICEException ex)
     {
         os__.writeUserException(ex);
         return Ice.DispatchStatus.DispatchUserException;
     }
 }
示例#19
0
        public static void DRAW_PANEL()
        {
            bool GUI_TEMP  = GUI.enabled;
            int  CART_temp = KP.MAT_CART_INDEX;
            int  FAM_temp  = KP.MAT_FAM_INDEX;
            int  TYP_temp  = KP.MAT_TYPE_INDEX;

            if (ME_LIST == null)
            {
                ME_LIST = new List <MaterialEditor>(4);
                Material       m = new Material(Shader.Find("Diffuse"));
                MaterialEditor me;
                for (int i = 0, n = 5; i < n; i++)
                {
                    me = Editor.CreateEditor(m) as MaterialEditor;

                    me.SetTexture("_mainTexture", kLibary.LoadBitmap("create", 25, 25));
                    ME_LIST.Add(me);
                }
            }
            //GUI.enabled = (_selection != null);
            // GUILayoutOption glo = {  };
            EditorGUILayout.BeginVertical(); //----------------------------------------------------------> Begin Vertical
            EditorGUI.BeginChangeCheck();
            GUILayout.Space(2);
            // Material operation and selection slots
            KP.FOLD_mSele = EditorGUILayout.Foldout(KP.FOLD_mSele, "Material Operation ");
            if (KP.FOLD_mSele)
            {
                KP.MAT_SELE_INDEX = GUILayout.Toolbar(KP.MAT_SELE_INDEX, new string[] { "Get", "Set", "2file", "2data" });
                //KP.MAT_SELE_INDEX = GUILayout.Toolbar(KP.MAT_SELE_INDEX, new string[] { "MAT I", "MAT II", "MAT III" });
                EditorGUILayout.BeginHorizontal();

                for (int i = 0, n = 4; i < n; i++)
                {
                    GUILayout.BeginVertical();
                    GUILayout.Box(new GUIContent("Slot " + i), GUILayout.ExpandWidth(true), GUILayout.Height(22));
                    // Debug.Log(ME_LIST[i]);
                    MaterialEditor med = ME_LIST[i];

                    if (med && Event.current.type == EventType.layout)
                    {
                        med.OnPreviewGUI(GUILayoutUtility.GetRect(45, 45), EditorStyles.whiteLabel);
                    }
                    GUILayout.EndVertical();
                    GUILayout.Space(2);
                }

                EditorGUILayout.EndHorizontal();
            }
            KP.FOLD_object = EditorGUILayout.Foldout(KP.FOLD_object, "Shader Family ");
            if (KP.FOLD_object)
            {
                // Material category
                KP.MAT_CART_INDEX = EditorGUILayout.Popup(KP.MAT_CART_INDEX, kShaderLab.CATEGORY);
                GUILayout.Space(2);
                // Material family
                KP.MAT_FAM_INDEX = GUILayout.SelectionGrid(KP.MAT_FAM_INDEX, kShaderLab.FAMILY, 2, KP_Style.grid(), GUILayout.MinWidth(100));
            }
            // Material type
            KP.FOLD_type = EditorGUILayout.Foldout(KP.FOLD_type, "Shader Type ");
            if (KP.FOLD_type)
            {
                //sc1 = EditorGUILayout.BeginScrollView(sc1, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MaxHeight(250), GUILayout.MinHeight(20));
                KP.MAT_TYPE_INDEX = GUILayout.SelectionGrid(KP.MAT_TYPE_INDEX, kShaderLab.GetShaderList(KP.MAT_FAM_INDEX), 1, KP_Style.grid());
                //EditorGUILayout.EndScrollView();
            }
            // Material NAME
            KP.FOLD_name = EditorGUILayout.Foldout(KP.FOLD_name, "Material Name");
            if (KP.FOLD_name)
            {
                KP._meshName = EditorGUILayout.TextField(KP._meshName, KP_Style.tf_input_center());
            }
            // Material shader properties
            KP.FOLD_para = EditorGUILayout.Foldout(KP.FOLD_para, "Material Parameters");
            if (KP.FOLD_para)
            {
                Shader s = (KP._sMaterial != null) ? kShaderLab.GetShader(KP.MAT_CART_INDEX, KP.MAT_FAM_INDEX, KP.MAT_TYPE_INDEX) : null;
                if (s != null)
                {
                    //Debug.Log(s.name);
                    //EditorGUILayout.LabelField("sName : " + s.name);
                    int n = ShaderUtil.GetPropertyCount(s);
                    for (int i = 0; i < n; i++)
                    {
                        // foreach property in current selected

                        string label        = ShaderUtil.GetPropertyDescription(s, i);
                        string propertyName = ShaderUtil.GetPropertyName(s, i);

                        //Debug.Log(ShaderUtil.GetPropertyType(s, i));
                        switch (ShaderUtil.GetPropertyType(s, i))
                        {
                        case ShaderUtil.ShaderPropertyType.Range:     // float ranges
                        {
                            //GUILayout.BeginHorizontal();
                            float v2 = ShaderUtil.GetRangeLimits(s, i, 1);
                            float v3 = ShaderUtil.GetRangeLimits(s, i, 2);

                            RangeProperty(propertyName, label, v2, v3);

                            //GUILayout.EndHorizontal();
                            break;
                        }

                        case ShaderUtil.ShaderPropertyType.Float:     // floats
                            Debug.Log(label);
                            FloatProperty(propertyName, label);
                            break;

                        case ShaderUtil.ShaderPropertyType.Color:     // colors
                        {
                            ColorProperty(propertyName, label);
                            break;
                        }

                        case ShaderUtil.ShaderPropertyType.TexEnv:     // textures
                        {
                            ShaderUtil.ShaderPropertyTexDim desiredTexdim = ShaderUtil.GetTexDim(s, i);
                            TextureProperty(propertyName, label, desiredTexdim);
                            //GUILayout.Space(6);
                            break;
                        }

                        case ShaderUtil.ShaderPropertyType.Vector:     // vectors
                        {
                            Debug.Log(label);
                            //VectorProperty(propertyName, label);
                            break;
                        }

                        default:
                        {
                            GUILayout.Label("ARGH" + label + " : " + ShaderUtil.GetPropertyType(s, i));
                            break;
                        }
                        }
                    }
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                Debug.Log("REPAINT GUI");
                if (CART_temp != KP.MAT_CART_INDEX ||
                    FAM_temp != KP.MAT_FAM_INDEX ||
                    TYP_temp != KP.MAT_TYPE_INDEX)
                {
                    if (KP.MAT_SELE_INDEX != -1)
                    {
                        KP.Reset_material();
                    }
                }
                if (KP.MAT_SELE_INDEX != -1)
                {
                    switch (KP.MAT_SELE_INDEX)
                    {
                    case 0: KP._sMaterial = kSelect.MATERIAL; break;

                    case 1: kSelect.MATERIAL = KP._sMaterial; break;

                    case 2: break;

                    case 3: break;
                    }
                    KP.MAT_SELE_INDEX = -1;
                }
                kPoly2Tool.instance.Repaint();
            }
            EditorGUILayout.EndVertical(); //------------------------------------------------------------> End Vertical
            //GUILayout.Space(10);
            //GUILayout.EndHorizontal();
            GUI.enabled = GUI_TEMP;
        }
示例#20
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus getDatabaseFileName___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     inS__.istr().skipEmptyEncaps();
     IceInternal.BasicStream os__ = inS__.ostr();
     string ret__ = obj__.getDatabaseFileName(current__);
     os__.writeString(ret__);
     return Ice.DispatchStatus.DispatchOK;
 }
示例#21
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus changeDatabase___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     string fileName;
     fileName = is__.readString();
     bool closeCurrent;
     closeCurrent = is__.readBool();
     is__.endReadEncaps();
     obj__.changeDatabase(fileName, closeCurrent, current__);
     return Ice.DispatchStatus.DispatchOK;
 }
示例#22
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus countLogins___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     string hostname;
     hostname = is__.readString();
     string actionURL;
     actionURL = is__.readString();
     string httpRealm;
     httpRealm = is__.readString();
     KeeICE.KPlib.loginSearchType lst;
     lst = (KeeICE.KPlib.loginSearchType)is__.readByte(3);
     bool requireFullURLMatches;
     requireFullURLMatches = is__.readBool();
     is__.endReadEncaps();
     IceInternal.BasicStream os__ = inS__.ostr();
     try
     {
         int ret__ = obj__.countLogins(hostname, actionURL, httpRealm, lst, requireFullURLMatches, current__);
         os__.writeInt(ret__);
         return Ice.DispatchStatus.DispatchOK;
     }
     catch(KeeICE.KPlib.KeeICEException ex)
     {
         os__.writeUserException(ex);
         return Ice.DispatchStatus.DispatchUserException;
     }
 }
示例#23
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus findLogins___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     string hostname;
     hostname = is__.readString();
     string actionURL;
     actionURL = is__.readString();
     string httpRealm;
     httpRealm = is__.readString();
     KeeICE.KPlib.loginSearchType lst;
     lst = (KeeICE.KPlib.loginSearchType)is__.readByte(3);
     bool requireFullURLMatches;
     requireFullURLMatches = is__.readBool();
     string uniqueID;
     uniqueID = is__.readString();
     is__.endReadEncaps();
     KeeICE.KPlib.KPEntry[] logins;
     IceInternal.BasicStream os__ = inS__.ostr();
     try
     {
         int ret__ = obj__.findLogins(hostname, actionURL, httpRealm, lst, requireFullURLMatches, uniqueID, out logins, current__);
         if(logins == null)
         {
             os__.writeSize(0);
         }
         else
         {
             os__.writeSize(logins.Length);
             for(int ix__ = 0; ix__ < logins.Length; ++ix__)
             {
                 (logins == null ? new KeeICE.KPlib.KPEntry() : logins[ix__]).write__(os__);
             }
         }
         os__.writeInt(ret__);
         return Ice.DispatchStatus.DispatchOK;
     }
     catch(KeeICE.KPlib.KeeICEException ex)
     {
         os__.writeUserException(ex);
         return Ice.DispatchStatus.DispatchUserException;
     }
 }
示例#24
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus getAllLogins___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     inS__.istr().skipEmptyEncaps();
     KeeICE.KPlib.KPEntry[] logins;
     IceInternal.BasicStream os__ = inS__.ostr();
     try
     {
         int ret__ = obj__.getAllLogins(out logins, current__);
         if(logins == null)
         {
             os__.writeSize(0);
         }
         else
         {
             os__.writeSize(logins.Length);
             for(int ix__ = 0; ix__ < logins.Length; ++ix__)
             {
                 (logins == null ? new KeeICE.KPlib.KPEntry() : logins[ix__]).write__(os__);
             }
         }
         os__.writeInt(ret__);
         return Ice.DispatchStatus.DispatchOK;
     }
     catch(KeeICE.KPlib.KeeICEException ex)
     {
         os__.writeUserException(ex);
         return Ice.DispatchStatus.DispatchUserException;
     }
 }
示例#25
0
文件: Settings.cs 项目: iyus/scada
        /// <summary>
        /// Загрузить линии связи
        /// </summary>
        private void LoadCommLines(XmlDocument xmlDoc, StringBuilder errorBuilder)
        {
            try
            {
                XmlNode xmlNode = xmlDoc.DocumentElement.SelectSingleNode("CommLines");
                if (xmlNode == null)
                {
                    throw new Exception(AppPhrases.NoCommLines);
                }
                else
                {
                    XmlNodeList listCommLine = xmlNode.SelectNodes("CommLine");
                    foreach (XmlElement elemCommLine in listCommLine)
                    {
                        string lineNumStr = elemCommLine.GetAttribute("number");
                        try
                        {
                            CommLine commLine = new CommLine();
                            commLine.Active = elemCommLine.GetAttrAsBool("active");
                            commLine.Bind   = elemCommLine.GetAttrAsBool("bind");
                            commLine.Name   = elemCommLine.GetAttribute("name");
                            commLine.Number = elemCommLine.GetAttrAsInt("number");
                            CommLines.Add(commLine);

                            // загрузка настроек соединения линии связи
                            XmlElement elemConn = elemCommLine.SelectSingleNode("Connection") as XmlElement;
                            if (elemConn != null)
                            {
                                XmlElement elemConnType = elemConn.SelectSingleNode("ConnType") as XmlElement;
                                if (elemConnType != null)
                                {
                                    commLine.ConnType = elemConnType.GetAttribute("value");
                                }

                                XmlElement elemCommSett = elemConn.SelectSingleNode("ComPortSettings") as XmlElement;
                                if (elemCommSett != null)
                                {
                                    try
                                    {
                                        commLine.PortName = elemCommSett.GetAttribute("portName");
                                        commLine.BaudRate = elemCommSett.GetAttrAsInt("baudRate");
                                        commLine.DataBits = elemCommSett.GetAttrAsInt("dataBits");
                                        commLine.Parity   = (Parity)Enum.Parse(typeof(Parity),
                                                                               elemCommSett.GetAttribute("parity"), true);
                                        commLine.StopBits = (StopBits)Enum.Parse(typeof(StopBits),
                                                                                 elemCommSett.GetAttribute("stopBits"), true);
                                        commLine.DtrEnable = elemCommSett.GetAttrAsBool("dtrEnable");
                                        commLine.RtsEnable = elemCommSett.GetAttrAsBool("rtsEnable");
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new Exception(AppPhrases.IncorrectPortSettings + ":\r\n" + ex.Message);
                                    }
                                }
                            }

                            // загрузка параметров линии связи
                            XmlElement elemLineParams = elemCommLine.SelectSingleNode("LineParams") as XmlElement;
                            if (elemLineParams != null)
                            {
                                XmlNodeList listParam = elemLineParams.SelectNodes("Param");
                                foreach (XmlElement elemParam in listParam)
                                {
                                    string name  = elemParam.GetAttribute("name");
                                    string nameL = name.ToLower();
                                    string val   = elemParam.GetAttribute("value");

                                    try
                                    {
                                        if (nameL == "reqtriescnt")
                                        {
                                            commLine.ReqTriesCnt = int.Parse(val);
                                        }
                                        else if (nameL == "cycledelay")
                                        {
                                            commLine.CycleDelay = int.Parse(val);
                                        }
                                        else if (nameL == "maxcommerrcnt")
                                        {
                                            commLine.MaxCommErrCnt = int.Parse(val);
                                        }
                                        else if (nameL == "cmdenabled")
                                        {
                                            commLine.CmdEnabled = bool.Parse(val);
                                        }
                                    }
                                    catch
                                    {
                                        throw new Exception(AppPhrases.IncorrectCommSettings + ":\r\n" +
                                                            string.Format(CommonPhrases.IncorrectXmlParamVal, name));
                                    }
                                }
                            }

                            // загрузка пользовательских параметров линии связи
                            XmlElement elemUserParams = elemCommLine.SelectSingleNode("UserParams") as XmlElement;
                            if (elemUserParams != null)
                            {
                                XmlNodeList listParam = elemUserParams.SelectNodes("Param");
                                foreach (XmlElement elemParam in listParam)
                                {
                                    string name = elemParam.GetAttribute("name");
                                    if (name != "")
                                    {
                                        UserParam userParam = new UserParam();
                                        userParam.Name  = name;
                                        userParam.Value = elemParam.GetAttribute("value");
                                        userParam.Descr = elemParam.GetAttribute("descr");
                                        commLine.UserParams.Add(userParam);
                                    }
                                }
                            }

                            // загрузка последовательности опроса линии связи
                            XmlElement elemReqSeq = elemCommLine.SelectSingleNode("ReqSequence") as XmlElement;
                            if (elemReqSeq != null)
                            {
                                XmlNodeList listKP = elemReqSeq.SelectNodes("KP");
                                foreach (XmlElement elemKP in listKP)
                                {
                                    string kpNumStr = elemKP.GetAttribute("number");
                                    try
                                    {
                                        KP kp = new KP();
                                        kp.Active  = elemKP.GetAttrAsBool("active");
                                        kp.Bind    = elemKP.GetAttrAsBool("bind");
                                        kp.Number  = elemKP.GetAttrAsInt("number");
                                        kp.Name    = elemKP.GetAttribute("name");
                                        kp.Dll     = elemKP.GetAttribute("dll");
                                        kp.CallNum = elemKP.GetAttribute("callNum");
                                        kp.CmdLine = elemKP.GetAttribute("cmdLine");
                                        commLine.ReqSequence.Add(kp);

                                        string address = elemKP.GetAttribute("address");
                                        if (address != "")
                                        {
                                            kp.Address = elemKP.GetAttrAsInt("address");
                                        }

                                        kp.Timeout = elemKP.GetAttrAsInt("timeout");
                                        kp.Delay   = elemKP.GetAttrAsInt("delay");

                                        string time = elemKP.GetAttribute("time");
                                        if (time != "")
                                        {
                                            kp.Time = elemKP.GetAttrAsDateTime("time");
                                        }

                                        string period = elemKP.GetAttribute("period");
                                        if (period != "")
                                        {
                                            kp.Period = elemKP.GetAttrAsTimeSpan("period");
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new Exception(string.Format(AppPhrases.IncorrectKPSettings, kpNumStr) +
                                                            ":\r\n" + ex.Message);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(string.Format(AppPhrases.IncorrectLineSettings, lineNumStr) +
                                                ":\r\n" + ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                errorBuilder.AppendLine(AppPhrases.LoadCommLinesError + ":\r\n" + ex.Message);
            }
        }
示例#26
0
文件: Settings.cs 项目: iyus/scada
            /// <summary>
            /// Создать полную копию КП
            /// </summary>
            public KP Clone()
            {
                KP kp = new KP();

                kp.Active = Active;
                kp.Bind = Bind;
                kp.Number = Number;
                kp.Name = Name;
                kp.Dll = Dll;
                kp.Address = Address;
                kp.CallNum = CallNum;
                kp.Timeout = Timeout;
                kp.Delay = Delay;
                kp.Time = Time;
                kp.Period = Period;
                kp.CmdLine = CmdLine;

                return kp;
            }
示例#27
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus addClient___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     Ice.Identity ident;
     ident = null;
     if(ident == null)
     {
         ident = new Ice.Identity();
     }
     ident.read__(is__);
     is__.endReadEncaps();
     obj__.addClient(ident, current__);
     return Ice.DispatchStatus.DispatchOK;
 }
示例#28
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus AddLogin___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     KeeICE.KPlib.KPEntry login;
     login = null;
     if(login == null)
     {
         login = new KeeICE.KPlib.KPEntry();
     }
     login.read__(is__);
     string parentUUID;
     parentUUID = is__.readString();
     is__.endReadEncaps();
     IceInternal.BasicStream os__ = inS__.ostr();
     try
     {
         KeeICE.KPlib.KPEntry ret__ = obj__.AddLogin(login, parentUUID, current__);
         if(ret__ == null)
         {
             KeeICE.KPlib.KPEntry tmp__ = new KeeICE.KPlib.KPEntry();
             tmp__.write__(os__);
         }
         else
         {
             ret__.write__(os__);
         }
         return Ice.DispatchStatus.DispatchOK;
     }
     catch(KeeICE.KPlib.KeeICEException ex)
     {
         os__.writeUserException(ex);
         return Ice.DispatchStatus.DispatchUserException;
     }
 }
示例#29
0
        private void TranslateModel(FileInfo kplFileName, FileInfo outputPathName, out FileInfo tempFolder)
        {
            KpModel kpModel = null;

            try
            {
                kpModel = KP.FromKpl(kplFileName.FullName);
            }
            catch (KplParseException kplException)
            {
                new Exception(string.Format("Failed to parse input file {0}. Reason: {1}", kplFileName, kplException.Message));
            }

            KPsystemXMLWriter kPsystemXML = new KPsystemXMLWriter(kpModel.KPsystem);

            try
            {
                Directory.CreateDirectory(outputPathName + "ite");
            }
            catch (KplParseException kplException)
            {
                new Exception(string.Format("Failed to parse create directory {0}. Reason: {1}", kplFileName, kplException.Message));
            }
            using (StreamWriter writer = new StreamWriter(outputPathName + modelGeneratedFile))
            {
                writer.Write(kPsystemXML.ToXML());
            }
            kPsystemXML.SaveCFiles(outputPathName.FullName);
            int  i = 0;
            bool b;

            do
            {
                tempFolder = new FileInfo(i == 0 ? outputPathName + "tmp" : outputPathName + "tmp" + i);
                i++;
                b = Directory.Exists(tempFolder.FullName);
            } while (b);
            try
            {
                Directory.CreateDirectory(tempFolder.FullName);
                tempFolder = new FileInfo(tempFolder + @"/");
            }
            catch (KplParseException kplException)
            {
                new Exception(string.Format("Failed to parse create directory {0}. Reason: {1}", kplFileName, kplException.Message));
            }
            using (StreamWriter writer = new StreamWriter(tempFolder + modelGeneratedFile))
            {
                writer.Write(kPsystemXML.ToXML());
            }
            kPsystemXML.SaveCFiles(tempFolder.FullName);
            using (StreamWriter writer = new StreamWriter(outputPathName + @"ite/0.xml"))
            {
                writer.Write(kPsystemXML.ToAgentsInitialConfiguration());
            }
            using (StreamWriter writer = new StreamWriter(outputPathName + @"ite/map.txt"))
            {
                writer.Write(kPsystemXML.MapObjectIds);
            }
            monitor.LogProgress(2, "KP model translated FLAME model successfully.");
        }
示例#30
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus findGroups___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     string name;
     name = is__.readString();
     string uuid;
     uuid = is__.readString();
     is__.endReadEncaps();
     KeeICE.KPlib.KPGroup[] groups;
     IceInternal.BasicStream os__ = inS__.ostr();
     int ret__ = obj__.findGroups(name, uuid, out groups, current__);
     if(groups == null)
     {
         os__.writeSize(0);
     }
     else
     {
         os__.writeSize(groups.Length);
         for(int ix__ = 0; ix__ < groups.Length; ++ix__)
         {
             (groups == null ? new KeeICE.KPlib.KPGroup() : groups[ix__]).write__(os__);
         }
     }
     os__.writeInt(ret__);
     return Ice.DispatchStatus.DispatchOK;
 }
示例#31
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus getChildEntries___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     string uuid;
     uuid = is__.readString();
     is__.endReadEncaps();
     IceInternal.BasicStream os__ = inS__.ostr();
     KeeICE.KPlib.KPEntry[] ret__ = obj__.getChildEntries(uuid, current__);
     if(ret__ == null)
     {
         os__.writeSize(0);
     }
     else
     {
         os__.writeSize(ret__.Length);
         for(int ix__ = 0; ix__ < ret__.Length; ++ix__)
         {
             (ret__ == null ? new KeeICE.KPlib.KPEntry() : ret__[ix__]).write__(os__);
         }
     }
     return Ice.DispatchStatus.DispatchOK;
 }
示例#32
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus addGroup___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     string name;
     name = is__.readString();
     string parentUuid;
     parentUuid = is__.readString();
     is__.endReadEncaps();
     IceInternal.BasicStream os__ = inS__.ostr();
     KeeICE.KPlib.KPGroup ret__ = obj__.addGroup(name, parentUuid, current__);
     if(ret__ == null)
     {
         KeeICE.KPlib.KPGroup tmp__ = new KeeICE.KPlib.KPGroup();
         tmp__.write__(os__);
     }
     else
     {
         ret__.write__(os__);
     }
     return Ice.DispatchStatus.DispatchOK;
 }
示例#33
0
        public static void DRAW_PANEL()
        {
            bool GUI_TEMP = GUI.enabled;

            EditorGUILayout.BeginVertical();
            GUILayout.Space(2);

            // OBJECT CART
            KP.MESH_CART_INDEX = EditorGUILayout.Popup(KP.MESH_CART_INDEX, KP.MESH_CART);
            // OBJECT TYPE
            KP.FOLD_object = EditorGUILayout.Foldout(KP.FOLD_object, "Object Types");
            if (KP.FOLD_object)
            {
                int objectTemp = KP.MESH_TYPE_INDEX;
                GUILayout.BeginHorizontal();
                GUILayout.Space(10);
                KP.MESH_TYPE_INDEX = GUILayout.SelectionGrid(KP.MESH_TYPE_INDEX, (KP.MESH_CART_INDEX == 0 ? KP.MESH_TYPE_a : KP.MESH_TYPE_b), 2);
                GUILayout.Space(10);
                GUILayout.EndHorizontal();

                if (objectTemp != KP.MESH_TYPE_INDEX)
                {
                    KP.Reset_create();
                }
            }
            // OBJECT NAME
            KP.FOLD_name = EditorGUILayout.Foldout(KP.FOLD_name, "Object Name");
            if (KP.FOLD_name)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(10);
                GUI.enabled  = KP.MESH_TYPE_INDEX != -1;
                KP._meshName = EditorGUILayout.TextField(KP._meshName, KP_Style.tf_input_center());
                GUI.enabled  = GUI_TEMP;
                if (GUILayout.Button("ID", GUILayout.Width(24)))
                {
                    KP._meshName = "kPoly " + UnityEngine.Random.Range(1, 99);
                }
                GUILayout.Space(10);
                GUILayout.EndHorizontal();
            }
            // OBJECT PARAMETERS
            KP.FOLD_para = EditorGUILayout.Foldout(KP.FOLD_para, "Parameters");
            if (KP.FOLD_para)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(10);
                GUI.enabled = KP.MESH_TYPE_INDEX != -1;
                if (KP.MESH_CART_INDEX == 0)
                {
                    switch (KP.MESH_TYPE_INDEX)
                    {
                    case 0:
                        CREATE_cube();
                        break;

                    case 1:
                        CREATE_plane();
                        break;

                    case 2:
                        CREATE_cone();
                        break;
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("No editabled properties.", EditorStyles.boldLabel);
                }
                GUILayout.Space(10);
                GUILayout.EndHorizontal();
            }
            // OBJECT CREATION TYPE
            KP.FOLD_create = EditorGUILayout.Foldout(KP.FOLD_create, "Creation Types");//, folderSkin());
            if (KP.FOLD_create)
            {
                // Editor Button for start mesh creation
                if (GUILayout.Button(new GUIContent("GameObject [ Scene ]")))
                {
                    MeshCreator_gameObject();
                }
                GUILayout.Button(new GUIContent("Mesh Asset [ DataBase ]"));
                GUILayout.BeginHorizontal();
                GUILayout.Button(new GUIContent("Export File [ Folder ]"));
                GUILayout.Button(new GUIContent(".."), GUILayout.Width(18));
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();
            GUI.enabled = GUI_TEMP;
        }
示例#34
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus LaunchLoginEditor___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     IceInternal.BasicStream is__ = inS__.istr();
     is__.startReadEncaps();
     string uuid;
     uuid = is__.readString();
     is__.endReadEncaps();
     obj__.LaunchLoginEditor(uuid, current__);
     return Ice.DispatchStatus.DispatchOK;
 }
示例#35
0
        /// <summary>
        /// Загрузить одну линию связи
        /// </summary>
        private CommLine LoadCommLine(XmlElement commLineElem)
        {
            CommLine commLine = new CommLine
            {
                Active = commLineElem.GetAttrAsBool("active"),
                Bind   = commLineElem.GetAttrAsBool("bind"),
                Name   = commLineElem.GetAttribute("name"),
                Number = commLineElem.GetAttrAsInt("number")
            };

            // загрузка канала связи
            XmlElement commChannelElem = commLineElem.SelectSingleNode("CommChannel") as XmlElement;

            if (commChannelElem == null)
            {
                // поддержка обратной совместимости
                XmlElement connElem = commLineElem.SelectSingleNode("Connection") as XmlElement;
                if (connElem != null)
                {
                    XmlElement connTypeElem = connElem.SelectSingleNode("ConnType") as XmlElement;
                    XmlElement commSettElem = connElem.SelectSingleNode("ComPortSettings") as XmlElement;

                    if (connTypeElem != null && commSettElem != null &&
                        connTypeElem.GetAttribute("value").Equals("ComPort", StringComparison.OrdinalIgnoreCase))
                    {
                        commLine.CommCnlType = CommSerialLogic.CommCnlType;
                        commLine.CommCnlParams.Add("PortName", commSettElem.GetAttribute("portName"));
                        commLine.CommCnlParams.Add("BaudRate", commSettElem.GetAttribute("baudRate"));
                        commLine.CommCnlParams.Add("Parity", commSettElem.GetAttribute("parity"));
                        commLine.CommCnlParams.Add("DataBits", commSettElem.GetAttribute("dataBits"));
                        commLine.CommCnlParams.Add("StopBits", commSettElem.GetAttribute("stopBits"));
                        commLine.CommCnlParams.Add("DtrEnable", commSettElem.GetAttribute("dtrEnable"));
                        commLine.CommCnlParams.Add("RtsEnable", commSettElem.GetAttribute("rtsEnable"));
                    }
                }
            }
            else
            {
                commLine.CommCnlType = commChannelElem.GetAttribute("type");
                XmlNodeList paramNodes = commChannelElem.SelectNodes("Param");
                foreach (XmlElement paramElem in paramNodes)
                {
                    string name = paramElem.GetAttribute("name");
                    if (name != "" && !commLine.CommCnlParams.ContainsKey(name))
                    {
                        commLine.CommCnlParams.Add(name, paramElem.GetAttribute("value"));
                    }
                }
            }

            // загрузка параметров связи
            XmlElement lineParamsElem = commLineElem.SelectSingleNode("LineParams") as XmlElement;

            if (lineParamsElem != null)
            {
                XmlNodeList paramNodes = lineParamsElem.SelectNodes("Param");
                foreach (XmlElement paramElem in paramNodes)
                {
                    string name  = paramElem.GetAttribute("name");
                    string nameL = name.ToLowerInvariant();
                    string val   = paramElem.GetAttribute("value");

                    try
                    {
                        if (nameL == "reqtriescnt")
                        {
                            commLine.ReqTriesCnt = int.Parse(val);
                        }
                        else if (nameL == "cycledelay")
                        {
                            commLine.CycleDelay = int.Parse(val);
                        }
                        else if (nameL == "cmdenabled")
                        {
                            commLine.CmdEnabled = bool.Parse(val);
                        }
                        else if (nameL == "reqaftercmd")
                        {
                            commLine.ReqAfterCmd = bool.Parse(val);
                        }
                        else if (nameL == "detailedlog")
                        {
                            commLine.DetailedLog = bool.Parse(val);
                        }
                    }
                    catch
                    {
                        throw new Exception(string.Format(CommonPhrases.IncorrectXmlParamVal, name));
                    }
                }
            }

            // загрузка пользовательских параметров линии связи
            XmlElement customParamsElem = commLineElem.SelectSingleNode("CustomParams") as XmlElement;

            if (customParamsElem == null)
            {
                customParamsElem = commLineElem.SelectSingleNode("UserParams") as XmlElement; // обратная совместимость
            }
            if (customParamsElem != null)
            {
                XmlNodeList paramNodes = customParamsElem.SelectNodes("Param");
                foreach (XmlElement paramElem in paramNodes)
                {
                    string name = paramElem.GetAttribute("name");
                    if (name != "" && !commLine.CustomParams.ContainsKey(name))
                    {
                        commLine.CustomParams.Add(name, paramElem.GetAttribute("value"));
                    }
                }
            }

            // загрузка последовательности опроса линии связи
            XmlElement reqSeqElem = commLineElem.SelectSingleNode("ReqSequence") as XmlElement;

            if (reqSeqElem != null)
            {
                XmlNodeList kpNodes = reqSeqElem.SelectNodes("KP");
                foreach (XmlElement kpElem in kpNodes)
                {
                    string kpNumStr = kpElem.GetAttribute("number");
                    try
                    {
                        KP kp = new KP
                        {
                            Active  = kpElem.GetAttrAsBool("active"),
                            Bind    = kpElem.GetAttrAsBool("bind"),
                            Number  = kpElem.GetAttrAsInt("number"),
                            Name    = kpElem.GetAttribute("name"),
                            Dll     = kpElem.GetAttribute("dll"),
                            Address = kpElem.GetAttrAsInt("address"),
                            CallNum = kpElem.GetAttribute("callNum"),
                            Timeout = kpElem.GetAttrAsInt("timeout"),
                            Delay   = kpElem.GetAttrAsInt("delay"),
                            Time    = kpElem.GetAttrAsDateTime("time"),
                            Period  = kpElem.GetAttrAsTimeSpan("period"),
                            CmdLine = kpElem.GetAttribute("cmdLine"),
                            Parent  = commLine
                        };

                        if (!kp.Dll.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
                        {
                            kp.Dll += ".dll";
                        }

                        commLine.ReqSequence.Add(kp);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(string.Format(CommPhrases.IncorrectKPSettings, kpNumStr) +
                                            ":" + Environment.NewLine + ex.Message);
                    }
                }
            }

            // установка родителя
            commLine.Parent = this;

            return(commLine);
        }
示例#36
0
文件: KeeICE.cs 项目: hathagat/KeeFox
 public static Ice.DispatchStatus getCurrentKFConfig___(KP obj__, IceInternal.Incoming inS__, Ice.Current current__)
 {
     checkMode__(Ice.OperationMode.Normal, current__.mode);
     inS__.istr().skipEmptyEncaps();
     IceInternal.BasicStream os__ = inS__.ostr();
     KeeICE.KPlib.KFConfiguration ret__ = obj__.getCurrentKFConfig(current__);
     if(ret__ == null)
     {
         KeeICE.KPlib.KFConfiguration tmp__ = new KeeICE.KPlib.KFConfiguration();
         tmp__.write__(os__);
     }
     else
     {
         ret__.write__(os__);
     }
     return Ice.DispatchStatus.DispatchOK;
 }
示例#37
0
文件: Settings.cs 项目: iyus/scada
        /// <summary>
        /// Загрузить линии связи
        /// </summary>
        private void LoadCommLines(XmlDocument xmlDoc, StringBuilder errorBuilder)
        {
            try
            {
                XmlNode xmlNode = xmlDoc.DocumentElement.SelectSingleNode("CommLines");
                if (xmlNode == null)
                {
                    throw new Exception(AppPhrases.NoCommLines);
                }
                else
                {
                    XmlNodeList listCommLine = xmlNode.SelectNodes("CommLine");
                    foreach (XmlElement elemCommLine in listCommLine)
                    {
                        string lineNumStr = elemCommLine.GetAttribute("number");
                        try
                        {
                            CommLine commLine = new CommLine();
                            commLine.Active = elemCommLine.GetAttrAsBool("active");
                            commLine.Bind = elemCommLine.GetAttrAsBool("bind");
                            commLine.Name = elemCommLine.GetAttribute("name");
                            commLine.Number = elemCommLine.GetAttrAsInt("number");
                            CommLines.Add(commLine);

                            // загрузка настроек соединения линии связи
                            XmlElement elemConn = elemCommLine.SelectSingleNode("Connection") as XmlElement;
                            if (elemConn != null)
                            {
                                XmlElement elemConnType = elemConn.SelectSingleNode("ConnType") as XmlElement;
                                if (elemConnType != null)
                                    commLine.ConnType = elemConnType.GetAttribute("value");

                                XmlElement elemCommSett = elemConn.SelectSingleNode("ComPortSettings") as XmlElement;
                                if (elemCommSett != null)
                                {
                                    try
                                    {
                                        commLine.PortName = elemCommSett.GetAttribute("portName");
                                        commLine.BaudRate = elemCommSett.GetAttrAsInt("baudRate");
                                        commLine.DataBits = elemCommSett.GetAttrAsInt("dataBits");
                                        commLine.Parity = (Parity)Enum.Parse(typeof(Parity),
                                            elemCommSett.GetAttribute("parity"), true);
                                        commLine.StopBits = (StopBits)Enum.Parse(typeof(StopBits),
                                            elemCommSett.GetAttribute("stopBits"), true);
                                        commLine.DtrEnable = elemCommSett.GetAttrAsBool("dtrEnable");
                                        commLine.RtsEnable = elemCommSett.GetAttrAsBool("rtsEnable");
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new Exception(AppPhrases.IncorrectPortSettings + ":\r\n" + ex.Message);
                                    }
                                }
                            }

                            // загрузка параметров линии связи
                            XmlElement elemLineParams = elemCommLine.SelectSingleNode("LineParams") as XmlElement;
                            if (elemLineParams != null)
                            {
                                XmlNodeList listParam = elemLineParams.SelectNodes("Param");
                                foreach (XmlElement elemParam in listParam)
                                {
                                    string name = elemParam.GetAttribute("name");
                                    string nameL = name.ToLower();
                                    string val = elemParam.GetAttribute("value");

                                    try
                                    {
                                        if (nameL == "reqtriescnt")
                                            commLine.ReqTriesCnt = int.Parse(val);
                                        else if (nameL == "cycledelay")
                                            commLine.CycleDelay = int.Parse(val);
                                        else if (nameL == "maxcommerrcnt")
                                            commLine.MaxCommErrCnt = int.Parse(val);
                                        else if (nameL == "cmdenabled")
                                            commLine.CmdEnabled = bool.Parse(val);
                                    }
                                    catch
                                    {
                                        throw new Exception(AppPhrases.IncorrectCommSettings + ":\r\n" +
                                            string.Format(CommonPhrases.IncorrectXmlParamVal, name));
                                    }
                                }
                            }

                            // загрузка пользовательских параметров линии связи
                            XmlElement elemUserParams = elemCommLine.SelectSingleNode("UserParams") as XmlElement;
                            if (elemUserParams != null)
                            {
                                XmlNodeList listParam = elemUserParams.SelectNodes("Param");
                                foreach (XmlElement elemParam in listParam)
                                {
                                    string name = elemParam.GetAttribute("name");
                                    if (name != "")
                                    {
                                        UserParam userParam = new UserParam();
                                        userParam.Name = name;
                                        userParam.Value = elemParam.GetAttribute("value");
                                        userParam.Descr = elemParam.GetAttribute("descr");
                                        commLine.UserParams.Add(userParam);
                                    }
                                }
                            }

                            // загрузка последовательности опроса линии связи
                            XmlElement elemReqSeq = elemCommLine.SelectSingleNode("ReqSequence") as XmlElement;
                            if (elemReqSeq != null)
                            {
                                XmlNodeList listKP = elemReqSeq.SelectNodes("KP");
                                foreach (XmlElement elemKP in listKP)
                                {
                                    string kpNumStr = elemKP.GetAttribute("number");
                                    try
                                    {
                                        KP kp = new KP();
                                        kp.Active = elemKP.GetAttrAsBool("active");
                                        kp.Bind = elemKP.GetAttrAsBool("bind");
                                        kp.Number = elemKP.GetAttrAsInt("number");
                                        kp.Name = elemKP.GetAttribute("name");
                                        kp.Dll = elemKP.GetAttribute("dll");
                                        kp.CallNum = elemKP.GetAttribute("callNum");
                                        kp.CmdLine = elemKP.GetAttribute("cmdLine");
                                        commLine.ReqSequence.Add(kp);

                                        string address = elemKP.GetAttribute("address");
                                        if (address != "")
                                            kp.Address = elemKP.GetAttrAsInt("address");

                                        kp.Timeout = elemKP.GetAttrAsInt("timeout");
                                        kp.Delay = elemKP.GetAttrAsInt("delay");

                                        string time = elemKP.GetAttribute("time");
                                        if (time != "")
                                            kp.Time = elemKP.GetAttrAsDateTime("time");

                                        string period = elemKP.GetAttribute("period");
                                        if (period != "")
                                            kp.Period = elemKP.GetAttrAsTimeSpan("period");
                                    }
                                    catch (Exception ex)
                                    {
                                        throw new Exception(string.Format(AppPhrases.IncorrectKPSettings, kpNumStr) +
                                            ":\r\n" + ex.Message);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(string.Format(AppPhrases.IncorrectLineSettings, lineNumStr) +
                                ":\r\n" + ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                errorBuilder.AppendLine(AppPhrases.LoadCommLinesError + ":\r\n" + ex.Message);
            }
        }
示例#38
0
        // возвращает список возможных атак через смежных пользователей
        public List <List <double> > get_attack(string user1, string user2)
        {
            List <List <double> > output = new List <List <double> > ();
            int _case = 0;

            /*foreach (KnowlegePattern p in SocGraphWithKP.Vertices)
             *      if (p.G.)*/

            // пользователи из одного отдела - используем сгенерированное
            // если нашли -> дальше не идем
            bool check = false;

            foreach (KnowlegePattern KP in SocGraphWithKP.Vertices)
            {
                if (KP.staff.Contains(user1) && KP.staff.Contains(user2))
                {
                    check = true;
                    output.Add(KP.get_attack(user1, user2));
                    return(output);
                }
            }

            if (!check)
            {
                KnowlegePattern START_KP  = null;
                KnowlegePattern FINISH_KP = null;
                // пользователи из разных отделов


                foreach (KnowlegePattern KP in SocGraphWithKP.Vertices)
                {
                    if (KP.staff.Contains(user1))
                    {
                        START_KP = KP;
                    }
                    else if (KP.staff.Contains(user2))
                    {
                        FINISH_KP = KP;
                    }


                    // проверка на наличие связей между отделами
                    for (int i = 0; i < START_KP.staff.Count; i++)
                    {
                        for (int j = 0; j < FINISH_KP.staff.Count; j++)
                        {
                            // 1 пользователь в 2 отделах -> просмотрим атаку через него
                            if (START_KP.staff [i] == FINISH_KP.staff [j])
                            {
                                output.Add(merge_attack_by_user(START_KP, FINISH_KP, user1, user2, START_KP.staff [i]));
                            }
                            Edge <string> e;


                            if (this.G.social_graph.TryGetEdge(START_KP.staff [i], FINISH_KP.staff [j], out e))
                            {
                                output.Add(merge_attack_by_edge(START_KP, FINISH_KP, user1, user2, e));
                            }
                        }
                    }
                }
            }
            return(output);
        }