Clone() public static method

Perform a deep Copy of the object.
public static Clone ( source ) : T,
source The object instance to copy.
return T,
コード例 #1
0
        protected void Action_Finished(Dom.Action action)
        {
            var dom = action.parent.parent.parent as Dom.Dom;

            if (action.dataModel == null)
            {
                var models = action.parameters.Select(a => a.dataModel).Where(a => a != null);
                if (!models.Any())
                {
                    return;
                }

                foreach (var model in models)
                {
                    SaveDataModel(dom, model);
                }
            }
            else
            {
                SaveDataModel(dom, action.dataModel);
            }

            if (cloneActions)
            {
                actions.Add(ObjectCopier.Clone(action));
            }
            else
            {
                actions.Add(action);
            }
        }
コード例 #2
0
ファイル: DropDownListBox.cs プロジェクト: dolani/CodeTorch
        void ctrl_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            try
            {
                if (Me.SelectedIndexChanged != null)
                {
                    ActionRunner runner = new ActionRunner();

                    Core.Action action = ObjectCopier.Clone <Core.Action>(Me.SelectedIndexChanged);

                    runner.Page   = (BasePage)this.Page;
                    runner.Action = action;

                    runner.Execute();
                }
            }
            catch (Exception ex)
            {
                string ErrorMessageFormat = "ERROR - {0} - Control {1} ({2} - {3})";
                string ErrorMessages      = String.Format(ErrorMessageFormat, ex.Message, this.ControlID, Me.Type, this.ID);

                this.ctrl.Items.Insert(0, new RadComboBoxItem(ErrorMessages, String.Empty));
                this.ctrl.BackColor = Color.Red;
            }
        }
コード例 #3
0
        public void Initialize(Models.FixedItemsList fixedItemsList, bool isForEditing)
        {
            FieldName.Content = fixedItemsList.Name;

            FixedItemsList dataStructure = DataStructure.GetAllAppFields()[fixedItemsList.Id] as FixedItemsList;

            foreach (Field dsField in dataStructure.Items)
            {
                Field field = fixedItemsList.Items.Find(x => x.Id == dsField.Id);
                if (field == null)
                {
                    field = ObjectCopier.Clone <Field>(dsField);
                    fixedItemsList.Items.Add(field);
                }
                field.SetName(dsField.Name);
                Container.Children.Add(field.GenerateUIElement(isForEditing));
            }

            if (fixedItemsList.IsConditional)
            {
                Binding b = new Binding();
                b.Source            = fixedItemsList;
                b.Path              = new PropertyPath("BoolValue");
                b.Mode              = BindingMode.TwoWay;
                BoolValue.IsChecked = fixedItemsList.BoolValue;
                BindingOperations.SetBinding(BoolValue, System.Windows.Controls.CheckBox.IsCheckedProperty, b);

                Container.Visibility = fixedItemsList.BoolValue ? Visibility.Visible : Visibility.Collapsed;
            }
            else
            {
                BoolValue.Visibility = Visibility.Collapsed;
            }
        }
コード例 #4
0
ファイル: SimonApplication.cs プロジェクト: aespielberg/RapID
        private void requestNewState()
        {
            // Select some number of the tags.
            HashSet <string> desiredTags = new HashSet <string>();

            desiredTags.Add(this.tagIds[random.Next(this.tagIds.Count)]);
            foreach (string tag in this.tagIds)
            {
                if (random.Next(2) == 0)
                {
                    desiredTags.Add(tag);
                }
            }
            // For each selected tag, ask the user to do something to the tag,
            // touch or move, but must be consistent with the current state of the tag.
            // Our new desired state will start as the last observed state and then we will make modifications.
            this.desiredState = (ObjectCopier.Clone <SimonInteractionState>(this.lastObservedState));
            string instructions = "Simon says:\n";

            foreach (string tag in desiredTags)
            {
                instructions += "\t" + this.requestNewTagAction(tag) + "\n";
            }
            Console.WriteLine(instructions + " desired state: " + this.desiredState.ToString());
        }
コード例 #5
0
        // NOTES: Need to serialize Physics data after Picture data for this to work for some strange reason.
        // Also, I think it records a little less than you would think it does (from the debugging console).

        protected virtual void CaptureObjectValues(Frame captureFrame, long captureOffset, long captureTimeStamp, long captureInterpolationTime)
        {
            if (!allCaptured)
            {
                if (amountCaptured > 300)
                {
                    allCaptured = true;
                    Debug.Log("All Object data captured!");

                    // Setting the properties of the class then serializing the container
                    testContainer.playbackFrames             = capturedFrames;
                    testContainer.playbackOffsets            = capturedOffsets;
                    testContainer.playbackTimestamps         = capturedTimeStamps;
                    testContainer.playbackInterpolationTimes = capturedInterpolationTimes;
                    HandSerializer.WriteToBinaryFile(@"C:\Users\Brian\Desktop\test.bin", testContainer);
                }

                else
                {
                    //// Copying the Frame object
                    Frame clonedFrame = ObjectCopier.Clone(captureFrame);

                    // Adding to the individual lists
                    capturedFrames.Add(clonedFrame);
                    capturedOffsets.Add(captureOffset);
                    capturedTimeStamps.Add(captureTimeStamp);
                    capturedInterpolationTimes.Add(captureInterpolationTime);

                    // Incrementing the amountCaptured value and debugging purposes
                    amountCaptured++;
                    Debug.Log("Capturing in progress: " + amountCaptured);
                }
            }
        }
        public void Add_Regions()
        {
            MySettings mySettings = new MySettings();

            mySettings.Filter.Spatial.RegionIds.Add(1);
            mySettings.Filter.Spatial.RegionIds.Add(25);
            mySettings.Filter.Spatial.RegionIds.Add(32);
            mySettings.ResultCacheNeedsRefresh = false;
            MySettings oldMySettings = ObjectCopier.Clone(mySettings);

            // No changes is made => cache is up to date
            Assert.IsFalse(mySettings.ResultCacheNeedsRefresh);

            mySettings.Filter.Spatial.RegionIds.RemoveAt(1);
            // One polygon is removed => cache needs refresh
            Assert.IsTrue(mySettings.ResultCacheNeedsRefresh);

            mySettings.Filter.Spatial.RegionIds.Add(25);
            // The removed region is added again => no changes is made => cache is up to date

            mySettings.ResultCacheNeedsRefresh = false;
            Assert.IsFalse(mySettings.Filter.Spatial.IsActive); // is active as default
            Assert.IsFalse(oldMySettings.Filter.Spatial.IsActive);
            mySettings.Filter.Spatial.IsActive = true;
            // changing IsActive => cache needs refresh.
            Assert.IsTrue(mySettings.ResultCacheNeedsRefresh);
        }
コード例 #7
0
        public async Task <OwletSignInResponse> LoginAsync(string email, string password)
        {
            var signInResponse = await this._aylaUserServiceClient.LoginAsync(email, password);

            this._owletUserSession?.SetSession(ObjectCopier.Clone(signInResponse));
            return(signInResponse);
        }
コード例 #8
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="settings"></param>
        public ConnectionSettings_UI(ConnectionSettings settings, bool setUiEnable, ApplicationSettings appSettings, Point position)
        {
            // Store the Starting Position to a local Variable
            windowStartPosistion = position;

            // Clone the Settings Object. becouse We are gone to change the Settings withe the interfacing of the users..
            userSettings        = (ConnectionSettings)ObjectCopier.Clone(settings);
            applicationSettings = (ApplicationSettings)ObjectCopier.Clone(appSettings);

            InitializeComponent();

            singleConnectionPage    = new settingsPageSingleConnection(userSettings.connection1, applicationSettings.expertModeIsActive);
            connectyInTheMiddlepage = new settingsPageConnectyInTheMiddle(userSettings, applicationSettings.expertModeIsActive);

            //Check the Current User Settings
            updateUiWithCurrentSettings();

            SettingsModeFrame.Loaded += new RoutedEventHandler(ConnectionSettingsFrameLoaded);


            if (!setUiEnable)
            {
                DisableEditFunctions();
            }
        }
        public void GridStatistics()
        {
            MySettings mySettings = new MySettings();

            mySettings.ResultCacheNeedsRefresh = false;
            MySettings oldMySettings = ObjectCopier.Clone(mySettings);

            // Is true by default
            Assert.IsTrue(mySettings.Calculation.GridStatistics.IsActive);
            mySettings.Calculation.GridStatistics.IsActive = true;
            Assert.IsTrue(mySettings.ResultCacheNeedsRefresh);
            mySettings.Calculation.GridStatistics.IsActive = false;

            mySettings.ResultCacheNeedsRefresh = false;
            mySettings.Calculation.GridStatistics.CoordinateSystemId = 2;
            Assert.IsTrue(mySettings.ResultCacheNeedsRefresh);
            mySettings.Calculation.GridStatistics.CoordinateSystemId = null;

            mySettings.ResultCacheNeedsRefresh             = false;
            mySettings.Calculation.GridStatistics.GridSize = 200;
            Assert.IsTrue(mySettings.ResultCacheNeedsRefresh);
            mySettings.Calculation.GridStatistics.GridSize = null;

            mySettings.ResultCacheNeedsRefresh = false;
            Assert.IsTrue(mySettings.Calculation.GridStatistics.CalculateNumberOfObservations);
            mySettings.Calculation.GridStatistics.CalculateNumberOfObservations = false;
            Assert.IsTrue(mySettings.ResultCacheNeedsRefresh);
            mySettings.Calculation.GridStatistics.CalculateNumberOfObservations = true;
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: BGCX261/ziliao-svn-to-git
        private static void load_commit_test(PrjManager manager)
        {
            Prj_Sheet sheet  = manager.SheetCRUD.Load_Sheet(2316);
            Prj_Sheet backup = ObjectCopier.Clone(sheet);


            Cld_FCBlock block = sheet.New_Cld_FCBlock();

            block.AlgName  = "added";
            block.Sequence = 12;

            Cld_FCInput inpt = block.New_FCInput();

            inpt.Description = "added desc";
            inpt.PinName     = "for test";

            Cld_FCOutput output = block.New_FCOutput();

            output.PinName = "for test output";


            SheetDiffer diff = manager.SheetCRUD.CompareSheet(backup, sheet);

            manager.SheetCRUD.Commit_Sheet(diff);
        }
コード例 #11
0
        /// <summary>
        /// Resolve the imports of this module. Here we'll
        /// link multiple files together. This is not part
        /// of the compiler, but part of the project system.
        /// TODO: verify this approach!
        /// </summary>
        private void ResolveImports()
        {
            this.Imports = new List <IASTNode>();
            var imports = Generator.AST.FindAll(n => n is ASTImport).ToList();

            imports.ForEach(node =>
            {
                ASTImport import = (ASTImport)node;
                var ast          = this.Project.GetAstForModule(import.Name);
                if (!import.Imports.Any())
                {
                    var copies = ast
                                 .FindAll(a => a is ASTType || a is ASTAlias || a is ASTData || a is ASTChoice)
                                 .Select(a => {
                        return(a switch
                        {
                            ASTType t => ObjectCopier.Clone(t) as IASTNode,
                            ASTAlias t => ObjectCopier.Clone(t) as IASTNode,
                            ASTData t => ObjectCopier.Clone(t) as IASTNode,
                            ASTChoice t => ObjectCopier.Clone(t) as IASTNode,
                            _ => throw new Exception("Can only serialize real AST nodes.")
                        });
                    })
                                 .ToList();
                    this.Imports.AddRange(copies);
                }
コード例 #12
0
        public ViewEditItem(DataStructure dataStructure, DataItem dataItem, string label, bool enableExport)
        {
            originalDataItem = dataItem;
            copiedDataItem   = ObjectCopier.Clone <DataItem>(dataItem);

            InitializeComponent();

            ItemName.Content        = label;
            ExportButton.Visibility = enableExport ? Visibility.Visible : Visibility.Collapsed;

            Dictionary <string, List <Field> > tabsDict = dataStructure.GetTabs(false);

            foreach (string tabName in tabsDict.Keys)
            {
                TabItem tabItem = new TabItem();
                tabItem.Header = tabName;
                tabs.Items.Add(tabItem);

                ScrollViewer scroll = new ScrollViewer();
                StackPanel   sp     = new StackPanel();
                scroll.Content = sp;
                sp.Orientation = System.Windows.Controls.Orientation.Vertical;
                foreach (Field tabField in tabsDict[tabName])
                {
                    FieldControl userControl = tabField is ExternalDataStructureList?originalDataItem.GetField(tabField.Id).GenerateUIElement(true) : copiedDataItem.GetField(tabField.Id).GenerateUIElement(true);

                    userControl.SetEditable(false);
                    allUserControls.Add(userControl);
                    sp.Children.Add(userControl);
                }

                tabItem.Content = scroll;
            }
        }
        public void Test_PresentationTableSettings()
        {
            MySettings mySettings = new MySettings();

            mySettings.ResultCacheNeedsRefresh = false;
            MySettings oldMySettings = ObjectCopier.Clone(mySettings);

            // presentation settings doesn't trigger cache refresh
            mySettings.Presentation.Table.IsActive = true;
            Assert.IsFalse(mySettings.ResultCacheNeedsRefresh);
            mySettings.Presentation.Table.SpeciesObservationTable.SelectedTableId = 1;
            Assert.IsFalse(mySettings.ResultCacheNeedsRefresh);

            mySettings.Presentation.Table.IsActive = false;
            mySettings.Presentation.Table.SpeciesObservationTable.SelectedTableId = 0;



            using (ShimsContext.Create())
            {
                base.LoginTestUserAnalyser();
                IUserContext userContext = SessionHandler.UserContext;

                List <ISpeciesObservationFieldDescription> tableFields = mySettings.Presentation.Table.SpeciesObservationTable.GetTableFields(userContext);
                Assert.IsTrue(tableFields.Count > 0);

                tableFields = mySettings.Presentation.Table.SpeciesObservationTable.GetTableFields(userContext, 1, false);
                Assert.IsTrue(tableFields.Count > 0);

                tableFields = mySettings.Presentation.Table.SpeciesObservationTable.GetTableFields(userContext, 0, true);
                Assert.IsTrue(tableFields.Count > 0);
            }
        }
コード例 #14
0
        private void ProcessCommAlarm_CIDAlarm(ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser, string commType)
        {
            CHCNetSDK.NET_DVR_CID_ALARM struCIDAlarm = new CHCNetSDK.NET_DVR_CID_ALARM();
            uint dwSize = (uint)Marshal.SizeOf(struCIDAlarm);

            struCIDAlarm = (CHCNetSDK.NET_DVR_CID_ALARM)Marshal.PtrToStructure(pAlarmInfo, typeof(CHCNetSDK.NET_DVR_CID_ALARM));

            //报警设备IP地址
            string strIP = pAlarmer.sDeviceIP;

            //报警时间:年月日时分秒
            string strTimeYear   = (struCIDAlarm.struTriggerTime.wYear).ToString();
            string strTimeMonth  = (struCIDAlarm.struTriggerTime.byMonth).ToString("d2");
            string strTimeDay    = (struCIDAlarm.struTriggerTime.byDay).ToString("d2");
            string strTimeHour   = (struCIDAlarm.struTriggerTime.byHour).ToString("d2");
            string strTimeMinute = (struCIDAlarm.struTriggerTime.byMinute).ToString("d2");
            string strTimeSecond = (struCIDAlarm.struTriggerTime.bySecond).ToString("d2");
            string strTime       = strTimeYear + "-" + strTimeMonth + "-" + strTimeDay + " " + strTimeHour + ":" + strTimeMinute + ":" + strTimeSecond;

            string stringAlarm = "报警主机CID报告,sCIDCode:" + struCIDAlarm.sCIDCode + ",sCIDDescribe:" + struCIDAlarm.sCIDDescribe
                                 + ",报告类型:" + struCIDAlarm.byReportType + ",防区号:" + struCIDAlarm.wDefenceNo + ",报警触发时间:" + strTime;

            if (NoticeAlarmEvent != null)
            {
                string ccommType    = ObjectCopier.Clone <string>(commType);
                string cstrIP       = ObjectCopier.Clone <string>(strIP);
                string cstringAlarm = ObjectCopier.Clone <string>(stringAlarm);

                NoticeAlarmEvent(ccommType, DateTime.Now.ToString(), cstrIP, cstringAlarm);
            }
        }
コード例 #15
0
        public void NewCopier()
        {
            DataModel dm = new DataModel("root");

            dm.Add(new Block("block1"));
            dm.Add(new Block("block2"));

            var t = new Hashtable();

            t["foo"] = "bar";

            var    mi   = typeof(Hashtable).GetMethod("get_Item");
            object ret1 = mi.Invoke(t, new object[] { "foo" });

            mi = typeof(Hashtable).GetMethod("set_Item");
            mi.Invoke(t, new object[] { "foo", "qux" });

            object ret2 = t["foo"];

            Assert.AreEqual("bar", ret1);
            Assert.AreEqual("qux", ret2);

            string f = (string)t["bunk"];

            Assert.AreEqual(f, null);

            var c = ObjectCopier.Clone(new SimpleClass(), null);

            Assert.NotNull(c);

            var ret = ObjectCopier.Clone(dm, null);

            Assert.NotNull(ret);
        }
コード例 #16
0
ファイル: FormConfigDatabase.cs プロジェクト: BuiUyen/uyen
        private void btnOK_Click(object sender, EventArgs e)
        {
            MyVar.mMediboxSetting.DB_SERVER       = local_txtServer.Text;
            MyVar.mMediboxSetting.DB_NAME         = local_txtDatabase.Text;
            MyVar.mMediboxSetting.DB_USERID       = local_txtUser.Text;
            MyVar.mMediboxSetting.DB_USERPASSWORD = local_txtPassword.Text;

            //Save
            try
            {
                MediboxSetting mMediboxSetting = ObjectCopier.Clone(MyVar.mMediboxSetting);

                if (!mMediboxSetting.DB_ENCRIPT)
                {
                    mMediboxSetting.DB_ENCRIPT      = true;
                    mMediboxSetting.DB_SERVER       = CryptorEngine.Encrypt(mMediboxSetting.DB_SERVER, true);
                    mMediboxSetting.DB_USERID       = CryptorEngine.Encrypt(mMediboxSetting.DB_USERID, true);
                    mMediboxSetting.DB_PORT         = CryptorEngine.Encrypt(mMediboxSetting.DB_PORT, true);
                    mMediboxSetting.DB_USERPASSWORD = CryptorEngine.Encrypt(mMediboxSetting.DB_USERPASSWORD, true);
                    mMediboxSetting.DB_NAME         = CryptorEngine.Encrypt(mMediboxSetting.DB_NAME, true);
                }

                File.WriteAllText(MyVar.SettingsFileName, JsonConvert.SerializeObject(mMediboxSetting));
            }
            catch (Exception ex)
            {
                SanitaLog.e(TAG, ex);
            }

            SoftUpdatePresenter.SetConnectionConfig(local_txtServer.Text, local_txtUser.Text, local_txtPassword.Text, local_txtDatabase.Text, MyVar.DEFAULT_PORT);

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
コード例 #17
0
        private void ExecuteAfterPopulateSection()
        {
            try
            {
                ActionRunner runner = new ActionRunner();
                Core.Action  action = null;

                if (Section is DetailsSection)
                {
                    if (DetailsSection.AfterPopulateSection != null)
                    {
                        action = ObjectCopier.Clone <Core.Action>(DetailsSection.AfterPopulateSection);
                    }
                }

                if (Section is EditSection)
                {
                    action = ObjectCopier.Clone <Core.Action>(EditSection.AfterPopulateSection);
                }

                if (action != null)
                {
                    runner.Page   = (BasePage)this.Page;
                    runner.Action = action;
                    runner.Execute();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #18
0
        public Genom Clone()
        {
            Genom clone = ObjectCopier.Clone(this);

            clone.Fitness = 0;
            return(clone);
        }
コード例 #19
0
        public EditValueViewModel(RegistryValue registryValue)
        {
            RegistryValue = ObjectCopier.Clone(registryValue);
            Name          = string.IsNullOrEmpty(registryValue.Key)
                ? (string)Application.Current.Resources["DefaultValue"]
                : registryValue.Key;

            switch (registryValue.ValueKind)
            {
            case RegistryValueKind.String:
            case RegistryValueKind.ExpandString:
                Title = (string)Application.Current.Resources["EditString"];
                break;

            case RegistryValueKind.Binary:
                Title = (string)Application.Current.Resources["EditBinary"];
                break;

            case RegistryValueKind.DWord:
                Title = (string)Application.Current.Resources["EditDWord"];
                break;

            case RegistryValueKind.MultiString:
                Title = (string)Application.Current.Resources["EditMultiString"];
                break;

            case RegistryValueKind.QWord:
                Title = (string)Application.Current.Resources["EditQWord"];
                break;
            }
        }
コード例 #20
0
ファイル: Program.cs プロジェクト: stephane-lallee/Myline
        static void trainNormal(TimeCanvas canvas, List <Sequence> trainSet, int iterations, bool bidirectional)
        {
            //canvas = new TimeCanvas(25, 7);
            //canvas.c2 = c2;

            for (int i = 0; i < iterations; i++)
            {
                foreach (Sequence s in trainSet)
                {
                    canvas.Reset();
                    foreach (double[] item in s)
                    {
                        canvas.Train(item);
                    }

                    if (bidirectional)
                    {
                        Sequence rS = ObjectCopier.Clone(s);
                        rS.Reverse();

                        canvas.Reset();
                        foreach (double[] item in rS)
                        {
                            canvas.Train(item);
                        }
                    }
                }
            }
            canvas.Save("debugNormal.csv");
        }
コード例 #21
0
        public List <ReportParameter> GetPopulatedReportParameters(BasePage page, List <ReportParameter> reportRarameters, Control Container)
        {
            string lastParameterName      = null;
            string ErrorFormat            = "Invalid {0} propery for Report Parameter {1} - {2}";
            List <ReportParameter> retVal = null;


            try
            {
                if (reportRarameters != null)
                {
                    retVal = ObjectCopier.Clone <List <ReportParameter> >(reportRarameters);
                }

                foreach (ReportParameter p in retVal)
                {
                    lastParameterName = p.Name;
                    p.Value           = Common.GetParameterInputValue(page, p, Container);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(
                          String.Format(ErrorFormat, "Value", lastParameterName, ex.Message),
                          ex);
            }

            return(retVal);
        }
コード例 #22
0
        /// <summary>
        /// Remplace une variable lié ou libre aléatoire par une variable anonyme.
        /// Echoue si l'argument séléctionné ne peut être une variable anonyme.
        /// </summary>
        /// <param name="index">Index dans l'ensemble d'action.</param>
        /// <param name="actionSet">Ensemble d'action à traiter.</param>
        /// <param name="env">Environnement à prendre en compte.</param>
        /// <returns>Le classifieur fils muté, null si la mutation échoue.</returns>
        private Classifier VarToAnonym(int index, List <Classifier> parentActionSet, PerceivedEnvironnement env)
        {
            List <Classifier> actionSet = ObjectCopier.Clone(parentActionSet);
            Dictionary <ArgType, Dictionary <string, List <int[]> > > varList = GetAllValues(ArgMode.BOUND, actionSet, index);
            Random rand = new Random();

            if (varList.Keys.Count != 0)
            {
                ArgType randArgType           = new List <ArgType>(varList.Keys)[rand.Next(varList.Keys.Count)];
                string  randArgVar            = new List <string>(varList[randArgType].Keys)[rand.Next(varList[randArgType].Keys.Count)];
                int[]   randPredicateArgIndex = varList[randArgType][randArgVar][rand.Next(varList[randArgType][randArgVar].Count)];

                if (randPredicateArgIndex[0] != -1)
                {
                    if (actionSet[index].rule.body[randPredicateArgIndex[0]].predOp.argsOptions[randPredicateArgIndex[1]].argsMode.Contains(ArgMode.ANONYMOUS))
                    {
                        string     newArg  = "_";
                        HornClause newRule = actionSet[index].rule;
                        newRule.body[randPredicateArgIndex[0]].values[randPredicateArgIndex[1]] = newArg;
                        return(new Classifier(currentTime, newRule, fo, actionSet[index]));
                    }
                }
                else
                {
                    if (actionSet[index].rule.head.predOp.argsOptions[randPredicateArgIndex[1]].argsMode.Contains(ArgMode.ANONYMOUS))
                    {
                        string     newArg  = "_";
                        HornClause newRule = actionSet[index].rule;
                        newRule.head.values[randPredicateArgIndex[1]] = newArg;
                        return(new Classifier(currentTime, newRule, fo, actionSet[index]));
                    }
                }
            }
            return(null);
        }
コード例 #23
0
        private void ProcessCommAlarm_FaceDetect(ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser, string commType)
        {
            CHCNetSDK.NET_DVR_FACE_DETECTION struFaceDetectInfo = new CHCNetSDK.NET_DVR_FACE_DETECTION();
            uint dwSize = (uint)Marshal.SizeOf(struFaceDetectInfo);

            struFaceDetectInfo = (CHCNetSDK.NET_DVR_FACE_DETECTION)Marshal.PtrToStructure(pAlarmInfo, typeof(CHCNetSDK.NET_DVR_FACE_DETECTION));

            //报警设备IP地址
            string strIP = pAlarmer.sDeviceIP;

            //报警时间:年月日时分秒
            string strTimeYear   = ((struFaceDetectInfo.dwAbsTime >> 26) + 2000).ToString();
            string strTimeMonth  = ((struFaceDetectInfo.dwAbsTime >> 22) & 15).ToString("d2");
            string strTimeDay    = ((struFaceDetectInfo.dwAbsTime >> 17) & 31).ToString("d2");
            string strTimeHour   = ((struFaceDetectInfo.dwAbsTime >> 12) & 31).ToString("d2");
            string strTimeMinute = ((struFaceDetectInfo.dwAbsTime >> 6) & 63).ToString("d2");
            string strTimeSecond = ((struFaceDetectInfo.dwAbsTime >> 0) & 63).ToString("d2");
            string strTime       = strTimeYear + "-" + strTimeMonth + "-" + strTimeDay + " " + strTimeHour + ":" + strTimeMinute + ":" + strTimeSecond;

            string stringAlarm = "人脸检测结果,前端设备:" + struFaceDetectInfo.struDevInfo.struDevIP.sIpV4 + ",报警时间:" + strTime;

            if (NoticeAlarmEvent != null)
            {
                string ccommType    = ObjectCopier.Clone <string>(commType);
                string cstrIP       = ObjectCopier.Clone <string>(strIP);
                string cstringAlarm = ObjectCopier.Clone <string>(stringAlarm);

                NoticeAlarmEvent(ccommType, DateTime.Now.ToString(), cstrIP, cstringAlarm);
            }
        }
コード例 #24
0
        public List <ScreenDataCommandParameter> GetPopulatedCommandParameters(string DataCommandName, BasePage page, Control Container, List <ScreenDataCommand> datacommands)
        {
            string ErrorFormat = "Invalid {0} propery for Data Command {1} Parameter {2} - {3}";
            List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>();

            ScreenDataCommand screenCommand = ScreenDataCommand.GetDataCommand(datacommands, DataCommandName);

            if ((screenCommand != null) && (screenCommand.Parameters != null))
            {
                parameters = ObjectCopier.Clone <List <ScreenDataCommandParameter> >(screenCommand.Parameters);

                foreach (ScreenDataCommandParameter p in parameters)
                {
                    try
                    {
                        p.Value = Common.GetParameterInputValue(page, p, Container);
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException(
                                  String.Format(ErrorFormat, "Value", DataCommandName, p.Name, ex.Message),
                                  ex);
                    }
                }
            }



            return(parameters);
        }
コード例 #25
0
        private void ProcessCommAlarm_VQD(ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser, string commType)
        {
            CHCNetSDK.NET_DVR_DIAGNOSIS_UPLOAD struVQDInfo = new CHCNetSDK.NET_DVR_DIAGNOSIS_UPLOAD();
            uint dwSize = (uint)Marshal.SizeOf(struVQDInfo);

            struVQDInfo = (CHCNetSDK.NET_DVR_DIAGNOSIS_UPLOAD)Marshal.PtrToStructure(pAlarmInfo, typeof(CHCNetSDK.NET_DVR_DIAGNOSIS_UPLOAD));

            //报警设备IP地址
            string strIP = pAlarmer.sDeviceIP;

            //开始时间
            string strCheckTime = string.Format("{0:D4}", struVQDInfo.struCheckTime.dwYear) +
                                  string.Format("{0:D2}", struVQDInfo.struCheckTime.dwMonth) +
                                  string.Format("{0:D2}", struVQDInfo.struCheckTime.dwDay) + " "
                                  + string.Format("{0:D2}", struVQDInfo.struCheckTime.dwHour) + ":"
                                  + string.Format("{0:D2}", struVQDInfo.struCheckTime.dwMinute) + ":"
                                  + string.Format("{0:D2}", struVQDInfo.struCheckTime.dwSecond);

            string stringAlarm = "视频质量诊断结果,流ID:" + struVQDInfo.sStreamID + ",监测点IP:" + struVQDInfo.sMonitorIP + ",监控点通道号:" + struVQDInfo.dwChanIndex +
                                 ",检测时间:" + strCheckTime + ",byResult:" + struVQDInfo.byResult + ",bySignalResult:" + struVQDInfo.bySignalResult + ",byBlurResult:" + struVQDInfo.byBlurResult;

            if (NoticeAlarmEvent != null)
            {
                string ccommType    = ObjectCopier.Clone <string>(commType);
                string cstrIP       = ObjectCopier.Clone <string>(strIP);
                string cstringAlarm = ObjectCopier.Clone <string>(stringAlarm);

                NoticeAlarmEvent(ccommType, DateTime.Now.ToString(), cstrIP, cstringAlarm);
            }
        }
コード例 #26
0
    /// <summary>
    /// Retrieve a list of all valid dialogue chains from an entity, given that they satisfy NPC relations, conditions, variables, and party members.
    /// </summary>
    /// <param name="entity">The entity to grab chains from.</param>
    /// <returns>A lsit of dialogue chains.</returns>
    public List <Dialogue.Conversation.Chain> GetValidChains(Entity entity)
    {
        var result = new List <Dialogue.Conversation.Chain>();

        foreach (Dialogue dialogue in entity.entityDialogues)
        {
            if (dialogue.cond.Equals(entity.cond))
            {
                foreach (Dialogue.Conversation conversation in dialogue.conversation)
                {
                    // If the entity is an NPC, then check for relation when pulling valid chains
                    if (entity is NPC)
                    {
                        var npc = entity as NPC;
                        if (conversation.relationsMin <= npc.relations && conversation.relationsMax >= npc.relations &&
                            MatchVars(conversation.vars, npc) && MatchParty(conversation.party))
                        {
                            result.AddRange(ObjectCopier.Clone(conversation.dialogueChains));
                            continue;
                        }
                    }
                    else
                    {
                        result.AddRange(ObjectCopier.Clone(conversation.dialogueChains));
                        continue;
                    }
                }
                break;
            }
        }

        return(result);
    }
コード例 #27
0
ファイル: Util.cs プロジェクト: aespielberg/RapID
    // Return n uniformly sampled samples from the given distribution.
    // InteractionStates are cloned before being returned.
    // Pseudocode taken from Probabilistic Robotics chapter 4 pg. 86
    public static ConcurrentQueue <T> lowVarianceSample <T>(ConcurrentDictionary <T, double> distribution, int n)
    {
        // Convert the dictionary into an array.
        KeyValuePair <T, double>[] keyvalues = distribution.ToArray();
        // Create the empty ConcurrentQueue to store the samples we will produce.
        ConcurrentQueue <T> samples = new ConcurrentQueue <T>();
        Random random = new Random();
        // Find a random number in the range [0, n-1] inclusive.
        double r = random.NextDouble() * 1.0 / n;
        // Initialize a counter to 0.
        int i = 0;
        // Grab the associated value at the starting index.
        double c = keyvalues[i].Value;

        // For each of the n samples we want to get:
        for (int m = 0; m < n; m++)
        {
            double u = r + (m) * (1.0 / n);
            while (u > c)
            {
                i += 1;
                c += keyvalues[i].Value;
            }
            // Add the InteractionState at index i to our samples array.
            samples.Enqueue(ObjectCopier.Clone <T>(keyvalues[i].Key));
        }
        return(samples);
    }
コード例 #28
0
        static void GenerateOsmFiles(List <Bucket> buckets, PathReconstructer reconstructor, OSMDB map, List <GPXTrack> gpxTrackList)
        {
            foreach (var b in buckets)
            {
                if (b.Paths.Any())
                {
                    var mapCopy = ObjectCopier.Clone <OSMDB>(map);
                    List <Polyline <IPointGeo> > pathList = new List <Polyline <IPointGeo> >();

                    OSMNode bucketInfo = new OSMNode(0, 0, 0);
                    OSMTag  start      = new OSMTag("start", b.Start.ToString());
                    OSMTag  end        = new OSMTag("end", b.End.ToString());
                    bucketInfo.Tags.Add(start);
                    bucketInfo.Tags.Add(end);

                    foreach (var p in b.Paths)
                    {
                        var uniquePath = p.Value.GroupBy(x => new { x.Id }).Select(x => x.First());

                        foreach (var seg in uniquePath)
                        {
                            if (seg.Id != 0)
                            {
                                var matchingWay = mapCopy.Ways[seg.Id];
                                var avgSpeed    = getAverageSpeed(p.Key, gpxTrackList);

                                if (avgSpeed != null)
                                {
                                    if (matchingWay.Tags.ContainsTag("avgSpeed"))
                                    {
                                        matchingWay.Tags["avgSpeed"].Value = avgSpeed;
                                    }
                                    else
                                    {
                                        matchingWay.Tags.Add(new OSMTag("avgSpeed", avgSpeed));
                                    }
                                }

                                if (matchingWay.Tags.ContainsTag("traffic"))
                                {
                                    matchingWay.Tags["traffic"].Value += "," + p.Key;
                                }
                                else
                                {
                                    matchingWay.Tags.Add(new OSMTag("traffic", p.Key));
                                }
                            }
                        }
                        pathList.AddRange(uniquePath);
                    }

                    //OSMDB resultMap = reconstructor.SaveToOSM(pathList);
                    //resultMap.Save("map" + b.Name + ".osm");

                    mapCopy.Nodes.Add(bucketInfo);
                    mapCopy.Save("map" + b.Name + ".osm");
                }
            }
        }
コード例 #29
0
        /// <summary>
        ///     构造方法
        /// </summary>
        /// <param name="tunnelHcEntity">回采面实体</param>
        public TunnelHcEntering(WorkingFace tunnelHcEntity)
        {
            _workingFace = ObjectCopier.Clone(tunnelHcEntity);
            Text         = Const_GM.TUNNEL_HC_CHANGE;
            InitializeComponent();

            FormDefaultPropertiesSetter.SetEnteringFormDefaultProperties(this, Const_GM.TUNNEL_HC_CHANGE);
        }
コード例 #30
0
        public Transformer Fit(FeatureVector featureVector)
        {
            var vector = ObjectCopier.Clone(featureVector);

            Shuffle(vector);
            FeatureVector[] folds        = Partition(vector);
            Transformer[]   transformers = GetTransformersAndAccuracy(folds);
            return(new CrossValidatorModel(transformers));
        }