コード例 #1
0
        static ICinema CreateCinema(CinemaType ct, EquipmentType et)
        {
            IRelay  projector, lamp1, lamp2;
            IEngine engine1, engine2;

            if (et == EquipmentType.Noolite)
            {
                projector = new RelayNoolite();
                lamp1     = new RelayNoolite();
                lamp2     = new RelayZWave();
                engine1   = new StepMotor();
                engine2   = new StepMotor();
            }
            else
            {
                projector = new RelayZWave();
                lamp1     = new RelayZWave();
                lamp2     = new RelayZWave();
                engine1   = new Motor();
                engine2   = new Motor();
            }

            switch (ct)
            {
            case CinemaType.flat:
                return(new CinemaFlat(lamp1, projector, engine1));

            case CinemaType.cottadge:
                return(new CinemaCottadge(projector, lamp1, lamp2, engine1, engine2));

            default:
                return(null);
            }
        }
コード例 #2
0
ファイル: Board.cs プロジェクト: Ray898/MicroscopeControl
        public void ChangeSpeed(ref StepMotor thisMotor, int speed)
        {
            Busy = true;
            byte[] byteSpeed = BitConverter.GetBytes(speed);
            byte[] sendthis  = new byte[] { Convert.ToByte('Q'), Convert.ToByte(thisMotor.ID), byteSpeed[0] };
            string message   = Encoding.ASCII.GetString(sendthis);

            SendData(sendthis);
        }
コード例 #3
0
 private void Init()
 {
     foreach (var mem in AxisManager.Instance.AxisDeviceS)
     {
         StepMotor     motor         = (StepMotor)mem.Value;
         AxisControlZd axisControlZd = new AxisControlZd(motor);
         flowLayoutPanel1.Controls.Add(axisControlZd);
         Thread.Sleep(10);
     }
 }
コード例 #4
0
ファイル: Board.cs プロジェクト: Ray898/MicroscopeControl
 public void ChangeDirection(ref StepMotor thisMotor, bool Checked)
 {
     Busy = true;                                                                            // Sets busy flag
     thisMotor.stepCheck = Checked;
     if (thisMotor.stepCheck)
     {
         SendData(Encoding.ASCII.GetBytes("R" + thisMotor.ID));
     }
     else
     {
         SendData(Encoding.ASCII.GetBytes("F" + thisMotor.ID));
     }
 }
コード例 #5
0
ファイル: Board.cs プロジェクト: Ray898/MicroscopeControl
 public void uStep(ref StepMotor thisMotor, bool Checked)
 {
     Busy = true;                                                                            // Sets busy flag
     thisMotor.stepCheck = Checked;
     if (thisMotor.stepCheck)
     {
         SendData(Encoding.ASCII.GetBytes("W" + thisMotor.ID));
     }
     else
     {
         SendData(Encoding.ASCII.GetBytes("U" + thisMotor.ID));
     }
 }
コード例 #6
0
ファイル: Board.cs プロジェクト: Ray898/MicroscopeControl
 public void MoveStage(ref StepMotor thisMotor, int step, char type)
 {
     //lock (locker)
     {
         Busy          = true;
         thisMotor.Pos = step;
         byte[] bytePos  = BitConverter.GetBytes(step);
         byte[] sendthis = new byte[] { Convert.ToByte(type), Convert.ToByte(thisMotor.ID), bytePos[0], bytePos[1] };
         string message  = Encoding.ASCII.GetString(sendthis);
         StatSender("Moving", thisMotor.ID);
         SendData(sendthis);
     }
 }
コード例 #7
0
ファイル: AxisControlZd.cs プロジェクト: MarkDDi/Frame
 public AxisControlZd(LogicAxis logicAxis)
 {
     InitializeComponent();
     cmB_MoveMode.SelectedIndex = 0;
     cmB_HomeDir.SelectedIndex  = 0;
     Motor = logicAxis.Motor;
     this.label_AxisName.Text = logicAxis.DeviceName;
     btn_Power.Text           = Motor.PowerStatue ? "Power On" : "Power Off";
     if (!logicAxis.IsHOme)
     {
         this.btn_Home.Enabled = false;
     }
     cmB_HomeDir.SelectedIndex = Motor.HomeDir;
     txt_MaxSpeed.Text         = Motor.MoveVM.ToString();
     CancellationTokenSource   = new CancellationTokenSource();
     Task.Run(new Action(() => FrashPosition()), CancellationTokenSource.Token);
 }
コード例 #8
0
ファイル: AxisControlZd.cs プロジェクト: MarkDDi/Frame
        public AxisControlZd(StepMotor motor)
        {
            InitializeComponent();

            cmB_MoveMode.SelectedIndex = 0;
            cmB_HomeDir.SelectedIndex  = 0;

            Motor = motor;
            this.label_AxisName.Text = Motor.DeviceName;
            btn_Power.Text           = Motor.PowerStatue ? "Power On" : "Power Off";

            cmB_HomeDir.SelectedIndex = Motor.HomeDir;


            txt_MaxSpeed.Text       = Motor.MoveVM.ToString();
            CancellationTokenSource = new CancellationTokenSource();
            Task.Run(new Action(() => FrashPosition()), CancellationTokenSource.Token);
        }
コード例 #9
0
        static void Main(string[] args)
        {
            WebClient wc = new WebClient();

            Console.WriteLine("ok");
            GPIOFile s1 = new GPIOFile(GPIOPins.V2_Pin_P1_11, GPIODirection.Out);
            GPIOFile s2 = new GPIOFile(GPIOPins.V2_Pin_P1_12, GPIODirection.Out);
            GPIOFile s3 = new GPIOFile(GPIOPins.V2_Pin_P1_13, GPIODirection.Out);
            GPIOFile s4 = new GPIOFile(GPIOPins.V2_Pin_P1_15, GPIODirection.Out);


            StepMotor m = new StepMotor(s1, s2, s3, s4);


            while (true)
            {
                string json = wc.DownloadString("http://a.wrd.app.fit.ba/home/getcommand?take=1");


                WebRezultat[] xArray = JsonConvert.DeserializeObject <WebRezultat[]>(json);


                var x = xArray[0];
                if (x.vrijednost == "Neretva_10_Plavo")
                {
                    wc.DownloadString("http://a.wrd.app.fit.ba/home?pozicija=Odgovor_na_komandu&vrijednost=Neterva_99_Zeleno");
                    m.PokreniMotor(400, Direkcija.Naprijed);
                }
                else if (x.vrijednost == "Neretva_20_Plavo")
                {
                    m.PokreniMotor(400, Direkcija.Nazad);
                }

                // System.Threading.Thread.Sleep(500);
            }
        }
コード例 #10
0
 bool m_isHome;     //是否执行回原点操作
 public LogicAxis(string devicename, Guid guid, StepMotor motor, bool isHome, uint homeIndex) : base(devicename, guid)
 {
     this.m_motor     = motor;
     this.m_isHome    = isHome;
     this.m_homeIndex = homeIndex;
 }
コード例 #11
0
ファイル: Board.cs プロジェクト: Ray898/MicroscopeControl
        private void ComInstruction(ref StepMotor myMotor)                                 // Manages received instructions from board (and actions on request)
        {
            //lock (locker)
            //{
            //AuxSender("RxON");
            bool   receivedAction = false;
            string lookup         = "";
            string command        = "";

            //if (RxString.Length >= 4)                                                               // Reads connection encoding and instruction
            //{
            lookup  = RxString.Substring(0, 2);
            command = RxString.Substring(2, 2);
            //}
            switch (command)                                                                   // Reads command and checks action (or none)
            {
            case "MF":                                                                         // Move Finished (Answers to 'P' request)                                                                                                //textBox1.Text = (Arduino.MainMotor.Pos + ", " + Arduino.MainMotor.PosRef);
                receivedAction = true;
                //myMotor.RxPos = BitConverter.ToUInt16(byteRead, 4) - 32;
                if (myMotor.Pos == myMotor.PosRef)                                                              // Check if position is up-to-date
                {
                    Busy = false;
                    StatSender("MoveFinished", myMotor.ID);
                }
                else
                {
                    Busy = true;
                    MoveStage(ref myMotor, myMotor.PosRef, 'P');
                    StatSender("MoveIncomplete", myMotor.ID);                                                  // Sends movement request to board
                }
                break;

            case "IF":                                                                          // Information received
                if (byteRead.Length == 12)
                {
                    receivedAction = true;                                           // Decode and allocate data
                    Busy           = false;
                    //Thread.Sleep(50);
                    MainMotor.StepVal  = BitConverter.ToUInt16(byteRead, 4).ToString();
                    MainMotor.CycleVal = BitConverter.ToUInt16(byteRead, 6).ToString();
                    MainMotor.TimeVal  = BitConverter.ToUInt16(byteRead, 8).ToString();
                    AuxMotor.StepVal   = BitConverter.ToUInt16(byteRead, 10).ToString();
                    StatSender("DataInfo", myMotor.ID);
                    break;
                }
                else
                {
                    Busy           = true;
                    receivedAction = false;
                }
                break;

            case "OF":                                                                          // Origin stablished
                receivedAction = true;
                Busy           = false;
                myMotor.Pos    = 0;
                myMotor.PosRef = 0;
                myMotor.Cycle  = 0;
                StatSender("Origin", myMotor.ID);
                break;

            case "SF":                                                                          // Cycle completed (Then sends board request for stablishing origin)
                receivedAction = true;
                Busy           = false;
                myMotor.Pos    = 0;
                myMotor.PosRef = 0;
                StatSender("Cycle", myMotor.ID);
                break;

            case "VF":                                                                          // Save completed
                receivedAction = true;
                Busy           = false;
                StatSender("DataSaved", myMotor.ID);
                break;

            case "LF":
                receivedAction = true;
                Busy           = false;
                StatSender("ServoMoved", myMotor.ID);
                break;

            //case "AF":
            //    receivedAction = true;
            //    Busy = false;
            //    myMotor.active = true;
            //    StatSender("Activated", myMotor.ID);
            //    break;
            //case "DF":
            //    receivedAction = true;
            //    Busy = false;
            //    myMotor.active = false;
            //    StatSender("Deactivated", myMotor.ID);
            //    break;
            case "CF":
                receivedAction = true;
                int temp = BitConverter.ToUInt16(byteRead, 4);
                Temperature = (float)((temp * 500.0) / 1024.0);
                //*****************For LM19***********
                //var tempF = (5.0*temp) / 1024;
                //MessageBox.Show(temp.ToString());
                //Temperature = (float)(Math.Sqrt((2.1962 * Math.Pow(10, 6)) + ((1.8639 - tempF) / (3.88 * Math.Pow(10, -6)))) - 1481.96);
                //*************************************
                Busy = false;
                StatSender("temperature", '¬');
                break;

            case "AF":
            case "DF":
            case "RF":                                                                          // Completed reverse direction selection
            case "FF":                                                                          // Completed forward direction selection
            case "QF":                                                                          // Completed speed selection
            case "UF":                                                                          // Completed normal step selection
            case "WF":                                                                          // Completed uStep selection
            case "KF":
                receivedAction = true;
                Busy           = false;
                break;

            default:
                receivedAction = false;
                break;
            }
            //AuxSender("RxOFF");
            if (!receivedAction)                                                                    // If no correct response from board is received, send again board request
            {
                PortCOM.Write(TxByte, 0, TxByte.Length);
            }
            //}
        }
コード例 #12
0
ファイル: Board.cs プロジェクト: Ray898/MicroscopeControl
 public void Deactivate(StepMotor thisMotor)
 {
     Busy = true;
     SendData(Encoding.ASCII.GetBytes("D" + thisMotor.ID));
 }
コード例 #13
0
ファイル: Board.cs プロジェクト: Ray898/MicroscopeControl
 public void SetOrigin(ref StepMotor thisMotor)
 {
     Busy = true;                                                                            // Sets busy flag
     //Thread.Sleep(5);
     SendData(Encoding.ASCII.GetBytes("O" + thisMotor.ID));
 }