예제 #1
0
파일: Form1.cs 프로젝트: lonely-bird/pang
        private void Form1_Shown(object sender, EventArgs e)
        {
            this.Size     = new Size(400, 800);
            this.Location = new Point(0, 0);
            InitializeControls();
            {
                Thread thread = new Thread(() =>
                {
                    while (true)
                    {
                        StringBuilder s = new StringBuilder();
                        foreach (var sh in socketHandlers)
                        {
                            s.AppendLine(sh.status);
                        }
                        s.AppendLine(status);
                        if (s.ToString() != LBL.Text)
                        {
                            LBL.Invoke(new Action(() => { LBL.Text = s.ToString(); }));
                        }
                        Thread.Sleep(10);
                    }
                });
                thread.IsBackground = true;
                thread.Start();
            }
            {
                Thread thread = new Thread(() =>
                {
                    while (true)
                    {
                        PBX.Invoke(new Action(() => { PBX.Image = (AIaction == '0' ? Properties.Resources.buttonLight : Properties.Resources.buttonDark); }));
                        TB.Invoke(new Action(() =>
                        {
                            int target = ((int)Math.Round(AIpressButtonPossibility * 1000.0) - TB.Value);
                            if (target > 0)
                            {
                                TB.Value += (int)Math.Ceiling(target * 0.2);
                            }
                            if (target < 0)
                            {
                                TB.Value += (int)Math.Floor(target * 0.2);
                            }
                            Application.DoEvents();
                        }));
                        Thread.Sleep(20);
                    }
                    ;
                });
                thread.IsBackground = true;
                thread.Start();
            }
            try
            {
                comport = new SerialPort("COM3", 115200, Parity.None, 8, StopBits.One);
                comport.DataReceived += Comport_DataReceived;
                if (!comport.IsOpen)
                {
                    comport.Open();
                }
            }
            catch (Exception error)
            {
                status += $"\r\nArduino doesn't connected, restart the program to try again\r\nError:\r\n{error}";
            }
            for (int i = 1; i <= socketCount; i++)
            {
                socketHandlers.Add(new MessageSender(port + i));
            }
            socketHandlers.Add(new MessageSender(port));
            MessageReceiver receiver = new MessageReceiver(aiPort);

            receiver.msgReceived += Receiver_msgReceived;
            receiver.Start();
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "ID,UserID,AuthorName,Title,Description,_Date,Open,GoLiveDate,SummaryDone,ServSpecDone,EOCDone,AppSupportDone,ChangeManDone,GISDone,NEDone,SCVDone,SREDone,DBADone,QADone,IAMDone,PBXDone,ITCSDone,SMODone,RisksDone,SignOffDone")] Project project)
        {
            if (ModelState.IsValid)
            {
                db.Projects.Add(project);
                project.Open = true;
                var user = User.Identity.GetUserName();
                if (user == "")
                {
                    user = "******";
                }
                project.UserID     = user;
                project.AuthorName = user;
                db.SaveChanges();
                // when a new project is created, create all corresponding entities
                AppsSupportReqs appsSupportReqs = new AppsSupportReqs();
                appsSupportReqs.ProjectID = project.ID;
                appsSupportReqs.ID        = project.ID;
                db.AppsSupportReqs.Add(appsSupportReqs);
                ChangeManagementReqs changeManagementReqs = new ChangeManagementReqs();
                changeManagementReqs.ProjectID = project.ID;
                changeManagementReqs.ID        = project.ID;
                db.ChangeManagementReqs.Add(changeManagementReqs);
                DBAReqs dbaReqs = new DBAReqs();
                dbaReqs.ProjectID = project.ID;
                dbaReqs.ID        = project.ID;
                db.DBAReqs.Add(dbaReqs);
                EOCReqs eocReqs = new EOCReqs();
                eocReqs.ProjectID = project.ID;
                eocReqs.ID        = project.ID;
                db.EOCReqs.Add(eocReqs);
                GISReqs gisReqs = new GISReqs();
                gisReqs.ProjectID = project.ID;
                gisReqs.ID        = project.ID;
                db.GISReqs.Add(gisReqs);
                IAMReqs iamReqs = new IAMReqs();
                iamReqs.ProjectID = project.ID;
                iamReqs.ID        = project.ID;
                db.IAMReqs.Add(iamReqs);
                ITCS itcs = new ITCS();
                itcs.ProjectID = project.ID;
                itcs.ID        = project.ID;
                db.ITCS.Add(itcs);
                NEReqs neReqs = new NEReqs();
                neReqs.ProjectID = project.ID;
                neReqs.ID        = project.ID;
                db.NEReqs.Add(neReqs);
                PBX pbx = new PBX();
                pbx.ProjectID = project.ID;
                pbx.ID        = project.ID;
                db.PBX.Add(pbx);
                QAReqs qaReqs = new QAReqs();
                qaReqs.ProjectID = project.ID;
                qaReqs.ID        = project.ID;
                db.QAReqs.Add(qaReqs);
                Risks risks = new Risks();
                risks.ProjectID         = project.ID;
                risks.RisksWarrantyDate = project.GoLiveDate;
                risks.RisksPreDate      = project.GoLiveDate;
                risks.ID = project.ID;
                db.Risks.Add(risks);
                SCVReqs scvReqs = new SCVReqs();
                scvReqs.ProjectID = project.ID;
                scvReqs.ID        = project.ID;
                db.SCVReqs.Add(scvReqs);
                ServiceSpecifics serviceSpecifics = new ServiceSpecifics();
                serviceSpecifics.ProjectID = project.ID;
                serviceSpecifics.ID        = project.ID;
                db.ServiceSpecifics.Add(serviceSpecifics);
                SignOff signOff = new SignOff();
                signOff.ProjectID   = project.ID;
                signOff.SignOffDate = project.GoLiveDate;
                signOff.ID          = project.ID;
                db.SignOffs.Add(signOff);
                SMOReqs smoReqs = new SMOReqs();
                smoReqs.ProjectID = project.ID;
                smoReqs.ID        = project.ID;
                db.SMOReqs.Add(smoReqs);
                SREReqs sreReqs = new SREReqs();
                sreReqs.ProjectID = project.ID;
                sreReqs.ID        = project.ID;
                db.SREReqs.Add(sreReqs);
                Summary summary = new Summary();
                summary.ProjectID  = project.ID;
                summary.ID         = project.ID;
                summary.GoLiveDate = project.GoLiveDate;
                db.Summaries.Add(summary);
                //generate history event recording project creation
                Event newEvent = new Event();
                newEvent.ProjectID = project.ID;
                newEvent.EventBody = "New SORT Project \"" + project.Title + "\" with Number " + project.ID + " created by " + project.AuthorName;
                newEvent.EventType = "New Project";
                db.Events.Add(newEvent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(project));
        }