コード例 #1
0
        public static AxDBCommManager Create(DBPlcId Model, Via Via, string Para)
        {
            try
            {
                plcKey = new AxDBCommManager();
                plcKey.CreateControl();
                plcKey.PLC  = Model;
                plcKey.Peer = Via.ToString();
                if (Via != Via.USB)
                {
                    plcKey.Peer = Para;
                }
                plcKey.UseWaitCursor = true;

                plcKey.Connect();


                G.isConnect = isConnect.Connected;
            }
            catch (Exception)
            {
                G.isConnect = isConnect.Disconnected;
            }
            return(plcKey);
        }
コード例 #2
0
ファイル: Online.cs プロジェクト: QuocTuan1992/SFS
        public Online()
        {
            int index = 0; bool blConnect = false;

            foreach (LisPLC LisPLC in G.LisPLC)
            {
                // AxDBCommManager plcTemp = new AxDBCommManager();

                DBPlcId eModel = (DBPlcId)Enum.Parse(typeof(MOD), LisPLC.Mod.Replace("-", ""));

                Via eVia = LisPLC.Via;
                // KEYENCEs.Create(eModel, eVia, LisPLC.Para);

                G.LisPLC[index].plcKey = KEYENCEs.Create(eModel, eVia, LisPLC.Para);
                // G.LisPLC[index].plcKey = KEYENCE.KEYENCEs.Connnect(LisPLC.plcKey);
                G.LisPLC[index].isConnect = G.isConnect;
                if (G.isConnect == isConnect.Disconnected)
                {
                    int num = index + 1;
                    G.sError   = "ERROR 0X02  : " + "LỖI ĐƯỜNG TRUYỀN KẾT NỐI VỚI LINE !" + Environment.NewLine + "VUI LÒNG KIỂM TRA LẠI KẾT NỐI VỚI THIẾT BỊ :" + LisPLC.name + "(" + LisPLC.Para + ")";
                    G.imgError = new Bitmap("pic\\errorWifi.gif");
                    Error      = new Error();
                    Error.ShowDialog();          //  this.Hide();

                    break;
                    blConnect = true;
                }
                index++;
            }
        }
コード例 #3
0
        /// <summary>
        /// Parse a message value.
        /// </summary>
        /// <param name="name">Name of header being parsed.</param>
        /// <param name="reader">Reader containing the string that should be parsed.</param>
        /// <returns>Newly created header.</returns>
        /// <exception cref="ParseException">Header value is malformed.</exception>
        public IHeader Parse(string name, ITextReader reader)
        {
            ViaEntry entry = ParseEntry(reader);

            if (reader.Current != ',')
            {
                return new Via {
                           entry
                }
            }
            ;

            var via = new Via {
                entry
            };

            while (reader.Current == ',')
            {
                reader.ConsumeWhiteSpaces(',');

                entry = ParseEntry(reader);
                via.Add(entry);
            }
            return(via);
        }

        #endregion
    }
コード例 #4
0
        internal void AddRule(Station station, Via viaRule)
        {
            Location location2 = Location.NotSet;

            if (TryGetLocation(viaRule.dest, "Destination", out var destination) &&
                TryGetLocation(viaRule.loc1, "Location1", out var location1) &&
                (string.IsNullOrEmpty(viaRule.loc2) || TryGetLocation(viaRule.loc2, "Location2", out location2)))
            {
                var rule = new ViaRule()
                {
                    At          = station,
                    Destination = destination,
                    Location1   = location1,
                    Location2   = location2,
                    Text        = viaRule.viatext
                };
                station.Add(rule);
            }

            bool TryGetLocation(string tiploc, string property, out Location location)
            {
                location = Location.NotSet;
                if (_locations.LocationsByTiploc.TryGetValue(tiploc, out location))
                {
                    return(true);
                }

                _log.Warning("Did not find {property} for via rule {@viaRule}", property, viaRule);
                return(false);
            }
        }
コード例 #5
0
        public bool TryAddLineItems(Stock s, int amount)
        {
            bool hasKey = LineItemUnits.ContainsKey(s.Matter);

            if ((hasKey && LineItemUnits[s.Matter] + amount > -1) || (!hasKey && amount > -1))
            {
                if (hasKey)
                {
                    LineItemUnits[s.Matter] += amount;
                }
                else
                {
                    LineItemUnits[s.Matter] = amount;
                }

                MatterCost += s.ListPrice * amount;

                RecalcVolumeMassShipping();

                //validate
                if (amount > 0)
                {
                    if (TotalVolume > Via.MaximumVolume() || TotalMass > Via.MaximumMass())
                    {
                        TryAddLineItems(s, -amount);
                        return(false);
                    }
                }

                return(true);
            }

            return(false);
        }
コード例 #6
0
        public override string ToString()
        {
            string source = string.Empty;

            if (!From.Equals(string.Empty))
            {
                source += " from " + From + "\r\n ";
            }
            if (!By.Equals(string.Empty))
            {
                source += " by " + By + "\r\n ";
            }
            if (!With.Equals(string.Empty))
            {
                source += " with " + With + "\r\n ";
            }
            if (!For.Equals(string.Empty))
            {
                source += " for " + For + "\r\n ";
            }
            if (!Via.Equals(string.Empty))
            {
                source += " via " + Via + "\r\n ";
            }
            if (!Id.Equals(string.Empty))
            {
                source += " id " + Id + "\r\n ";
            }

            if (string.IsNullOrEmpty(source))
            {
                return("");
            }
            return(source.Remove(0, source.Length - 3) + ";" + Date.ToString("r"));
        }
コード例 #7
0
        /// <summary>
        /// Assign a header
        /// </summary>
        /// <param name="name">Long name, in lower case.</param>
        /// <param name="header">Header to assign</param>
        internal virtual void Assign(string name, IHeader header)
        {
            switch (name)
            {
            case "to":
                To = ((ContactHeader)header).FirstContact;
                break;

            case "from":
                From = ((ContactHeader)header).FirstContact;
                break;

            case "cseq":
                CSeq = (CSeq)header;
                break;

            case "via":
                var via = (Via)header;
                if (Via != null && Via.Items.Count > 0)
                {
                    foreach (ViaEntry entry in via)
                    {
                        Via.Add(entry);
                    }
                }
                else
                {
                    Via = via;
                }
                break;
            }

            Headers.Add(name.ToLower(), header);
        }
コード例 #8
0
ファイル: Request.cs プロジェクト: jeoffman/SipSharp
        /// <summary>
        /// Create a new response.
        /// </summary>
        /// <param name="code">Response status code</param>
        /// <param name="reason">Reason to why the status code was used.</param>
        /// <returns>A Created response.</returns>
        /// <exception cref="InvalidOperationException">Provisional responses is only valid for INVITE method.</exception>
        public IResponse CreateResponse(StatusCode code, string reason)
        {
            if (StatusCodeHelper.Is1xx(code) && Method != "INVITE")
            {
                throw new InvalidOperationException("Provisional responses is only valid for INVITE method.");
            }

            var response = new Response(SipVersion, code, reason);

            // When a 100 (Trying) response is generated, any Timestamp header field
            // present in the request MUST be copied into this 100 (Trying)
            // response.  If there is a delay in generating the response, the UAS
            // SHOULD add a delay value into the Timestamp value in the response.
            // This value MUST contain the difference between the time of sending of
            // the response and receipt of the request, measured in seconds.
            if (StatusCodeHelper.Is1xx(code) && Headers["Timestamp"] != null)
            {
                response.Headers.Add("Timestamp", Headers["Timestamp"]);
            }

            // The From field of the response MUST equal the From header field of
            // the request.  The Call-ID header field of the response MUST equal the
            // Call-ID header field of the request.  The CSeq header field of the
            // response MUST equal the CSeq field of the request.  The Via header
            // field values in the response MUST equal the Via header field values
            // in the request and MUST maintain the same ordering.
            response.From   = From;
            response.CallId = CallId;
            response.CSeq   = CSeq;
            response.Via    = (Via)Via.Clone();


            // If a request contained a To tag in the request, the To header field
            // in the response MUST equal that of the request.  However, if the To
            // header field in the request did not contain a tag, the URI in the To
            // header field in the response MUST equal the URI in the To header
            // field; additionally, the UAS MUST add a tag to the To header field in
            // the response (with the exception of the 100 (Trying) response, in
            // which a tag MAY be present).  This serves to identify the UAS that is
            // responding, possibly resulting in a component of a dialog ID.  The
            // same tag MUST be used for all responses to that request, both final
            // and provisional (again excepting the 100 (Trying)).  Procedures for
            // the generation of tags are defined in Section 19.3.
            response.To = To;
            if (To.Parameters["tag"] != null)
            {
                // RFC3261 Section 17.2.1:
                // The 100 (Trying) response is constructed
                // according to the procedures in Section 8.2.6, except that the
                // insertion of tags in the To header field of the response (when none
                // was present in the request) is downgraded from MAY to SHOULD NOT.
                if (!StatusCodeHelper.Is1xx(code))
                {
                    response.To.Parameters.Add("tag", Guid.NewGuid().ToString().Replace("-", string.Empty));
                }
            }

            return(response);
        }
コード例 #9
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            Medicamento med = medicamentoLogica.TraerMedicamentoPorId(Convert.ToInt32(cboMedicamento.SelectedValue));
            Via         via = viaLogica.TraerViaPorId(Convert.ToInt32(cboVia.SelectedValue));

            //Agrega filas
            dgvDetalle.Rows.Add(med.Id, med.Codigo, med.Descripcion, via.Id, via.Descripcion, txtFrecuencia.Text);
        }
コード例 #10
0
ファイル: ParseTests.cs プロジェクト: Jacfal/SipClient
        public void Create_Sip_Via_Success(string via)
        {
            // *** ACT ***
            Via    v  = Via.Parse(via);
            string vs = v.ToString();

            // *** ASSERT ***
            Assert.Equal(via, vs);
        }
コード例 #11
0
        public Via TraerViaPorId(int idVia)
        {
            ViaDatos viaDatos = new ViaDatos();
            Via      via      = new Via();

            via = viaDatos.TraerViaPorId(idVia);

            return(via);
        }
コード例 #12
0
ファイル: frmViaReplace.cs プロジェクト: RandyLyne/SwRI_Tools
    private void btnSelect_Click(object sender, EventArgs e)
    {
        if (PCBServer == null)
        {
            return;
        }

        IPCB_BoardIterator BoardIterator;
        IPCB_Via           Via;

        Board = Util.GetCurrentPCB();

        if (Board == null)
        {
            return;
        }

        BoardIterator = Board.BoardIterator_Create();

        //Iterate theough all components on the board.
        PCB.TObjectSet FilterSet = new PCB.TObjectSet();
        //Filter for components only.
        FilterSet.Add(PCB.TObjectId.eViaObject);
        BoardIterator.AddFilter_ObjectSet(FilterSet);
        BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
        BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

        IPCB_DrillLayerPair        OldPair = null, DrillPair = null;
        List <IPCB_DrillLayerPair> NewPairs = new List <IPCB_DrillLayerPair>();

        for (int i = 0; i < Board.GetState_DrillLayerPairsCount(); i++)
        {
            DrillPair = Board.GetState_LayerPair(i);
            if (lstBefore.SelectedItem.ToString() == DrillPair.GetState_Description())
            {
                OldPair = DrillPair;
            }
        }

        Via = BoardIterator.FirstPCBObject() as IPCB_Via;

        Board.BeginModify();

        while (Via != null)
        {
            if (Via.GetState_StartLayer() == OldPair.GetState_StartLayer() && Via.GetState_StopLayer() == OldPair.GetState_StopLayer())
            {
                Via.SetState_Selected(true);
            }
            Via = BoardIterator.NextPCBObject() as IPCB_Via;
        }

        Board.EndModify();

        Board.BoardIterator_Destroy(ref BoardIterator);
    }
コード例 #13
0
        public void TestViaMapping(Via via, string viaText)
        {
            var mapper = new MapperConfiguration(cfg => cfg.AddProfile <TicketProfile>()).CreateMapper();

            var ticket = new Ticket {
                Via = via
            };

            var mapped = mapper.Map <Middleware.Model.Ticket>(ticket);

            mapped.Via.Should().Be(viaText);
        }
コード例 #14
0
 public LisPLC(string name, string Co, string Mod, Via Via, string Para, AxDBCommManager plcKey, isConnect isConnect, Image imgModel, Image imgVia, Point pMap)
 {
     this.name      = name;
     this.plcKey    = plcKey;
     this.Para      = Para;
     this.isConnect = isConnect;
     this.imgModel  = imgModel;
     this.imgVia    = imgVia;
     this.pMap      = pMap;
     this.Mod       = Mod;
     this.Co        = Co;
     this.Via       = Via;
 }
コード例 #15
0
ファイル: NewDevice.cs プロジェクト: QuocTuan1992/SFS
        private void btnAdd_Click(object sender, EventArgs e)
        {
            G.sourceSQL = G.VariableSQL;
            if (!cSQL.CHECK("*", "DEVICE", "DEVICE='" + txtName.Text + "' OR PARAMETER ='" + cbPara.Text.Trim() + G.portIP + "'"))
            {
                if (cbPara.Text != "")
                {
                    dynamic         itModel = cbModel.Items[cbModel.SelectedIndex];
                    DBPlcId         eModel  = (DBPlcId)int.Parse(itModel.Value);
                    dynamic         itVia   = cbVia.Items[cbVia.SelectedIndex];
                    Via             eVia    = (Via)int.Parse(itVia.Value);
                    AxDBCommManager plcTemp = new AxDBCommManager();
                    // cbModel.Items

                    plcTemp = KEYENCEs.Create(eModel, eVia, cbPara.Text.Trim() + G.portIP);
                    // G.ListKey.Add(new ListKey("", plcTemp, isConnect.Connected, img, new Point(0, 0)));
                    G.LisPLC.Add(new LisPLC(txtName.Text, cbCo.Text, cbModel.Text, eVia, cbPara.Text.Trim() + G.portIP, plcTemp, G.isConnect, picModel, picVia, G.pPen));
                    List <string> List = new List <string>();
                    List.Add(G.LisPLC[G.LisPLC.Count - 1].name);
                    List.Add("PLC");
                    List.Add(G.LisPLC[G.LisPLC.Count - 1].Co.ToString());
                    List.Add(G.LisPLC[G.LisPLC.Count - 1].Mod.ToString());
                    List.Add(G.LisPLC[G.LisPLC.Count - 1].Via.ToString());
                    List.Add(G.LisPLC[G.LisPLC.Count - 1].Para.ToString());
                    List.Add(G.LisPLC[G.LisPLC.Count - 1].isConnect.ToString());
                    cSQL.Insert("DEVICE", List);

                    // fm1.PicMap.Invalidate();
                    fm1.picMap.Invalidate();

                    //  LoadDevice();
                    G.pPen.X += picReview.Width + 10;
                    if (G.pPen.X + picReview.Width >= fm1.PicMap.Width)
                    {
                        G.pPen.Y += picReview.Height + 50;
                        G.pPen.X  = 0;
                    }
                }
                else
                {
                    MessageBox.Show("Vui lòng quét thông số kết nối trước khi thêm thiết bị mới !");
                }
            }
            else
            {
                MessageBox.Show("Vui lòng đặt tên khác hoặc thông số khác !");
            }
            G.sourceSQL = G.defautSQL;
            //   int A = plcTemp.ReadDevice(DBPlcDevice.DKV3000_DM, "110");
        }
コード例 #16
0
        /// <summary>
        /// Draw a via on the board
        /// </summary>
        public Via DrawVia(PointF where, double size, double drill, Net net, bool last_front = false)
        {
            Via via = new Via();

            via.Location  = where;
            via.Size      = size;
            via.DrillSize = drill;
            via.Net       = net;
            Vias.Add(via);
            lastNet   = net;
            lastPoint = where;
            lastFront = last_front;
            return(via);
        }
コード例 #17
0
ファイル: ViaParser.cs プロジェクト: jgauffin/SipSharp
        /// <summary>
        /// Parse a message value.
        /// </summary>
        /// <param name="name">Name of header being parsed.</param>
        /// <param name="reader">Reader containing the string that should be parsed.</param>
        /// <returns>Newly created header.</returns>
        /// <exception cref="ParseException">Header value is malformed.</exception>
        public IHeader Parse(string name, ITextReader reader)
        {
            ViaEntry entry = ParseEntry(reader);
            if (reader.Current != ',')
                return new Via {entry};

            var via = new Via {entry};
            while (reader.Current == ',')
            {
                reader.ConsumeWhiteSpaces(',');
                entry = ParseEntry(reader);
                via.Add(entry);
            }
            return via;
        }
コード例 #18
0
ファイル: Drive1541.cs プロジェクト: retr0s4ge/BizHawk
        public Drive1541(int clockNum, int clockDen)
        {
            DriveRom = new Chip23128();
            _cpu     = new MOS6502X <CpuLink>(new CpuLink(this))
            {
                NMI = false
            };

            _ram = new int[0x800];
            Via0 = Chip6522.Create(ViaReadClock, ViaReadData, ViaReadAtn, 8);
            Via1 = Chip6522.Create(ReadVia1PrA, ReadVia1PrB);

            _cpuClockNum      = clockNum;
            _driveCpuClockNum = clockDen * 16000000;             // 16mhz
        }
コード例 #19
0
            public override bool ProcessLine(byte[] line)
            {
                Layers    StartLayer, EndLayer;
                double    X, Y, Width, HoleSize;
                double    RRatio = 0;
                Int16     Component;
                Int16     Net;
                ViaStruct via = ByteArrayToStructure <ViaStruct>(line);

                base.ProcessLine();

                StartLayer = (Layers)via.StartLayer;
                EndLayer   = (Layers)via.EndLayer;
                Net        = via.net;
                Net++;
                Component = via.Component;
                X         = Math.Round(ToMM(via.X) - originX, Precision);
                Y         = Math.Round(ToMM(via.Y) - originY, Precision);
                CheckMinMax(X, Y);
                Width    = ToMM(via.Width);
                HoleSize = ToMM(via.Hole);
                bool InComponent = Component != -1;

                if (!InComponent)
                {
                    Via Via = new Via(X, Y, Width, HoleSize, Net, StartLayer, EndLayer);
                    ViasL.Add(Via);
                }
                else
                {
                    // can't have vias in components in Kicad (yet) so add as a pad
                    Pad Pad = new Pad("0", "thru_hole", "circle", X, Y, 0, Width, Width, HoleSize, "*.Cu", Net, RRatio)
                    {
                        SolderMaskExpansion = 0,
                        PasteMaskExpansion  = 0,
                        Component           = Component
                    };
                    if (Component > 0 && Component < ModulesL.Count)
                    {
                        ModulesL[Component].Pads.Add(Pad);
                    }
                    else
                    {
                        OutputError($"Invalid component {Component}");
                    }
                }
                return(true);
            }
コード例 #20
0
        private void TestTortousInvite()
        {
            MessageFactoryContext context = _factory.CreateNewContext(null);

            Parse(context, Messages.AShortTortuousINVITE);
            Assert.NotNull(_request);
            Assert.Equal("chair-dnrc.example.com", _request.Uri.Domain);
            Assert.Equal("1918181833n", _request.To.Parameters["tag"]);

            Via via = _request.Via;

            Assert.Equal(3, via.Items.Count);
            Assert.Equal("390skdjuw", via.Items[0].Branch);
            Assert.Equal("SIP/2.0", via.Items[0].SipVersion);
            Assert.Equal("192.168.255.111", via.Items[2].Domain);
        }
コード例 #21
0
        public void ProcessPreambleInitiator()
        {
            ResetWriteBuffer();

            buffer.WriteByte(VersionRecord);
            buffer.WriteByte(1);
            buffer.WriteByte(0);
            buffer.WriteByte(ModeRecord);
            buffer.WriteByte((byte)mode);
            buffer.WriteByte(ViaRecord);
            writer.Write(Via.ToString());
            buffer.WriteByte(KnownEncodingRecord); // FIXME
            buffer.WriteByte((byte)EncodingRecord);
            buffer.WriteByte(PreambleEndRecord);
            buffer.Flush();
            s.Write(buffer.GetBuffer(), 0, (int)buffer.Position);
            s.Flush();
        }
コード例 #22
0
ファイル: Drive1541.cs プロジェクト: tustin2121/tpp-BizHawk2
        public Drive1541(int clockNum, int clockDen)
        {
            DriveRom = new Chip23128();
            _cpu     = new MOS6502X
            {
                ReadMemory      = CpuRead,
                WriteMemory     = CpuWrite,
                DummyReadMemory = CpuRead,
                PeekMemory      = CpuPeek,
                NMI             = false
            };

            _ram = new int[0x800];
            Via0 = Chip6522.Create(ViaReadClock, ViaReadData, ViaReadAtn, 8);
            Via1 = Chip6522.Create(ReadVia1PrA, ReadVia1PrB);

            _cpuClockNum      = clockNum;
            _driveCpuClockNum = clockDen * 16000000;             // 16mhz
        }
コード例 #23
0
        public Via TraerViaPorId(int idVia)
        {
            Via Via = null;

            try
            {
                var query = from it in context.Vias
                            where it.Id == idVia
                            select it;
                foreach (Via ViaLista in query)
                {
                    Via = ViaLista;
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(Via);
        }
コード例 #24
0
        /// <summary>
        /// Checks if SIP response has all required values as response line,header fields and their values.
        /// Throws Exception if not valid SIP response.
        /// </summary>
        public void Validate()
        {
            // Via: + branch prameter
            // To:
            // From:
            // CallID:
            // CSeq

            if (Via.GetTopMostValue() == null)
            {
                throw new SIP_ParseException("Via: header field is missing !");
            }
            if (Via.GetTopMostValue().Branch == null)
            {
                throw new SIP_ParseException("Via: header fields branch parameter is missing !");
            }

            if (To == null)
            {
                throw new SIP_ParseException("To: header field is missing !");
            }

            if (From == null)
            {
                throw new SIP_ParseException("From: header field is missing !");
            }

            if (CallID == null)
            {
                throw new SIP_ParseException("CallID: header field is missing !");
            }

            if (CSeq == null)
            {
                throw new SIP_ParseException("CSeq: header field is missing !");
            }

            // TODO: INVITE 2xx must have only 1 contact header with SIP or SIPS.
        }
コード例 #25
0
ファイル: TransactionAgent.cs プロジェクト: Jacfal/SipClient
        /// <summary>
        ///     Start listening.
        /// </summary>
        /// <param name="localEP"></param>
        /// <returns></returns>
        public void StartListeningAsync(IPEndPoint localEP)
        {
            _logger.Debug("Starting listener.");

            Socket listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            listenSocket.Bind(localEP);

            _via = new Via(localEP.Address.ToString(), localEP.Port, TransportProtocol);
            _cancellationTokenSource = new CancellationTokenSource();

            _logger.Info($"Listener started at {localEP.Address}:{localEP.Port}.");

            EndPoint      ie      = new IPEndPoint(IPAddress.Any, 0);
            BufferSegment segment = new BufferSegment()
            {
                Buffer = ArrayPool <byte> .Shared.Rent(1024)
            };

            Tuple <Socket, BufferSegment> container = new Tuple <Socket, BufferSegment>(listenSocket, segment);

            listenSocket.BeginReceiveFrom(segment.Buffer, 0, 1024, SocketFlags.None, ref ie, Receive, container);
        }
コード例 #26
0
ファイル: Form1.cs プロジェクト: QuocTuan1992/SFS
        private void btnOnline_Click(object sender, EventArgs e)
        {
            int index = 0; bool blConnect = false;

            foreach (LisPLC LisPLC in G.LisPLC)
            {
                // AxDBCommManager plcTemp = new AxDBCommManager();

                DBPlcId eModel = (DBPlcId)Enum.Parse(typeof(MOD), LisPLC.Mod.Replace("-", ""));

                Via eVia = LisPLC.Via;


                G.LisPLC[index].plcKey = KEYENCEs.Create(eModel, eVia, LisPLC.Para);
                // G.LisPLC[index].plcKey = KEYENCE.KEYENCEs.Connnect(LisPLC.plcKey);
                G.LisPLC[index].isConnect = G.isConnect;
                if (G.isConnect == isConnect.Disconnected)
                {
                    blConnect = false;
                }
                else
                {
                    blConnect = true;
                }
                index++;
            }
            if (blConnect == true)
            {
                btnOnline.Image = Properties.Resources.online; btnStart.Enabled = true;
            }
            else
            {
                btnOnline.Image = Properties.Resources.offline; btnStart.Enabled = false;
            }
            picMap.Invalidate();
            Refresh1 = new SFS_FV.SQL.Refresh();
        }
コード例 #27
0
        public List <Via> ObtieneVias(String pStrIdTipo)
        {
            List <Via> lstVias = new List <Via>();

            try
            {
                MUNI_INTEGRADOEntities1 objContext = new MUNI_INTEGRADOEntities1();
                var lstViasTmp = objContext.MA_VIA.Where(v => v.noTipoVia == pStrIdTipo || pStrIdTipo == null).ToList();

                foreach (MA_VIA objViaTmp in lstViasTmp)
                {
                    Via objVia = new Via();
                    objVia.IdVia  = objViaTmp.coVia;
                    objVia.Nombre = objViaTmp.noNomVia;
                    objVia.Tipo   = objViaTmp.noTipoVia;
                    lstVias.Add(objVia);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            return(lstVias);
        }
コード例 #28
0
ファイル: Message.cs プロジェクト: jgauffin/SipSharp
        /// <summary>
        /// Assign a header
        /// </summary>
        /// <param name="name">Long name, in lower case.</param>
        /// <param name="header">Header to assign</param>
        internal virtual void Assign(string name, IHeader header)
        {
            switch (name)
            {
                case "to":
                    To = ((ContactHeader) header).FirstContact;
                    break;
                case "from":
                    From = ((ContactHeader) header).FirstContact;
                    break;
                case "cseq":
                    CSeq = (CSeq) header;
                    break;
                case "via":
                    var via = (Via) header;
                    if (Via != null && Via.Items.Count > 0)
                    {
                        foreach (ViaEntry entry in via)
                            Via.Add(entry);
                    }
                    else
                        Via = via;
                    break;
            }

            Headers.Add(name.ToLower(), header);
        }
コード例 #29
0
        /// <summary>
        /// Checks if SIP request has all required values as request line,header fields and their values.
        /// Throws Exception if not valid SIP request.
        /// </summary>
        public void Validate()
        {
            // Request SIP version
            // Via: + branch prameter
            // To:
            // From:
            // CallID:
            // CSeq
            // Max-Forwards RFC 3261 8.1.1.

            if (!RequestLine.Version.ToUpper().StartsWith("SIP/2.0"))
            {
                throw new SIP_ParseException("Not supported SIP version '" + RequestLine.Version + "' !");
            }

            if (Via.GetTopMostValue() == null)
            {
                throw new SIP_ParseException("Via: header field is missing !");
            }
            if (Via.GetTopMostValue().Branch == null)
            {
                throw new SIP_ParseException("Via: header field branch parameter is missing !");
            }

            if (To == null)
            {
                throw new SIP_ParseException("To: header field is missing !");
            }

            if (From == null)
            {
                throw new SIP_ParseException("From: header field is missing !");
            }

            if (CallID == null)
            {
                throw new SIP_ParseException("CallID: header field is missing !");
            }

            if (CSeq == null)
            {
                throw new SIP_ParseException("CSeq: header field is missing !");
            }

            if (MaxForwards == -1)
            {
                // We can fix it by setting it to default value 70.
                MaxForwards = 70;
            }

            /* RFC 3261 12.1.2
             *  When a UAC sends a request that can establish a dialog (such as an INVITE) it MUST
             *  provide a SIP or SIPS URI with global scope (i.e., the same SIP URI can be used in
             *  messages outside this dialog) in the Contact header field of the request. If the
             *  request has a Request-URI or a topmost Route header field value with a SIPS URI, the
             *  Contact header field MUST contain a SIPS URI.
             */
            if (SIP_Utils.MethodCanEstablishDialog(RequestLine.Method))
            {
                if (Contact.GetAllValues().Length == 0)
                {
                    throw new SIP_ParseException(
                              "Contact: header field is missing, method that can establish a dialog MUST provide a SIP or SIPS URI !");
                }
                if (Contact.GetAllValues().Length > 1)
                {
                    throw new SIP_ParseException(
                              "There may be only 1 Contact: header for the method that can establish a dialog !");
                }
                if (!Contact.GetTopMostValue().Address.IsSipOrSipsUri)
                {
                    throw new SIP_ParseException(
                              "Method that can establish a dialog MUST have SIP or SIPS uri in Contact: header !");
                }
            }

            // TODO: Invite must have From:/To: tag

            // TODO: Check that request-Method equals CSeq method

            // TODO: PRACK must have RAck and RSeq header fields.

            // TODO: get in transport made request, so check if sips and sip set as needed.
        }
コード例 #30
0
        public bool OfferARide()
        {
            try {
                List <Via>    viaplaces = new List <Via>();
                List <string> via = new List <string>();
                string        source, destination, countPlaces, tempPlace;


                Console.WriteLine("Enter Source of Journey / Enter to Exit ..");
                source = Console.ReadLine();
                if (source.Equals(""))
                {
                    return(true);
                }

                Console.WriteLine("Enter Destination of Journey / Enter to Exit ..");
                destination = Console.ReadLine();
                if (destination.Equals(""))
                {
                    return(true);
                }

                Console.WriteLine("Enter Number of places you are covering including source and destination / Enter to Exit ..");
                countPlaces = (Console.ReadLine());


                do
                {
                    Console.WriteLine("Enter Via Places including Source and Destination in sequence / Enter to Exit ..");
                    for (int j = 0; j < Int32.Parse(countPlaces); j++)
                    {
                        tempPlace = Console.ReadLine();
                        if (tempPlace.Equals(""))
                        {
                            return(true);
                        }
                        via.Add(tempPlace);
                    }

                    if (!source.Equals(via[0]) || !destination.Equals(via[via.Count - 1]))
                    {
                        Console.WriteLine("Source and Destination are different from initial inputs. Please Enter Valid data...\n");
                        via.Clear();
                        continue;
                    }
                    break;
                } while (true);



                decimal d, c;
                string  temp;
                Via     viaobj;
                for (int j = 1; j < via.Count; j++)
                {
                    do
                    {
                        Console.WriteLine("Enter Distance Between {0} and {1} / Enter -1 to Exit..", via[j - 1], via[j]);
                        temp = Console.ReadLine();
                        if (!decimal.TryParse(temp, out d))
                        {
                            Console.WriteLine("Enter Decimal Digits! strings are not valid."); continue;
                        }
                        if (d == -1)
                        {
                            return(true);
                        }
                        break;
                    } while (true);


                    do
                    {
                        Console.WriteLine("Enter Travel cost Between {0} and {1}/Enter -1 to Exit..", via[j - 1], via[j]);
                        temp = Console.ReadLine();
                        if (!decimal.TryParse(temp, out c))
                        {
                            Console.WriteLine("Enter Decimal Digits! strings are not valid."); continue;
                        }
                        if (c == -1)
                        {
                            return(true);
                        }
                        break;
                    } while (true);

                    viaobj = new Via()
                    {
                        Source = via[j - 1], Destination = via[j], Distance = d, Price = c
                    };
                    viaplaces.Add(viaobj);
                }

                string rideInfo = RideServices.OfferRide(LoggedUser, viaplaces, source, destination);
                Console.WriteLine(rideInfo);
            }
            catch (Exception ex) {
                Console.WriteLine("Error... Enter Valid data" + ex.InnerException);
            }
            return(true);
        }
コード例 #31
0
        public LoadSQLITE()
        {
            G.LisDevice     = new List <string>();
            G.LisPLC        = new List <LisPLC>();
            G.ListGraphic   = new List <ListGraphic>();
            G.ListVariables = new List <ListVariables>();
            G.ListToolGr    = new List <ToolGr>();
            G.ListToolChart = new List <GRAPHIC.ToolChart>();
            G.ListToolTemp  = new List <ToolGr>();
            G.pPen          = new Point(0, 0);
            G.sourceSQL     = G.VariableSQL;
            DataTable dtCycleTime           = new DataTable();
            DataTable dtYield               = new DataTable();
            DataTable dtLostTime            = new DataTable();
            DataTable dtToolQua             = new DataTable();
            DataTable dtToolTime            = new DataTable();
            DataTable dtChart               = new DataTable();
            DataTable dtDevice              = new DataTable();
            DataTable dtVariable            = new DataTable();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("isCycle", isCycle.open.ToString());
            SQLITE.Update("CycleTime", dic, "", G.VariableSQL);
            dtDevice    = SQLITE.SQL_Table("*", "DEVICE", "");
            dtVariable  = SQLITE.SQL_Table("*", "Global", "");
            dtCycleTime = SQLITE.SQL_Table("*", "CycleTime", "");
            dtYield     = SQLITE.SQL_Table("*", "Yield", "");
            dtLostTime  = SQLITE.SQL_Table("*", "LostTime", "");
            G.sourceSQL = G.ToolSQL;
            // SQLITE.DeleteAll("CHART");
            //   SQLITE.DeleteAll("Quantity");
            //   SQLITE.DeleteAll("Time");
            //SQLITE.DeleteAll("TOOL");
            //SQLITE.Delete("TOOL", "TYPE='Yield'");
            dtToolQua   = SQLITE.SQL_Table("*", "Quantity", "");
            dtToolTime  = SQLITE.SQL_Table("*", "Time", "");
            G.sourceSQL = G.ChartSQL;
            dtChart     = SQLITE.SQL_Table("*", "CHART", "");
            G.sourceSQL = G.VariableSQL;
            foreach (DataRow DataRow in dtDevice.Rows)
            {
                AxDBCommManager plcTemp = new AxDBCommManager();

                DBPlcId eModel = (DBPlcId)Enum.Parse(typeof(MOD), DataRow[3].ToString().Replace("-", ""));

                Via eVia = (Via)Enum.Parse(typeof(Via), DataRow[4].ToString());


                //   plcTemp = KEYENCEs.Create(eModel, eVia, DataRow[5].ToString());
                if (G.isConnect == isConnect.Disconnected)
                {
                    blConnect = false;
                }
                Image picModel, picVia;

                picModel = Image.FromFile(DataRow[3].ToString() + ".png");
                picVia   = Image.FromFile(DataRow[4].ToString() + ".png");
                G.LisPLC.Add(new LisPLC(DataRow[0].ToString(), DataRow[2].ToString(), DataRow[3].ToString(), eVia, DataRow[5].ToString(), plcTemp, G.isConnect, picModel, picVia, G.pPen));
                G.pPen.X += G.spicReview.X + 10;
                if (G.pPen.X + G.spicReview.X >= 10)
                {
                    G.pPen.Y += G.spicReview.Y + 50;
                    G.pPen.X  = 0;
                }
            }
            foreach (DataRow DataRow in dtVariable.Rows)
            {
                isBit   isBit   = (isBit)Enum.Parse(typeof(isBit), DataRow[6].ToString());
                typeBit typeBit = (typeBit)Enum.Parse(typeof(typeBit), DataRow[4].ToString());
                int     i       = 0;
                int     index   = 0;
                foreach (DataRow DataRow1 in dtDevice.Rows)
                {
                    if (DataRow1[0].ToString() == DataRow[1].ToString())
                    {
                        index = i;
                    }
                    i++;
                }
                G.ListVariables.Add(new ListVariables(DataRow[0].ToString(), G.LisPLC[index], DataRow[2].ToString(), DataRow[3].ToString(), DataRow[5].ToString(), isBit, typeBit, typeVariable2.Global));
            }
            foreach (DataRow DataRow in dtCycleTime.Rows)
            {
                int i     = 0;
                int index = 0;
                foreach (DataRow DataRow1 in dtVariable.Rows)
                {
                    if (DataRow1[0].ToString() == DataRow[1].ToString())
                    {
                        index = i;
                    }
                    i++;
                }

                G.ListVariables.Add(new ListVariables(new CycleTime(DataRow[0].ToString(), G.ListVariables[index], DataRow[2].ToString(), int.Parse(DataRow[3].ToString()), int.Parse(DataRow[4].ToString()), new DateTime(), new DateTime(), isCycle.open, false), typeVariable2.CycleTime));
                //  LoadData("CycleTime");
            }
            foreach (DataRow DataRow in dtLostTime.Rows)
            {
                int i     = 0;
                int index = 0;
                foreach (DataRow DataRow1 in dtVariable.Rows)
                {
                    if (DataRow1[0].ToString() == DataRow[1].ToString())
                    {
                        index = i;
                    }
                    i++;
                }
                G.ListVariables.Add(new ListVariables(new LostTime(DataRow[0].ToString(), G.ListVariables[index], DataRow[2].ToString(), int.Parse(DataRow[3].ToString()), int.Parse(DataRow[4].ToString()), new DateTime(), new DateTime(), isLost.open, false), typeVariable2.LostTime));
            }

            foreach (DataRow DataRow in dtYield.Rows)
            {
                int    i = 0;
                int    index = 0;
                string ListOKsql = "", ListNGsql = "";
                ListOKsql = DataRow[2].ToString();
                ListNGsql = DataRow[3].ToString();
                string[]             ListOKsplit = ListOKsql.Split(',');
                string[]             ListNGsplit = ListNGsql.Split(',');
                List <ListVariables> ListYieldOK = new List <ListVariables>();
                List <ListVariables> ListYieldNG = new List <ListVariables>();
                foreach (ListVariables ListVariables in G.ListVariables)
                {
                    foreach (string ListOK in ListOKsplit)
                    {
                        if (ListVariables.Name == ListOK)
                        {
                            ListYieldOK.Add(ListVariables);
                        }
                    }
                    foreach (string ListNG in ListNGsplit)
                    {
                        if (ListVariables.Name == ListNG)
                        {
                            ListYieldNG.Add(ListVariables);
                        }
                    }
                }
                foreach (DataRow DataRow1 in dtVariable.Rows)
                {
                    if (DataRow1[0].ToString() == DataRow[1].ToString())
                    {
                        index = i;
                    }
                    i++;
                }
                //Color red = Color.FromName("Red");
                G.ListVariables.Add(new ListVariables(new Yield(DataRow[0].ToString(), DataRow[1].ToString(), ListYieldOK, ListYieldNG), typeVariable2.Yield));
            }
            foreach (DataRow DataRow in dtToolQua.Rows)
            {
                var    cvt   = new FontConverter();
                String color = DataRow[5].ToString();
                Font   fonts = new Font("Arial", 10);
                try
                {
                    fonts = cvt.ConvertFromString(DataRow[6].ToString()) as Font;
                }
                catch (Exception)
                {
                }
                String Fcolor = DataRow[7].ToString();
                color = color.Replace("Color [A=", "");
                color = color.Replace("]", "");
                color = color.Replace("Color [", "");
                color = color.Replace("R=", "");
                color = color.Replace("G=", "");
                color = color.Replace("B=", "");

                Fcolor = Fcolor.Replace("Color ", "");
                Fcolor = Fcolor.Replace("]", "");
                Fcolor = Fcolor.Replace("[", "");



                string[] splColor = color.Split(',');
                // string[] splFcolor = Fcolor.Split(',');

                SolidBrush backcolor;
                try
                {
                    backcolor = new SolidBrush(Color.FromArgb(int.Parse(splColor[0]), int.Parse(splColor[1]), int.Parse(splColor[2]), int.Parse(splColor[3])));
                }
                catch (Exception)
                {
                    backcolor = new SolidBrush(Color.FromName(color));
                }
                Color      fontColor = Color.FromName(Fcolor);
                FontDialog fontDlg   = new FontDialog();
                fontDlg.Color = fontColor;
                fontDlg.Font  = fonts;
                int i     = 0;
                int index = 0;
                foreach (ListVariables ListVariables in G.ListVariables)
                {
                    if (ListVariables.Name != null)
                    {
                        if (ListVariables.Name.ToString() == DataRow[2].ToString())
                        {
                            index = i;
                        }
                    }
                    else
                    {
                        if (ListVariables.Yield != null)
                        {
                            if (ListVariables.Yield.Name.ToString() == DataRow[2].ToString())
                            {
                                index = i;
                            }
                        }
                    }
                    i++;
                }
                //string Name,string sShow,TypeGr TypeGr,ListVariables ListVariables, Brush brFont,Color BackColor,int sizeFont,int defaut,Font font,bool isChar,bool isVal,bool isConst)
                TypeGr typeGr = (TypeGr)Enum.Parse(typeof(TypeGr), DataRow[1].ToString());
                G.ListToolGr.Add(new ToolGr(DataRow[0].ToString(), DataRow[3].ToString(), typeGr, G.ListVariables[index], new SolidBrush(fontDlg.Color), backcolor, int.Parse(DataRow[4].ToString()), int.Parse(DataRow[11].ToString()), fontDlg.Font, Boolean.Parse(DataRow[8].ToString()), Boolean.Parse(DataRow[9].ToString()), Boolean.Parse(DataRow[10].ToString())));
            }
            foreach (DataRow DataRow in dtToolTime.Rows)
            {
                var    cvt   = new FontConverter();
                String color = DataRow[5].ToString();
                Font   fonts = new Font("Arial", 10);
                try
                {
                    fonts = cvt.ConvertFromString(DataRow[6].ToString()) as Font;
                }
                catch (Exception)
                {
                }

                String Fcolor = DataRow[7].ToString();
                color = color.Replace("Color [A=", "");
                color = color.Replace("]", "");
                color = color.Replace("Color [", "");
                color = color.Replace("R=", "");
                color = color.Replace("G=", "");
                color = color.Replace("B=", "");

                Fcolor = Fcolor.Replace("Color ", "");
                Fcolor = Fcolor.Replace("]", "");
                Fcolor = Fcolor.Replace("[", "");



                string[] splColor = color.Split(',');
                // string[] splFcolor = Fcolor.Split(',');

                SolidBrush backcolor;
                try
                {
                    backcolor = new SolidBrush(Color.FromArgb(int.Parse(splColor[0]), int.Parse(splColor[1]), int.Parse(splColor[2]), int.Parse(splColor[3])));
                }
                catch (Exception)
                {
                    backcolor = new SolidBrush(Color.FromName(color));
                }
                Color      fontColor = Color.FromName(Fcolor);
                FontDialog fontDlg   = new FontDialog();
                fontDlg.Color = fontColor;
                fontDlg.Font  = fonts;
                int i     = 0;
                int index = 0;
                foreach (ListVariables ListVariables in G.ListVariables)
                {
                    if (ListVariables.CycleTime != null)
                    {
                        if (ListVariables.CycleTime.Name.ToString() == DataRow[2].ToString())
                        {
                            index = i;
                        }
                    }
                    else
                    {
                        //  if (ListVariables.LostTime.Name.ToString() == DataRow[2].ToString())
                        //  {

                        //     index = i;
                        //  }
                    }
                    i++;
                }
                //string Name,string sShow,TypeGr TypeGr,ListVariables ListVariables, Brush brFont,Color BackColor,int sizeFont,int defaut,Font font,bool isChar,bool isVal,bool isConst)
                TypeGr typeGr = (TypeGr)Enum.Parse(typeof(TypeGr), DataRow[1].ToString());
                G.ListToolGr.Add(new ToolGr(DataRow[0].ToString(), DataRow[3].ToString(), typeGr, G.ListVariables[index], new SolidBrush(fontDlg.Color), backcolor, Convert.ToDouble(DataRow[12].ToString()), fontDlg.Font, Boolean.Parse(DataRow[8].ToString()), Boolean.Parse(DataRow[9].ToString()), Boolean.Parse(DataRow[10].ToString())));
            }
            List <ToolChart> ToolChart = new List <GRAPHIC.ToolChart>();
            List <string>    ListNameChart = new List <string>();
            string           nameChart = ""; DateTime dtBegin = new DateTime(); int Reset = 0, Update = 0; Point pOffset = new Point();
            int indexRow = 0;

            foreach (DataRow DataRow in dtChart.Rows)
            {
                if (DataRow[0].ToString() != nameChart && nameChart != "")
                {
                    G.ListGraphic.Add(new ListGraphic(nameChart, ToolChart, G.ListData, dtBegin, Reset, Update, int.Parse(DataRow[5].ToString()), pOffset, int.Parse(DataRow[8].ToString()), bool.Parse(DataRow[9].ToString())));
                    ToolChart = new List <GRAPHIC.ToolChart>();
                }

                //  ToolChart.Clear();
                int i     = 0;
                int index = 0;
                foreach (ToolGr ToolGr in G.ListToolGr)
                {
                    if (DataRow[1].ToString() == ToolGr.Name)
                    {
                        string[] ChartPoint = DataRow[6].ToString().Split(',');
                        ToolChart.Add(new ToolChart(ToolGr, new Point(int.Parse(ChartPoint[0]), int.Parse(ChartPoint[1]))));
                    }
                    i++;
                }
                G.ListData = new List <List <ListData> >();
                dtBegin    = DateTime.Parse(DataRow[2].ToString());
                dtBegin.AddYears(DateTime.Now.Year - dtBegin.Year);
                dtBegin.AddMonths(DateTime.Now.Month - dtBegin.Month);
                dtBegin.AddDays(DateTime.Now.Day - dtBegin.Day);
                Reset           = int.Parse(DataRow[3].ToString());
                Update          = int.Parse(DataRow[4].ToString());
                G.ListToolChart = ToolChart;
                UpdateGraphic(Reset, Update);


                string[] pOffsetSplit = DataRow[7].ToString().Split(',');
                pOffset = new Point(int.Parse(pOffsetSplit[0]), int.Parse(pOffsetSplit[1]));

                nameChart = DataRow[0].ToString();
                indexRow++;
                if (indexRow == dtChart.Rows.Count)
                {
                    G.ListGraphic.Add(new ListGraphic(nameChart, ToolChart, G.ListData, dtBegin, Reset, Update, int.Parse(DataRow[5].ToString()), pOffset, int.Parse(DataRow[8].ToString()), bool.Parse(DataRow[9].ToString())));
                }
            }
            G.sourceSQL  = G.DATASQL;
            G.sPicAvatar = new List <string>();
            G.sPicAvatar = SQLITE.SQL_List(0, SQLITE.SQL_Table("*", "PIC", ""));
        }
コード例 #32
0
ファイル: TransactionAgent.cs プロジェクト: Jacfal/SipClient
        private void Receive(IAsyncResult result)
        {
            Tuple <Socket, BufferSegment> container = (Tuple <Socket, BufferSegment>)result.AsyncState;
            Socket        listenSocket = container.Item1;
            BufferSegment bs           = container.Item2;

            EndPoint clientEp  = new IPEndPoint(IPAddress.Any, 0);
            int      recvBytes = listenSocket.EndReceiveFrom(result, ref clientEp);

            string recvMsg;

            while (true)
            {
                _logger.Debug("Recieving new bunch of data from socket.");
                recvMsg = Encoding.ASCII.GetString(bs.Buffer, 0, recvBytes);

                if (ParsingHelpers.IsSipMessageComplete(recvMsg))
                {
                    break;
                }
                throw new NotImplementedException("Message wasn't full recieved at one method calling.");
            }

            // process sip message
            SipMessageType messageType = ParsingHelpers.GetSipMessageType(recvMsg);

            SipMessage sipMessage;

            if (messageType == SipMessageType.Request)
            {
                throw new NotImplementedException("SIP REQUEST decoder not yet implemented.");
            }
            else if (messageType == SipMessageType.Response)
            {
                sipMessage = SipResponse.CreateSipResponse(recvMsg);
            }
            else
            {
                _logger.Warn($"Cann't recognize if incomming SIP message is type of REQUEST or RESPONSE:\n {recvMsg}");
                throw new ArgumentException("Incomming sip message is invalid... unknown message type.");
            }
            _logger.Debug($"New sip message received:\n{sipMessage}");

            Via transactionInfo = sipMessage.Headers.Via.First();

            if (transactionInfo.IpAddress == ListeningOnIp)
            {
                // handle local transaction
                bool transactionResult = Transactions.TryGetValue(transactionInfo.Branch, out Transaction transaction);
                if (!transactionResult)
                {
                    throw new NotImplementedException($"Cann't find transaction with transaction id {transactionInfo.Branch}.");
                }

                if (transaction.SetResponse((SipResponse)sipMessage))
                {
                    _logger.Info($"Transacion {transactionInfo.Branch} complete.");
                    OnTransactionComplete(transaction);
                }
                else
                {
                    throw new NotImplementedException("Provisional response handling not yet implemented.");
                }
            }
            else
            {
                throw new NotImplementedException("Transaction is determined for different endpoint.");
            }
        }