Exemplo n.º 1
0
        public string sendOperatorInfoToPCS(Dictionary <string, string> operatorDict)
        {
            Operator _operator = new Operator();

            _operator.type         = operatorDict["TYPE"];
            _operator.id           = operatorDict["OPERATOR_ID"];
            _operator.input        = operatorDict["INPUT"];
            _operator.repFact      = Int32.Parse(operatorDict["REP_FACT"]);
            _operator.routing      = operatorDict["ROUTING"];
            _operator.loggingLevel = operatorDict["LOGGING_LEVEL"];
            _operator.semantics    = operatorDict["SEMANTICS"];
            if (operatorDict["FIELD_NUMBER"] != "")
            {
                _operator.fieldNumber = Int32.Parse(operatorDict["FIELD_NUMBER"]);
            }
            _operator.condition      = operatorDict["CONDITION"];
            _operator.conditionValue = operatorDict["CONDITION_VALUE"];
            _operator.status         = "Stand_by";
            _operator.dllCustom      = operatorDict["DLL"];
            _operator.classCustom    = operatorDict["CLASS"];
            _operator.methodCustom   = operatorDict["METHOD"];

            int operatorNumber = 0;

            foreach (string address in operatorDict["ADDRESSES"].Split('$'))
            {
                _operator.myAddress = address;
                _operator.repID     = operatorNumber;
                Operator finalOperator = new Operator();
                finalOperator.duplicate(_operator);
                PCS.operatorsDict.Add(finalOperator.id + "-" + finalOperator.repID, finalOperator);
                operatorNumber++;
                PCS.setMyPreviousAddresses(finalOperator.id, finalOperator.repID);
                //PCS.setMyReplicasAddresses(finalOperator.id, finalOperator.repID);
            }

            foreach (string key in PCS.operatorsDict.Keys)
            {
                Operator op = PCS.operatorsDict[key];
                op.print();
                Console.WriteLine("\r\n");
            }

            PCS.startOperator(_operator.id);
            return(_operator.id + " recebido pelo PCS");;
        }
Exemplo n.º 2
0
 public static string startOperator(string operatorID)
 {
     foreach (string key in PCS.operatorsDict.Keys)
     {
         if (key.Contains(operatorID))
         {
             operatorsDict[key].myReplicaAddresses = setMyReplicasAddresses(operatorID, operatorsDict[key].repID);
             string           operatorPath      = BuildPaths.getExecPath("\\Operator\\bin\\Debug\\Operator.exe");
             string           operatorArgs      = PCS.getAllFieldsOperator(key);
             ProcessStartInfo operatorStartInfo = new ProcessStartInfo();
             operatorStartInfo.FileName  = operatorPath;
             operatorStartInfo.Arguments = operatorArgs;
             Process operatorProcess = Process.Start(operatorStartInfo);
             Console.WriteLine("Comecei operador com id: " + operatorID + " e repID: " + PCS.operatorsDict[key].repID);
         }
     }
     return("Operator " + operatorID + " launched");
 }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            Console.Clear();
            Console.WriteLine();
            Console.WriteLine("PCS");
            Console.WriteLine("listening on tcp://" + PCS.GetLocalIPAddress() + ":10000/pcs");

            TcpChannel channel = new TcpChannel(10000);

            ChannelServices.RegisterChannel(channel, false);

            PCS pcs = new PCS();

            RemotingServices.Marshal(pcs, "pcs", typeof(IPCS));

            // Dont close console
            Console.ReadLine();

            // Close TcpChannel
            channel.StopListening(null);
            RemotingServices.Disconnect(pcs);
            ChannelServices.UnregisterChannel(channel);
            channel = null;
        }