public void PortionReceive(string statementsXML) { XDocument doc = XDocument.Parse(statementsXML); var q = from x in doc.Elements().Descendants("Pid") select x; string Pid = q.ElementAt(0).Value.ToString(); // SwarmMemory sm = function(Pid); SwarmMemory sm = new SwarmMemory("d",""); sm.adjustThePartialTables(statementsXML); }
public EditPermissions(SwarmMemory sm, string ip, string port, string text, string uname) { InitializeComponent(); SM = sm; myIP = ip; myPort = port; programText = text; owner = uname; chkRead.IsEnabled = false; chkWrite.IsEnabled = false; btnGrant.IsEnabled = false; btnCngOwner.IsEnabled = false; }
public void setSMObject(SwarmMemory sm) { coreObject.setSwarmObject(sm); }
public void setSwarmObject(SwarmMemory sm) { smem = sm; interp_visitor.setSwarmObject(sm); }
public void InsertProgtoSC(SwarmMemory sm) { mSocket.InsertProg(sm.getPid(), sm); }
//*** All the public functions ***// /// <summary> /// ProgWin Constructor /// </summary> /// <param name="e">editor type</param> /// <param name="sconn">Swarm Connection Object</param> /// <param name="ip">Self IP</param> /// <param name="port">Self Port</param> /// <param name="pid">PID of the program</param> /// <param name="uname">Self USername</param> public ProgWin(editorType e, SwarmConnection sconn, string ip, string port, string pid, string uname, string Prog) { InitializeComponent(); et = e; err.ProgWinError += new ErrorNotification(ShowError); plot.image += new PlotReceiver.BmpImage(EnablePlot); Controller = new executor(); Controller.resEvent += new executor.result(Display); keywords = Controller.frontEnd.getKeywords(); err.SetExecutorObject(Controller); err.SetPlotObject(plot); username = uname; progName = Prog; //Swarm Operations SC = sconn; SM = new SwarmMemory(SC); IP = ip; Port = port; PID = pid; SM.PermissionListCh += new SwarmMemory.PermissionListChanged(progUserListChange); SM.rnBtnClicked += new SwarmMemory.RunButtonClick(RunClicked); SM.srcChanged += new SwarmMemory.SourceCodeChanged(CollabEditing); SM.CloseP += new SwarmMemory.CloseProgram(SM_CloseP); SM.RerunP += new SwarmMemory.RerunProgram(SM_RerunP); SC.DisconnectChanged += new SwarmConnection.DisconnectEventHandler(SM_CloseP); SM.FinalResult += new SwarmMemory.GetFinalResult(SM_FinalResult); SM.createTheObjects(PID, IP, Port); //Finally the swarm memory object SC.InsertProgtoSC(SM); err.SetSwarmMemoryObject(SM); //Exec Operations Controller.setPlotObject(plot); Controller.setSMObject(SM); worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); prog = new TextRange(rtbInput.Document.ContentStart, rtbInput.Document.ContentEnd).Text; userColor.Add(Colors.Brown); userColor.Add(Colors.Yellow); userColor.Add(Colors.Green); }
public void CreatProgram(string pid) { SwarmMemory sm = new SwarmMemory(pid, mSocket.GetIP() + ":" + mSocket.GetPort()); sm.setOwner(mSocket.GetIP() + ":" + mSocket.GetPort()); mSocket.InsertProg(pid, sm); }
public void InsertProg(String pid, SwarmMemory prog) { Program[pid] = prog; }
public SwarmMemory InitializeThePeer(string data, string myIPPort) { XDocument doc = XDocument.Parse(data); var q = from x in doc.Elements().Descendants("Pid") select x; string Pid = q.ElementAt(0).Value.ToString(); SwarmMemory sm = new SwarmMemory(Pid,myIPPort); q = from x in doc.Elements().Descendants("stack").Descendants("value") select x; Stack<string> newProgramStack = new Stack<string>(); foreach (var item in q) { newProgramStack.Push(item.Value.ToString()); } newProgramStack.Reverse(); sm.setProgramStack(newProgramStack); //////////////////////////////////////////////////////// q = from x in doc.Elements().Descendants("partialResults").Descendants("Result").Descendants("IPPort") select x; List<string> ResultIPorts = new List<string>(); foreach (var item in q) { ResultIPorts.Add(item.Value.ToString()); } q = from x in doc.Elements().Descendants("partialResults").Descendants("Result").Descendants("ResultValue") select x; List<string> ResultVal = new List<string>(); foreach (var item in q) { ResultVal.Add(item.Value.ToString()); } q = from x in doc.Elements().Descendants("partialResults").Descendants("Result").Descendants("done") select x; List<string> _done = new List<string>(); foreach (var item in q) { _done.Add(item.Value.ToString()); } Hashtable newPartialResults = new Hashtable(); for (int i = 0; i < ResultIPorts.Count; i++) { string[] temp = { ResultVal[i].ToString(), _done[i].ToString() }; newPartialResults.Add(ResultIPorts[i].ToString(), temp); } sm.setpartialResults(newPartialResults); ///////////////////////////// q = from x in doc.Elements().Descendants("permissions").Descendants("permit").Descendants("IPPort") select x; List<string> IPorts = new List<string>(); foreach (var item in q) { IPorts.Add(item.Value.ToString()); } q = from x in doc.Elements().Descendants("permissions").Descendants("permit").Descendants("read") select x; List<string> reads = new List<string>(); foreach (var item in q) { reads.Add(item.Value.ToString()); } q = from x in doc.Elements().Descendants("permissions").Descendants("permit").Descendants("write") select x; List<string> writes = new List<string>(); foreach (var item in q) { writes.Add(item.Value.ToString()); } Hashtable newPermissions = new Hashtable(); for (int i = 0; i < IPorts.Count; i++) { string[] temp = { reads[i].ToString(), writes[i].ToString() }; newPermissions.Add(IPorts[i].ToString(), temp); } sm.setPermissions(newPermissions); ////////////////////////////// q = from x in doc.Elements().Descendants("programVariables").Descendants("variable").Descendants("name") select x; List<string> varnames = new List<string>(); foreach (var item in q) { varnames.Add(item.Value.ToString()); } q = from x in doc.Elements().Descendants("programVariables").Descendants("variable").Descendants("value") select x; List<string> varvalues = new List<string>(); foreach (var item in q) { varvalues.Add(item.Value.ToString()); } Hashtable newProgramVariables = new Hashtable(); for (int i = 0; i < varnames.Count; i++) { newProgramVariables.Add(varnames[i].ToString(), varvalues[i].ToString()); } sm.setProgramVariables(newProgramVariables); /////////////////////////////////////////// q = from x in doc.Elements().Descendants("Replies").Descendants("Reply").Descendants("IPPort") select x; List<string> ports = new List<string>(); foreach (var item in q) { ports.Add(item.Value.ToString()); } q = from x in doc.Elements().Descendants("Replies").Descendants("Reply").Descendants("ReplyValue") select x; List<string> repVal = new List<string>(); foreach (var item in q) { repVal.Add(item.Value.ToString()); } Hashtable newReplies = new Hashtable(); for (int i = 0; i < ports.Count; i++) { newReplies.Add(ports[i].ToString(), repVal[i].ToString()); } sm.setReply(newReplies); /////////////////////////////// q = from x in doc.Elements().Descendants("Owner") select x; string owner = q.ElementAt(0).Value.ToString(); sm.setOwner(owner); return sm; /* ////////////////////////////////////////////////////// //this part belongs to TEST2 string TestID = Pid; Stack<string> TestStack = sm.getStack(); Hashtable TestPartialResults = sm.getPartialResults(); Hashtable TestPermissions = sm.getPermissions(); Hashtable TestVariables = sm.getProgramVariables(); Hashtable TestReplies = sm.getReplies(); string TestOwner = sm.getOwner(); Console.WriteLine("========STACK======="); foreach (string item in TestStack) { Console.WriteLine(item.ToString()); } Console.WriteLine("========PartialResults======="); foreach (DictionaryEntry item in TestPartialResults) { string[] temp = (string[])item.Value; Console.WriteLine("IP={0} Value={1} Done={2}", item.Key.ToString(), temp[0].ToString(), temp[1].ToString()); } Console.WriteLine("========Permissions======="); foreach (DictionaryEntry item in TestPermissions) { string[] temp = (string[])item.Value; Console.WriteLine("IP={0} read={1} write={2}", item.Key.ToString(), temp[0].ToString(), temp[1].ToString()); } Console.WriteLine("========Variables======="); foreach (DictionaryEntry item in TestVariables) { Console.WriteLine("name={0} value={1}",item.Key.ToString(),item.Value.ToString()); } Console.WriteLine("========Replies======="); foreach (DictionaryEntry item in TestReplies) { Console.WriteLine("IP={0} Reply={1}", item.Key.ToString(), item.Value.ToString()); } Console.WriteLine("========Owner======="); Console.WriteLine("Owner={0}",TestOwner); * */ }
public void masterSourceCodeChage(string changes) { XDocument doc = XDocument.Parse(changes); var q = from x in doc.Elements().Descendants("Pid") select x; string Pid = q.ElementAt(0).Value.ToString(); SwarmMemory sm = new SwarmMemory("dsf","");// SwarmMemory sm = function(Pid); sm.masterCodeChanger(changes); }
public void StackInfo(string _stack) { // SwarmMemory sm = function(Pid); SwarmMemory sm = new SwarmMemory("d",""); sm.receiveStack(_stack); }
public void SetSwarmMemoryObject(SwarmMemory s) { SM = s; SM.ErrorResult+=new SwarmMemory.BrdErrorResult(ShowMsg); }
public Hashtable GetPermission(String pid) { SwarmMemory temp=new SwarmMemory("-1",""); Hashtable result = new Hashtable(); if (Program.Contains(pid)) temp = (SwarmMemory)Program[pid]; result = temp.getPermissions(); foreach (DictionaryEntry item in result) { string[] temp1 = (string[])item.Value; Console.WriteLine("IPPrt={0} read={1} write={2}", item.Key.ToString(), temp1[0], temp1[1]); } return result; }
private void button4_Click(object sender, EventArgs e) { SwarmMemory sm = new SwarmMemory("1", mSocket.GetIP() + ":" + mSocket.GetPort()); mSocket.InsertProg("1", sm); mSocket.GetProg("1").setOwner(mSocket.GetIP() + ":" + mSocket.GetPort()); SwarmMemory sm1 = new SwarmMemory("2", mSocket.GetIP() + ":" + mSocket.GetPort()); mSocket.InsertProg("2", sm1); mSocket.GetProg("2").setOwner(mSocket.GetIP() + ":" + mSocket.GetPort()); Console.WriteLine(mSocket.GetProg("1").getPid().ToString()); Console.WriteLine(mSocket.GetProg("2").getPid().ToString()); }