Ejemplo n.º 1
0
        public void Connect()
        {
            EthSystemConnector connection = new EthSystemConnector(System.Net.IPAddress.Parse(this.IPAddress))
            {
                UserName = "******",
                Password = "",
            };

            this.Sensor = new DataManSystem(connection);
            this.Sensor.DefaultTimeout = 5000;
            this.Sensor.SetKeepAliveOptions(true, 3000, 1000);

            ResultTypes requestedResults = ResultTypes.ReadXml | ResultTypes.Image | ResultTypes.ImageGraphics;

            this.Collector = new ResultCollector(this.Sensor, requestedResults);
            this.Collector.ComplexResultArrived += M_DatamanResultCollector_ComplexResultArrived;

            this.Sensor.Connect();

            try
            {
                this.Sensor.SetResultTypes(requestedResults);
            }
            catch
            {
            }
        }
 /// <summary>
 /// Constructs an instance of the LocalPerformer class.
 /// </summary>
 /// <param name="msg">The invocation to be executed.</param>
 /// <param name="resultCollector">The Result Collector.</param>
 /// <param name="mbr">The target.</param>
 public LocalPerformer(IMessage msg, ResultCollector resultCollector, MarshalByRefObject mbr)
 {
     this._msg = msg;
     this._resultCollector = resultCollector;
     this._mbr = mbr;
     this._mbrUri = RemotingServices.GetObjectUri(mbr);
 }
Ejemplo n.º 3
0
        private void OperationCompleteBroadcastCallFinishedHandler(Dispatcher dispatcher, IMessage message,
                                                                   ResultCollector resultCollector)
        {
            lock (resultCollector)
            {
                foreach (DictionaryEntry entry in resultCollector.Failed)
                {
                    string    mbrUri = (string)entry.Key;
                    Exception ex     = null;
                    if (entry.Value is Exception)
                    {
                        ex = (Exception)entry.Value;
                    }
                    else
                    {
                        ex = ((IMethodReturnMessage)entry.Value).Exception;
                    }
                    MarshalByRefObject failedObject =
                        dispatcher.FindObjectByUri(mbrUri);

                    Console.WriteLine(
                        "OperationCompleteBroadcastCallFinishedHandler: Receiver {0} has failed. Error: {1}",
                        mbrUri, ex.Message);
                    // here you have failed MBR object (failedObject)
                    // and Exception (ex)
                }
            }
        }
Ejemplo n.º 4
0
    public void OnPreprocessBuild(BuildReport report)
    {
        var results = new ResultCollector();

        var api = ScriptableObject.CreateInstance <TestRunnerApi>();

        api.RegisterCallbacks(results);
        api.Execute(new ExecutionSettings
        {
            runSynchronously = true,

            filters = new[]
            {
                // CategoryNames is not obligatory, but recommend if you want to group your tests
                new Filter {
                    categoryNames = new [] { $"PlayerCategory" },
                    testMode      = TestMode.EditMode
                }
            }
        });

        // If we found ANY errors, we can fail here
        if (results.Result.FailCount > 0)
        {
            throw new BuildFailedException("Failed !");
        }
    }
Ejemplo n.º 5
0
    public void OnPreprocessBuild(BuildReport report)
    {
        var results = new ResultCollector();

        var api = ScriptableObject.CreateInstance <TestRunnerApi>();

        api.RegisterCallbacks(results);

        api.Execute(new ExecutionSettings
        {
            runSynchronously = true,
            filters          = new[]
            {
                new Filter
                {
                    groupNames = new[] { $"AsteroidValidationTests." },
                    testMode   = TestMode.EditMode
                }
            }
        });

        if (results.Failed)
        {
            results.ReportTestResults();
            throw new BuildFailedException("One or more of the asteroid validation tests did not pass");
        }

        Debug.Log($"{results.PassCount} asteroid validation tests passed ({results.SkipCount} skipped)");
    }
Ejemplo n.º 6
0
 /// <summary>
 /// Puts down a record containing a reference to the specified ResultCollected.
 /// </summary>
 /// <param name="resultCollector">ResultCollector.</param>
 public void WriteResultCollectorId(ResultCollector resultCollector)
 {
     this.BinaryWriter.Write((bool)(resultCollector != null));
     if (resultCollector != null)
     {
         this.BinaryWriter.Write((int)resultCollector.DbgResultCollectorId);
     }
 }
Ejemplo n.º 7
0
        public string Search()
        {
            var rc = new ResultCollector();

            engine.BeginSearch(fen, rc, span);
            rc.Wait();
            return(rc.BestMove);
        }
        /// <summary>
        /// Broadcasts message to all registered receivers.
        /// </summary>
        /// <param name="msg">The message to be broadcasted.</param>
        /// <returns></returns>
        public override IMessage Invoke(IMessage msg)
        {
            ResultCollector resultCollector = null;

            // broadcasting
            using (ReaderAutoLocker reader = new ReaderAutoLocker(this._dispatcher._readerWriterLock))
            {
                resultCollector = new ResultCollector(this._dispatcher, this._dispatcher._receivers.Count + 3, msg);
            }

            resultCollector.PerformBroadcasting(msg);
            return new ReturnMessage(resultCollector, null, 0, (LogicalCallContext) msg.Properties["__CallContext"], (IMethodCallMessage) msg);
        }
Ejemplo n.º 9
0
            public void Connect()
            {
                try
                {
                    //EthSystemDiscoverer.SystemInfo eth_system_info = MasterCamera as EthSystemDiscoverer.SystemInfo;
                    //EthSystemConnector conn = new EthSystemConnector(eth_system_info.IPAddress, eth_system_info.Port);
                    EthSystemConnector conn = new EthSystemConnector(IPAddress);
                    conn.UserName = User;
                    conn.Password = Password;

                    _connector = conn;

                    _system = new DataManSystem(_connector);
                    _system.DefaultTimeout = 5000;


                    #region  Subscribe to events that are signalled when the system is connected / disconnected.
                    _system.SystemConnected    += new SystemConnectedHandler(OnSystemConnected);
                    _system.SystemDisconnected += new SystemDisconnectedHandler(OnSystemDisconnected);
                    //_system.SystemWentOnline += new SystemWentOnlineHandler(OnSystemWentOnline);
                    //_system.SystemWentOffline += new SystemWentOfflineHandler(OnSystemWentOffline);
                    //_system.KeepAliveResponseMissed += new KeepAliveResponseMissedHandler(OnKeepAliveResponseMissed);
                    //_system.BinaryDataTransferProgress += new BinaryDataTransferProgressHandler(OnBinaryDataTransferProgress);
                    //_system.OffProtocolByteReceived += new OffProtocolByteReceivedHandler(OffProtocolByteReceived);
                    //_system.AutomaticResponseArrived += new AutomaticResponseArrivedHandler(AutomaticResponseArrived);
                    #endregion

                    #region Subscribe to events that are signalled when the device sends auto-responses.
                    ResultTypes requested_result_types = ResultTypes.ReadXml | ResultTypes.Image | ResultTypes.ImageGraphics;
                    //ResultTypes requested_result_types = ResultTypes.ReadXml;
                    _results = new ResultCollector(_system, requested_result_types);
                    _results.ComplexResultCompleted += Results_ComplexResultCompleted;
                    //_results.SimpleResultDropped += Results_SimpleResultDropped;
                    #endregion

                    //_system.SetKeepAliveOptions(cbEnableKeepAlive.Checked, 3000, 1000);

                    _system.Connect();

                    try
                    {
                        _system.SetResultTypes(requested_result_types);
                    }
                    catch
                    { }
                }
                catch
                {
                    CleanupConnection();
                }
            }
Ejemplo n.º 10
0
        private void InvalidateWholeCacheBroadcastCallFinishedHandler(Dispatcher dispatcher, IMessage message,
                                                                      ResultCollector resultCollector)
        {
            lock (resultCollector)
            {
                /*
                 * foreach (DictionaryEntry entry in resultCollector.Successful)
                 * {
                 *  IMethodReturnMessage iMethodReturnMessage =
                 *     (IMethodReturnMessage)entry.Value;
                 *
                 *  // here you get client responses
                 *  // including out and ref parameters
                 *  if (Log.IsDebugEnabled)
                 *  {
                 *      Log.Debug(string.Format("InvalidateWholeCacheBroadcastCallFinishedHandler: Returned object = {0}",
                 *                        iMethodReturnMessage.ReturnValue.ToString()));
                 *  }
                 * }*/

                foreach (DictionaryEntry entry in resultCollector.Failed)
                {
                    string    mbrUri = (string)entry.Key;
                    Exception ex     = null;
                    if (entry.Value is Exception)
                    {
                        ex = (Exception)entry.Value;
                    }
                    else
                    {
                        ex = ((IMethodReturnMessage)entry.Value).Exception;
                    }
                    MarshalByRefObject failedObject =
                        dispatcher.FindObjectByUri(mbrUri);

                    if (Log.IsDebugEnabled)
                    {
                        Log.Debug(
                            string.Format(
                                "InvalidateWholeCacheBroadcastCallFinishedHandler: Receiver {0} has failed. Error: {1}",
                                mbrUri, ex.Message));
                    }
                    // here you have failed MBR object (failedObject)
                    // and Exception (ex)
                }
            }
        }
Ejemplo n.º 11
0
            public void Disconnect()
            {
                try
                {
                    if (_system == null || _system.State != ConnectionState.Connected)
                    {
                        return;
                    }

                    _system.Disconnect();

                    CleanupConnection();

                    _results.ClearCachedResults();
                    _results = null;
                }
                catch { }
            }
Ejemplo n.º 12
0
        public static IEnumerable <RegistryInventory> EnumerateInstances()
        {
            LoadOptions();
            Log.LogLocation = logPath;
            Log.LogEnabled  = logEnabled;

            Log.Write("Beginning enumeration of WMI Class");

            if (!providerEnabled)
            {
                Log.Write("Provider has been disabled by provider settings in the registry. Exiting without returning any instances.");
                yield break;
            }

            if (!System.IO.File.Exists(definitionPath))
            {
                Log.Write($"Definition file could not be found at \"{definitionPath}\". Exiting without returning any instances.");
                yield break;
            }

            //Load Definition
            InventorySettings RegistryInventorySetting = InventorySettings.LoadFromFile(definitionPath);

            if (RegistryInventorySetting is null)
            {
                Log.Write($"Definition file was unable to load. Exiting without returning any instances.");
                yield break;
            }

            if (!RegistryInventorySetting.Enabled)
            {
                Log.Write($"Provider has been disabled by provider settings in the definition file. Exiting without returning any instances.");
                yield break;
            }

            // Yield Results
            foreach (RegistryInventory Result in ResultCollector.GetResultsFromRuleset(RegistryInventorySetting))
            {
                yield return(Result);
            }

            Log.Write("Sucessfully finished enumeration. Exiting.");
        }
    public void OnProcessScene(Scene scene, BuildReport report)
    {
        if (report == null)
        {
            return;
        }

        var scenePath = scene.path;

        if (!new GameplayScenesProvider().Contains(scenePath))
        {
            return;
        }

        var results = new ResultCollector();

        var api = ScriptableObject.CreateInstance <TestRunnerApi>();

        api.RegisterCallbacks(results);

        api.Execute(new ExecutionSettings
        {
            runSynchronously = true,
            filters          = new[]
            {
                new Filter
                {
                    groupNames = new[] { $"SceneValidationTests\\(\"{scenePath}\"\\)\\." },
                    testMode   = TestMode.EditMode
                }
            }
        });

        if (results.Failed)
        {
            results.ReportTestResults();
            throw new BuildFailedException("One or more of the scene validation tests did not pass");
        }

        Debug.Log($"{results.PassCount} scene validation tests passed for {scenePath} ({results.SkipCount} skipped)");
    }
Ejemplo n.º 14
0
    public void OnPreprocessBuild(BuildReport report)
    {
        Debug.Log("run prebuild editmode tests");

        var result = new ResultCollector();

        var api = ScriptableObject.CreateInstance <TestRunnerApi>();

        api.RegisterCallbacks(result);

        api.Execute(new ExecutionSettings {
            runSynchronously = true,
            filters          = new[] { new Filter {
                                           testMode = TestMode.EditMode
                                       } }
        });

        if (result.Result.FailCount > 0)
        {
            throw new BuildFailedException($"{result.Result.FailCount} tests failed");
        }

        Debug.Log($"tests passed: {result.Result.PassCount}");
    }
Ejemplo n.º 15
0
        private void btnDisconnect_Click(object sender, EventArgs e)
        {
            try
            {
                if (_system == null || _system.State != ConnectionState.Connected)
                {
                    return;
                }

                btnDisconnect.Enabled = false;

                _autoconnect = false;
                _system.Disconnect();

                CleanupConnection();

                _results.ClearCachedResults();
                _results = null;
            }
            finally
            {
                RefreshGui();
            }
        }
Ejemplo n.º 16
0
		public MetaFilterer(ReflexiveFlattener flattener, ResultCollector resultCollector, FieldHighlighter highlighter)
		{
			_flattener = flattener;
			_resultCollector = resultCollector;
			_highlighter = highlighter;
		}
Ejemplo n.º 17
0
        // run test in batch mode
        private void RunTest(String testFile, String logFile, Boolean remoteStart, String remote_hosts_string)
        {
            FileStream reader = null;

            try
            {
                if (!File.Exists(testFile))
                {
                    println("Could not open " + testFile);
                    return;
                }
                //FileServer.getFileServer().setBaseForScript(f);

                reader = new FileStream(testFile, FileMode.Open, FileAccess.Read, FileShare.Read);
                log.Info("Loading file: " + testFile);

                HashTree tree = IOService.loadTree(reader);

                // Deliberate use of deprecated ctor
                NetMeterTreeModel treeModel = new NetMeterTreeModel(new Object());// Create non-GUI version to avoid headless problems
                NetMeterTreeNode  root      = (NetMeterTreeNode)treeModel.getRoot();
                treeModel.addSubTree(tree, root);

                // Hack to resolve ModuleControllers in non GUI mode
                SearchByType <ReplaceableController> replaceableControllers = new SearchByType <ReplaceableController>();
                tree.Traverse(replaceableControllers);
                List <ReplaceableController> replaceableControllersRes = replaceableControllers.GetSearchResults();

                foreach (ReplaceableController controller in replaceableControllersRes)
                {
                    controller.resolveReplacementSubTree(root);
                }

                // Remove the disabled items
                // For GUI runs this is done in Start.java
                ConvertSubTree(tree);

                ResultCollector summer         = null;
                String          summariserName = "Summariser";//$NON-NLS-1$
                log.Info("Creating summariser <" + summariserName + ">");
                println("Creating summariser <" + summariserName + ">");
                summer = new ResultCollector(summariserName);

                if (logFile != null)
                {
                    ResultCollector logger = new ResultCollector(summer);
                    logger.setFilename(logFile);
                    tree.Add(tree.GetArray()[0], logger);
                }
                else
                {
                    // only add Summariser if it can not be shared with the ResultCollector
                    if (summer != null)
                    {
                        tree.Add(tree.GetArray()[0], summer);
                    }
                }

                LinkedList <NetMeterEngine> engines = new LinkedList <NetMeterEngine>();
                tree.Put(tree.GetArray()[0], new ListenToTest(parent, (remoteStart && remoteStop) ? engines : null));
                println("Created the tree successfully using " + testFile);
                if (!remoteStart)
                {
                    NetMeterEngine engine = new StandardEngine();
                    engine.Configure(tree);
                    Int64 now = DateTime.Now.Ticks;
                    println("Starting the test @ " + DateTime.Now.ToString() + " (" + now + ")");
                    engine.RunTest();
                    engines.AddLast(engine);
                }
                //else
                //{
                //    java.util.StringTokenizer st = new java.util.StringTokenizer(remote_hosts_string, ",");//$NON-NLS-1$
                //    List<String> failingEngines = new ArrayList<String>(st.countTokens());
                //    while (st.hasMoreElements())
                //    {
                //        String el = (String) st.nextElement();
                //        println("Configuring remote engine for " + el);
                //        log.info("Configuring remote engine for " + el);
                //        JMeterEngine eng = doRemoteInit(el.trim(), tree);
                //        if (null != eng)
                //        {
                //            engines.add(eng);
                //        }
                //        else
                //        {
                //            failingEngines.add(el);
                //            println("Failed to configure "+el);
                //        }
                //    }
                //    if (engines.isEmpty())
                //    {
                //        println("No remote engines were started.");
                //        return;
                //    }
                //    if(failingEngines.size()>0) {
                //        throw new IllegalArgumentException("The following remote engines could not be configured:"+failingEngines);
                //    }
                //    println("Starting remote engines");
                //    log.Info("Starting remote engines");
                //    long now = System.currentTimeMillis();
                //    println("Starting the test @ "+new Date(now)+" ("+now+")");
                //    foreach (NetMeterEngine engine in engines)
                //    {
                //        engine.runTest();
                //    }
                //    println("Remote engines have been started");
                //    log.Info("Remote engines have been started");
                //}
                StartUdpDdaemon(engines);
            }
            catch (Exception e)
            {
                System.Console.WriteLine("Error in NonGUIDriver " + e.Message);
                log.Error("Error in NonGUIDriver", e);
            }
            finally
            {
                reader.Close();
            }
        }
Ejemplo n.º 18
0
        public String PathCalculus(String type, String vertexA, String vertexB)
        {
            int depthA = 0;
            int depthB = 0;
            String VertexUIDA = "";
            String VertexUIDB = "";

            //Try catch block to see the depth of vertexA.
            try
            {
                SqlDataReader myReader = null;
                SqlCommand myCommand = new SqlCommand("SELECT VertexUid, Depth FROM Vertex WHERE Type = '"+type+"' AND Name = '"+vertexA+"';", this.MyConnection);
                myReader = myCommand.ExecuteReader();

                while (myReader.Read())
                {
                   int.TryParse(myReader["Depth"].ToString(), out depthA);

               //VertexUid string.

                    VertexUIDA = myReader["VertexUid"].ToString();
                    break;
                }

                myCommand = null;
                myReader.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Errore su Vertex A: "+e.ToString());
            }

            try
            {
                SqlDataReader myReader = null;
                SqlCommand myCommand = new SqlCommand("SELECT VertexUid, Depth FROM Vertex WHERE Type = '" + type + "' AND Name = '" + vertexB + "';", this.MyConnection);
                myReader = myCommand.ExecuteReader();

                while (myReader.Read())
                {
                    int.TryParse(myReader["Depth"].ToString(), out depthB);

                    VertexUIDB = myReader["VertexUid"].ToString();
                    break;
                }

                myCommand = null;
                myReader.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Errore su Vertex B: "+e.ToString());
            }

            // Initialize vertex UID assigning the summit that is deeper.
            String VertexUID = "";
            String VertexName = "";

            if (depthA > depthB)
            {
                VertexUID = VertexUIDA;
                VertexName = vertexA;
            }
            else
            {
                VertexUID = VertexUIDB;
                VertexName = vertexB;
            }

            String EdgeUID = getEdgeUIDFromVertex(VertexUID);
            // Account attributes to initialize ResultCollector.
            int AttributeNumber = getAttributeSize(VertexUID) + getAttributeSize(EdgeUID);

            ResultCollector result = new ResultCollector(AttributeNumber+1);

            //Adding first vertex to VertexNameList.
            result.addVertexName(VertexName);

            // Count all attributes.
            int depthDiff = Math.Abs(depthA - depthB);

            for (int i = 0; i < depthDiff; ++i)
            {

                String AttrName = "";
                int AttrValue = 0;

                try
                {
                    SqlDataReader myReader = null;
                    SqlCommand myCommand = new SqlCommand("SELECT AD.AttrDefUid, AD.Name, AU.AttrValue FROM AttrDef AD, AttrUsage AU WHERE AU.ObjectUid = '" + VertexUID + "' AND AU.AttrDefUid = AD.AttrDefUid; ", this.MyConnection);
                    myReader = myCommand.ExecuteReader();

                    while (myReader.Read())
                    {
                        int.TryParse(myReader["AttrValue"].ToString(), out AttrValue);

                        AttrName = myReader["Name"].ToString();

                        if (i == 0)
                        {
                            result.addNewAttribute(AttrName, AttrValue);
                        }
                        else
                        {
                            result.addAttribute(AttrName, AttrValue);

                        }
                    }

                    myReader.Close();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }

                EdgeUID = getEdgeUIDFromVertex(VertexUID);

                    try
                    {
                        SqlDataReader myReader = null;
                        SqlCommand myCommand = new SqlCommand("SELECT AD.AttrDefUid, AD.Name, AU.AttrValue FROM AttrDef AD, AttrUsage AU WHERE AU.ObjectUid = '" + EdgeUID + "' AND AU.AttrDefUid = AD.AttrDefUid; ", this.MyConnection);
                        myReader = myCommand.ExecuteReader();

                        while (myReader.Read())
                        {
                            int.TryParse(myReader["AttrValue"].ToString(), out AttrValue);

                            AttrName = myReader["Name"].ToString();

                        if (i == 0)
                        {
                            result.addNewAttribute(AttrName, AttrValue);
                        }
                        else result.addAttribute(AttrName, AttrValue);
                        }

                        myReader.Close();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                    }

                VertexUID = getVertexUIDFromEdge(EdgeUID);
                VertexName = getVertexName(VertexUID);
                result.addVertexName(VertexName);
            }

            return result.toString();
        }
Ejemplo n.º 19
0
        private void Initialize()
        {
            IPAddress ipaddress = null;
            if (IPAddress.TryParse(IP, out ipaddress))
                _conn = new EthSystemConnector(ipaddress, Port);
            else
            {
                _conn = new EthSystemConnector(IPAddress.Parse("0.0.0.0"), Port);
                Logging(LogLevel.Error, String.Format("Device|{0}|{1}:{2}|IP address invalid cannot initialize device", DeviceType, IP, Port));
            }

            _system = new DataManSystem(_conn);
            _resultCollector = new ResultCollector(_system, _resultTypes);
            _resultCollector.ComplexResultArrived += onDataArrived;
            _system.SetKeepAliveOptions(true, 3000, 1000);
            _system.DefaultTimeout = 1000;
            _system.SetResultTypes(_resultTypes);
            _system.SystemConnected += new SystemConnectedHandler(OnSystemConnected);
            _system.SystemDisconnected += new SystemDisconnectedHandler(OnSystemDisconnected);
        }
 /// <summary>
 /// Sends the message via specific broadcast transport.
 /// </summary>
 /// <param name="message">The message being sent.</param>
 /// <param name="resultCollector">The Result Ñollector to gather results of the invocation.</param>
 public abstract void SendMessage(Message message, ResultCollector resultCollector);
Ejemplo n.º 21
0
 /// <summary>
 /// Sends a broadcast message thru IP multicasting.
 /// </summary>
 /// <param name="message">The message being sent.</param>
 /// <param name="resultCollector">The result collector that gathers results of the invocation.</param>
 public override void SendMessage(Message message, ResultCollector resultCollector)
 {
     message.Recipient = this.ITransportContext.KnownHosts["_gbudp://" + this.Court];
     message.DestinationMarshalByRef = this.Court;
     this.ITransportContext.ConnectionManager.Send(message);
 }
Ejemplo n.º 22
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (listBoxDetectedSystems.SelectedIndex == -1 || listBoxDetectedSystems.SelectedIndex >= listBoxDetectedSystems.Items.Count)
            {
                return;
            }

            btnConnect.Enabled = false;
            _autoconnect       = false;

            try
            {
                var system_info = listBoxDetectedSystems.Items[listBoxDetectedSystems.SelectedIndex];

                if (system_info is EthSystemDiscoverer.SystemInfo)
                {
                    EthSystemDiscoverer.SystemInfo eth_system_info = system_info as EthSystemDiscoverer.SystemInfo;
                    EthSystemConnector             conn            = new EthSystemConnector(eth_system_info.IPAddress, eth_system_info.Port)
                    {
                        UserName = "******",
                        Password = txtPassword.Text
                    };

                    _connector = conn;
                }
                else if (system_info is SerSystemDiscoverer.SystemInfo)
                {
                    SerSystemDiscoverer.SystemInfo ser_system_info = system_info as SerSystemDiscoverer.SystemInfo;
                    SerSystemConnector             conn            = new SerSystemConnector(ser_system_info.PortName, ser_system_info.Baudrate);

                    _connector = conn;
                }

                _logger.Enabled   = cbLoggingEnabled.Checked;
                _connector.Logger = _logger;

                _system = new DataManSystem(_connector)
                {
                    DefaultTimeout = 5000
                };

                // Subscribe to events that are signalled when the system is connected / disconnected.
                _system.SystemConnected            += new SystemConnectedHandler(OnSystemConnected);
                _system.SystemDisconnected         += new SystemDisconnectedHandler(OnSystemDisconnected);
                _system.SystemWentOnline           += new SystemWentOnlineHandler(OnSystemWentOnline);
                _system.SystemWentOffline          += new SystemWentOfflineHandler(OnSystemWentOffline);
                _system.KeepAliveResponseMissed    += new KeepAliveResponseMissedHandler(OnKeepAliveResponseMissed);
                _system.BinaryDataTransferProgress += new BinaryDataTransferProgressHandler(OnBinaryDataTransferProgress);
                _system.OffProtocolByteReceived    += new OffProtocolByteReceivedHandler(OffProtocolByteReceived);
                _system.AutomaticResponseArrived   += new AutomaticResponseArrivedHandler(AutomaticResponseArrived);

                // Subscribe to events that are signalled when the device sends auto-responses.
                ResultTypes requested_result_types = ResultTypes.ReadXml | ResultTypes.Image | ResultTypes.ImageGraphics;
                _results = new ResultCollector(_system, requested_result_types);
                _results.ComplexResultCompleted += Results_ComplexResultCompleted;
                _results.SimpleResultDropped    += Results_SimpleResultDropped;

                _system.SetKeepAliveOptions(cbEnableKeepAlive.Checked, 3000, 1000);

                _system.Connect(1000);

                try
                {
                    _system.SetResultTypes(requested_result_types);
                }
                catch
                { }
            }
            catch (Exception ex)
            {
                CleanupConnection();

                AddListItem("Failed to connect: " + ex.ToString());
            }

            _autoconnect = true;
            RefreshGui();
        }
 /// <summary>
 /// Sends a broadcast message thru IP multicasting.
 /// </summary>
 /// <param name="message">The message being sent.</param>
 /// <param name="resultCollector">The result collector that gathers results of the invocation.</param>
 public override void SendMessage(Message message, ResultCollector resultCollector)
 {
     message.Recipient = this.ITransportContext.KnownHosts["_gbudp://" + this.Court];
     message.DestinationMarshalByRef = this.Court;
     this.ITransportContext.ConnectionManager.Send(message);
 }
 /// <summary>
 /// Puts down a record containing a reference to the specified ResultCollected.
 /// </summary>
 /// <param name="resultCollector">ResultCollector.</param>
 public void WriteResultCollectorId(ResultCollector resultCollector)
 {
     this.BinaryWriter.Write( (bool) (resultCollector != null) );
     if (resultCollector != null)
         this.BinaryWriter.Write( (int) resultCollector.DbgResultCollectorId);
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Does absolutely nothing. If you want to enable async calls and do not need to process call results, use this stub as an event receiver.
 /// </summary>
 /// <param name="dispatcher">Ignored.</param>
 /// <param name="message">Ignored.</param>
 /// <param name="resultCollector">Ignored.</param>
 public void AsyncEventStub(Dispatcher dispatcher, IMessage message, ResultCollector resultCollector)
 {
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Returns the filtered array of the ReceiverInfo instances.
        /// </summary>
        /// <param name="arrayOfReceiverInfo">The list of receivers being filtered out.</param>
        /// <param name="iMessage">The invocation.</param>
        /// <param name="resultCollector">The Result Collector obtaining the list of receivers. Is used for debugging purposes only.</param>
        public void GetListOfReceivers(out object[] arrayOfReceiverInfo, IMessage iMessage, ResultCollector resultCollector)
        {
            arrayOfReceiverInfo = null;

            try
            {
                using (ReaderAutoLocker reader = new ReaderAutoLocker(this._readerWriterLock))
                {
                    // check whether they were cached
                    if (this._cachedReceiversInfoArray == null)
                    {
                        this._cachedReceiversInfoArray = new object[this._receivers.Values.Count];
                        this._receivers.Values.CopyTo(this._cachedReceiversInfoArray, 0);
                    }

                    // get the cached array
                    arrayOfReceiverInfo = this._cachedReceiversInfoArray;

                    // and drive it thru the filter
                    IMulticastFilter iMulticastFilter = Dispatcher.GetCurrentFilter();
                    if (iMulticastFilter == null)
                        iMulticastFilter = this.IMulticastFilter;
                    if (iMulticastFilter != null)
                    {
                        // LOG:
                        BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter;
                        if ( binaryLogWriter != null && binaryLogWriter[LogCategory.BroadcastEngine] > 0 )
                        {
                            binaryLogWriter.WriteBroadcastEngineEvent(LogCategory.BroadcastEngine, "Dispatcher.GetListOfReceivers",
                                LogMessageType.BroadcastFilterCalled, null, null, null, null,
                                GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name,
                                null, null, false, this, resultCollector, false, null,
                                iMulticastFilter.GetType().ToString(), null,
                                "The broadcast filter is called. The type of the filter: {0}.", iMulticastFilter.GetType().ToString());
                        }

                        arrayOfReceiverInfo = iMulticastFilter.GetReceivers(arrayOfReceiverInfo, iMessage);
                    }
                }
            }
            catch(Exception ex)
            {
                // LOG:
                BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter;
                if ( binaryLogWriter != null && binaryLogWriter[LogCategory.BroadcastEngine] > 0 )
                {
                    binaryLogWriter.WriteBroadcastEngineEvent(LogCategory.BroadcastEngine, "Dispatcher.GetListOfReceivers",
                        LogMessageType.BroadcastFilterCalled, ex, null, null, null,
                        GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name,
                        null, null, false, this, resultCollector, false, null,
                        null, null,
                        "The exception occurred while calling the broadcast filter.");
                }
            }
        }
Ejemplo n.º 27
0
 public abstract void Run(ResultCollector collector);
Ejemplo n.º 28
0
 /// <summary>
 /// Called by broadcast dispatcher when all calls are performed.
 /// Does not undertake any actions.
 /// </summary>
 /// <param name="dispatcher">Source dipatcher.</param>
 /// <param name="message">Source message.</param>
 /// <param name="resultCollector">Call results.</param>
 public void BroadcastCallFinishedHandler(Dispatcher dispatcher, IMessage message, ResultCollector resultCollector)
 {
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Called by the dispatcher when all calls are performed.
 /// Does nothing.
 /// </summary>
 /// <param name="dispatcher">Source dipatcher.</param>
 /// <param name="message">Source message.</param>
 /// <param name="resultCollector">Call results.</param>
 public void BroadcastCallFinishedHandler(Dispatcher dispatcher, IMessage message, ResultCollector resultCollector)
 {
 }
        /// <summary>
        /// Puts down a record describing a general Genuine Channels event.
        /// </summary>
        /// <param name="logCategory">The category of the event.</param>
        /// <param name="author">The author.</param>
        /// <param name="type">The type of the event(Subcategory).</param>
        /// <param name="exception">The exception associated with the event.</param>
        /// <param name="message">The message associated with the event.</param>
        /// <param name="remote">The remote host participating in the event.</param>
        /// <param name="content">The content associated with the record.</param>
        /// <param name="sourceThreadId">The id of the thread where the invocation was made.</param>
        /// <param name="sourceThreadName">The name of the thread.</param>
        /// <param name="securitySession">The Security Session.</param>
        /// <param name="securitySessionName">The name of the Security Session</param>
        /// <param name="writeDispatcherSettings">A value indicating whether it is necessary to put down broadcast dispatcher's settings.</param>
        /// <param name="dispatcher">The broadcast dispatcher.</param>
        /// <param name="resultCollector">The broadcast result collector.</param>
        /// <param name="writeReceiverInfoSettings">A value indicating whether it is necessary to put down information about the specified broadcast recipient.</param>
        /// <param name="receiverInfo">The broadcast recipient.</param>
        /// <param name="string1">The first string that elaborates the current event.</param>
        /// <param name="string2">The second string that elaborates the current event.</param>
        /// <param name="description">The description of the event.</param>
        /// <param name="parameters">Parameters to the description.</param>
        public void WriteBroadcastEngineEvent(LogCategory logCategory, string author, LogMessageType type, Exception exception, 
            Message message, HostInformation remote, Stream content, int sourceThreadId, string sourceThreadName,
            SecuritySession securitySession, string securitySessionName,
            bool writeDispatcherSettings, Dispatcher dispatcher, ResultCollector resultCollector, bool writeReceiverInfoSettings,
            ReceiverInfo receiverInfo, string string1, string string2, string description, params object[] parameters)
        {
            if (dispatcher == null)
            {
                this.WriteImplementationWarningEvent("BinaryLogWriter.WriteBroadcastEngineEvent", LogMessageType.Error, null,
                    sourceThreadId, sourceThreadName, "The reference is null. Stack trace: " + Environment.StackTrace);
                return ;
            }

            lock (this._streamLock)
            {
                this.WriteRecordHeader(BinaryRecordVersion.TransportBroadcastEngineRecord, logCategory, type, author);
                this.WriteException( exception );

                this.WriteMessageSeqNo( message );
                this.WriteHostInformationId( remote );
                this.WriteBinaryContent( content );

                this.BinaryWriter.Write( (int) sourceThreadId);
                this.WriteString( sourceThreadName );

                this.WriteSecuritySessionId( securitySession );
                this.WriteString( securitySessionName );

                this.WriteResultCollectorId(resultCollector);
                this.WriteDispatcherSettings(writeDispatcherSettings, dispatcher);
                this.WriteReceiverInfo(writeReceiverInfoSettings, receiverInfo);

                this.WriteString( string1 );
                this.WriteString( string2 );
                this.WriteStringWithParameters( description, parameters);

                this.BinaryWriter.Flush();
            }
        }
Ejemplo n.º 31
0
 public MetaFilterer(TagBlockFlattener flattener, ResultCollector resultCollector, FieldHighlighter highlighter)
 {
     _flattener       = flattener;
     _resultCollector = resultCollector;
     _highlighter     = highlighter;
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Puts down a record describing a general Genuine Channels event.
        /// </summary>
        /// <param name="logCategory">The category of the event.</param>
        /// <param name="author">The author.</param>
        /// <param name="type">The type of the event(Subcategory).</param>
        /// <param name="exception">The exception associated with the event.</param>
        /// <param name="message">The message associated with the event.</param>
        /// <param name="remote">The remote host participating in the event.</param>
        /// <param name="content">The content associated with the record.</param>
        /// <param name="sourceThreadId">The id of the thread where the invocation was made.</param>
        /// <param name="sourceThreadName">The name of the thread.</param>
        /// <param name="securitySession">The Security Session.</param>
        /// <param name="securitySessionName">The name of the Security Session</param>
        /// <param name="writeDispatcherSettings">A value indicating whether it is necessary to put down broadcast dispatcher's settings.</param>
        /// <param name="dispatcher">The broadcast dispatcher.</param>
        /// <param name="resultCollector">The broadcast result collector.</param>
        /// <param name="writeReceiverInfoSettings">A value indicating whether it is necessary to put down information about the specified broadcast recipient.</param>
        /// <param name="receiverInfo">The broadcast recipient.</param>
        /// <param name="string1">The first string that elaborates the current event.</param>
        /// <param name="string2">The second string that elaborates the current event.</param>
        /// <param name="description">The description of the event.</param>
        /// <param name="parameters">Parameters to the description.</param>
        public void WriteBroadcastEngineEvent(LogCategory logCategory, string author, LogMessageType type, Exception exception,
                                              Message message, HostInformation remote, Stream content, int sourceThreadId, string sourceThreadName,
                                              SecuritySession securitySession, string securitySessionName,
                                              bool writeDispatcherSettings, Dispatcher dispatcher, ResultCollector resultCollector, bool writeReceiverInfoSettings,
                                              ReceiverInfo receiverInfo, string string1, string string2, string description, params object[] parameters)
        {
            if (dispatcher == null)
            {
                this.WriteImplementationWarningEvent("BinaryLogWriter.WriteBroadcastEngineEvent", LogMessageType.Error, null,
                                                     sourceThreadId, sourceThreadName, "The reference is null. Stack trace: " + Environment.StackTrace);
                return;
            }

            lock (this._streamLock)
            {
                this.WriteRecordHeader(BinaryRecordVersion.TransportBroadcastEngineRecord, logCategory, type, author);
                this.WriteException(exception);

                this.WriteMessageSeqNo(message);
                this.WriteHostInformationId(remote);
                this.WriteBinaryContent(content);

                this.BinaryWriter.Write((int)sourceThreadId);
                this.WriteString(sourceThreadName);

                this.WriteSecuritySessionId(securitySession);
                this.WriteString(securitySessionName);

                this.WriteResultCollectorId(resultCollector);
                this.WriteDispatcherSettings(writeDispatcherSettings, dispatcher);
                this.WriteReceiverInfo(writeReceiverInfoSettings, receiverInfo);

                this.WriteString(string1);
                this.WriteString(string2);
                this.WriteStringWithParameters(description, parameters);

                this.BinaryWriter.Flush();
            }
        }
Ejemplo n.º 33
0
        private void OperationCompleteBroadcastCallFinishedHandler(Dispatcher dispatcher, IMessage message,
                                                                   ResultCollector resultCollector)
        {
            lock (resultCollector)
            {
                foreach (DictionaryEntry entry in resultCollector.Failed)
                {
                    string mbrUri = (string)entry.Key;
                    Exception ex = null;
                    if (entry.Value is Exception)
                    {
                        ex = (Exception)entry.Value;
                    }
                    else
                    {
                        ex = ((IMethodReturnMessage)entry.Value).Exception;
                    }
                    MarshalByRefObject failedObject =
                        dispatcher.FindObjectByUri(mbrUri);

                    Console.WriteLine(
                        "OperationCompleteBroadcastCallFinishedHandler: Receiver {0} has failed. Error: {1}",
                        mbrUri, ex.Message);
                    // here you have failed MBR object (failedObject)
                    // and Exception (ex)
                }
            }
        }
Ejemplo n.º 34
0
        public String PathCalculus(String type, String vertexA, String vertexB)
        {
            int    depthA     = 0;
            int    depthB     = 0;
            String VertexUIDA = "";
            String VertexUIDB = "";


            //Try catch block to see the depth of vertexA.
            try
            {
                SqlDataReader myReader  = null;
                SqlCommand    myCommand = new SqlCommand("SELECT VertexUid, Depth FROM Vertex WHERE Type = '" + type + "' AND Name = '" + vertexA + "';", this.MyConnection);
                myReader = myCommand.ExecuteReader();

                while (myReader.Read())
                {
                    int.TryParse(myReader["Depth"].ToString(), out depthA);

                    //VertexUid string.

                    VertexUIDA = myReader["VertexUid"].ToString();
                    break;
                }

                myCommand = null;
                myReader.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Errore su Vertex A: " + e.ToString());
            }

            try
            {
                SqlDataReader myReader  = null;
                SqlCommand    myCommand = new SqlCommand("SELECT VertexUid, Depth FROM Vertex WHERE Type = '" + type + "' AND Name = '" + vertexB + "';", this.MyConnection);
                myReader = myCommand.ExecuteReader();

                while (myReader.Read())
                {
                    int.TryParse(myReader["Depth"].ToString(), out depthB);


                    VertexUIDB = myReader["VertexUid"].ToString();
                    break;
                }

                myCommand = null;
                myReader.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Errore su Vertex B: " + e.ToString());
            }

            // Initialize vertex UID assigning the summit that is deeper.
            String VertexUID  = "";
            String VertexName = "";

            if (depthA > depthB)
            {
                VertexUID  = VertexUIDA;
                VertexName = vertexA;
            }
            else
            {
                VertexUID  = VertexUIDB;
                VertexName = vertexB;
            }

            String EdgeUID = getEdgeUIDFromVertex(VertexUID);
            // Account attributes to initialize ResultCollector.
            int AttributeNumber = getAttributeSize(VertexUID) + getAttributeSize(EdgeUID);


            ResultCollector result = new ResultCollector(AttributeNumber + 1);

            //Adding first vertex to VertexNameList.
            result.addVertexName(VertexName);


            // Count all attributes.
            int depthDiff = Math.Abs(depthA - depthB);

            for (int i = 0; i < depthDiff; ++i)
            {
                String AttrName  = "";
                int    AttrValue = 0;

                try
                {
                    SqlDataReader myReader  = null;
                    SqlCommand    myCommand = new SqlCommand("SELECT AD.AttrDefUid, AD.Name, AU.AttrValue FROM AttrDef AD, AttrUsage AU WHERE AU.ObjectUid = '" + VertexUID + "' AND AU.AttrDefUid = AD.AttrDefUid; ", this.MyConnection);
                    myReader = myCommand.ExecuteReader();

                    while (myReader.Read())
                    {
                        int.TryParse(myReader["AttrValue"].ToString(), out AttrValue);

                        AttrName = myReader["Name"].ToString();

                        if (i == 0)
                        {
                            result.addNewAttribute(AttrName, AttrValue);
                        }
                        else
                        {
                            result.addAttribute(AttrName, AttrValue);
                        }
                    }

                    myReader.Close();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }

                EdgeUID = getEdgeUIDFromVertex(VertexUID);

                try
                {
                    SqlDataReader myReader  = null;
                    SqlCommand    myCommand = new SqlCommand("SELECT AD.AttrDefUid, AD.Name, AU.AttrValue FROM AttrDef AD, AttrUsage AU WHERE AU.ObjectUid = '" + EdgeUID + "' AND AU.AttrDefUid = AD.AttrDefUid; ", this.MyConnection);
                    myReader = myCommand.ExecuteReader();

                    while (myReader.Read())
                    {
                        int.TryParse(myReader["AttrValue"].ToString(), out AttrValue);

                        AttrName = myReader["Name"].ToString();

                        if (i == 0)
                        {
                            result.addNewAttribute(AttrName, AttrValue);
                        }
                        else
                        {
                            result.addAttribute(AttrName, AttrValue);
                        }
                    }

                    myReader.Close();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }



                VertexUID  = getVertexUIDFromEdge(EdgeUID);
                VertexName = getVertexName(VertexUID);
                result.addVertexName(VertexName);
            }

            return(result.toString());
        }