private Socket _mSocket; //TCP connection to device #endregion Fields #region Constructors /// <summary> /// Creates a PLC object with all the parameters needed for connections. /// For S7-1200 and S7-1500, the default is rack = 0 and slot = 0. /// You need slot > 0 if you are connecting to external ethernet card (CP). /// For S7-300 and S7-400 the default is rack = 0 and slot = 2. /// </summary> /// <param name="cpu">CpuType of the plc (select from the enum)</param> /// <param name="ip">Ip address of the plc</param> /// <param name="rack">rack of the plc, usually it's 0, but check in the hardware configuration of Step7 or TIA portal</param> /// <param name="slot">slot of the CPU of the plc, usually it's 2 for S7300-S7400, 0 for S7-1200 and S7-1500. /// If you use an external ethernet card, this must be set accordingly.</param> public Plc(CpuType cpu, string ip, Int16 rack, Int16 slot) { IP = ip; CPU = cpu; Rack = rack; Slot = slot; }
/// <summary> /// Creates a PLC object with all the parameters needed for connections. /// For S7-1200 and S7-1500, the default is rack = 0 and slot = 0. /// You need slot > 0 if you are connecting to external ethernet card (CP). /// For S7-300 and S7-400 the default is rack = 0 and slot = 2. /// </summary> /// <param name="cpu"></param> /// <param name="ip"></param> /// <param name="rack"></param> /// <param name="slot"></param> /// <param name="name"></param> /// <param name="tag"></param> public Plc(CpuType cpu, string ip, Int16 rack, Int16 slot, string name = "", object tag = null) { IP = ip; CPU = cpu; Rack = rack; Slot = slot; Name = name; Tag = tag; }
public void Initialize(int scanline, int cycle, CpuType cpuType) { _scanline = scanline; _cycle = cycle; _cpuType = cpuType; this.nudScanline.Value = _scanline; this.nudCycle.Value = _cycle; RefreshSettings(); }
public static bool EnableDisableBreakpoint(AddressInfo info, CpuType cpuType) { Breakpoint breakpoint = BreakpointManager.GetMatchingBreakpoint(info, cpuType); if (breakpoint != null) { breakpoint.SetEnabled(!breakpoint.Enabled); return(true); } return(false); }
public FormMeasure() { InitializeComponent(); CpuType cpu = (CpuType)Enum.Parse(typeof(CpuType), Settings.Default.CpuType); string ip = Settings.Default.IP; short rack = Convert.ToInt16(Settings.Default.Rack); short slot = Convert.ToInt16(Settings.Default.Slot); plc = new Plc(cpu, ip, rack, slot); connection = new SQLiteConnection("data source=" + dbfile); //connection = new SQLiteConnection(@"data source=./mukavemet.db"); cbProduct.DataSource = Settings.Default.ProductList; cbUser.DataSource = Settings.Default.UserList; FlipButtonIcon(button1); ///////////////////////////////////////////////////////////////////////// var mapper = Mappers.Xy <MeasureModel>() .X(model => model.Time.Ticks) .Y(model => model.Value); Charting.For <MeasureModel>(mapper); crtVls = new ChartValues <MeasureModel>(); cartesianChart1.Series = new SeriesCollection { new LineSeries { Values = crtVls, PointGeometrySize = 4, StrokeThickness = 2, Fill = new LinearGradientBrush( System.Windows.Media.Color.FromArgb(0xcc, 0xff, 0xff, 0xff), System.Windows.Media.Color.FromArgb(0x64, 0xff, 0xff, 0xff), 90), Stroke = new SolidColorBrush( System.Windows.Media.Color.FromArgb(0xff, 0xff, 0xff, 0xff)) }, }; cartesianChart1.AxisX.Add(new Axis { // DisableAnimations = true, LabelFormatter = value => new TimeSpan((long)value) .TotalMilliseconds.ToString() + "ms", Separator = new Separator { Step = TimeSpan.FromMilliseconds(500).Ticks } }); cartesianChart1.AxisX[0].MaxValue = TimeSpan.FromMilliseconds(100).Ticks; cartesianChart1.AxisX[0].MinValue = TimeSpan.FromMilliseconds(0).Ticks; cartesianChart1.AnimationsSpeed = TimeSpan.FromMilliseconds(20); //////////////////////////////////////////////////////////////////// }
public static CodeLineData GetDisassemblyLineData(CpuType type, UInt32 lineIndex) { InteropCodeLineData data = new InteropCodeLineData(); data.Comment = new byte[1000]; data.Text = new byte[1000]; data.ByteCode = new byte[4]; DebugApi.GetDisassemblyLineDataWrapper(type, lineIndex, ref data); return(new CodeLineData(data, type)); }
private void button1_Click(object sender, EventArgs e) { try { CpuType ty = CpuType.S71200; if (!string.IsNullOrEmpty(comboBox1.Text)) { Enum.TryParse <CpuType>(comboBox1.Text, out ty); } device = new Plc(ty, textip.Text, Convert.ToInt16(numrank.Value), Convert.ToInt16(numslot.Value)); device.Open(); if (device.IsConnected && device.IsAvailable) { label1.Text = "Bağlantı başarılı"; } else { label1.Text = string.Format("Bağlanılamadı IsConnected:{0}, IsAvailable:{1}", device.IsConnected, device.IsAvailable); } } catch (Exception exc) { label1.Text = string.Format("Bağlantı sağlanamadı: {0}", exc.Message); label2.Text = exc.StackTrace; } //timer1.Enabled = true; /* * PLCPin pin1 = new PLCPin(391, "25100125"); * pin1.ElmaslamaAdres = new PinAdres() { Ad = "KOYO_YANAK_025125_ELMASLAMA_TIMESPAN", Adres = "DB1.DBD16" }; * pin1.BeklemeAdres = new PinAdres() { Ad = "KOYO_YANAK_025125_BEKLEME_TIMESPAN", Adres = "DB1.DBD32" }; * //PLCPin pin2 = new PLCPin(948, "25100129"); * //pin2.ElmaslamaAdres = new PinAdres() { Ad = "NISSEI_YANAK_025129_ELMASLAMA_TIMESPAN", Adres = "DB1.DBD20" }; * //pin2.BeklemeAdres = new PinAdres() { Ad = "NISSEI_YANAK_025129_BEKLEME_TIMESPAN", Adres = "DB1.DBD36" }; * //PLCPin pin3 = new PLCPin(968, "25200240"); * //pin3.ElmaslamaAdres = new PinAdres() { Ad = "SMSB_PUNTASIZ_025240_BEKLEME_TIMESPAN", Adres = "DB1.DBD40" }; * //pin3.BeklemeAdres = new PinAdres() { Ad = "SMSB_PUNTASIZ_025240_ELMASLAMA_TIMESPAN", Adres = "DB1.DBD24" }; * //PLCPin pin4 = new PLCPin(223, "25200222"); * //pin4.ElmaslamaAdres = new PinAdres() { Ad = "KOYO_PUNTASIZ_025222_ELMASLAMA_TIMESPAN", Adres = "DB1.DBD28" }; * //pin4.BeklemeAdres = new PinAdres() { Ad = "KOYO_PUNTASIZ_025222_BEKLEME_TIMESPAN", Adres = "DB1.DBD44" }; * PLCDevice device = new PLCDevice("192.168.145.2", "YP_HAT_2"); * device.Add(pin1); * //device.Add(pin2); * //device.Add(pin3); * //device.Add(pin4); * device.ConnectionClosed += device_ConnectionClosed; * device.Open(); * devices.Add(device); * devices.TrimExcess(); */ }
public frmDebugger(CpuType cpuType) { InitializeComponent(); _cpuType = cpuType; if (DesignMode) { return; } }
static public void Attach(int process, CpuType cpu) { if (!IsRunning) { Start(cpu); SendSettings(BreakOnException); watchExtressions.ForEach(x => DebuggerServer.AddWatchExpression(x)); Attach(process); EntryBreakpointFile = null; } }
private void ConnBT_Click_1(object sender, EventArgs e) { CpuType cpu = (CpuType)Enum.Parse(typeof(CpuType), CpyTypeCB.SelectedValue.ToString()); plc = new Plc(cpu, IPaddressTB.Text, Convert.ToInt16(RackTB.Text), Convert.ToInt16(SlotTB.Text)); plc.Open(); if (plc.IsConnected) { StatConnTB.Text = "Connected"; } }
public SymbolCodeDataProvider(CpuType type, ISymbolProvider symbolProvider, SourceFileInfo file) { //_prgRom = DebugApi.GetMemoryState(SnesMemoryType.PrgRom); _cpuType = type; _symbolProvider = symbolProvider; _file = file; _lineCount = file.Data.Length; string filename = file.Name.ToLower(); _isC = filename.EndsWith(".h") || filename.EndsWith(".c"); }
static public void Start(string app, string args, CpuType cpu) { if (!IsRunning) { lastLocation = null; Start(cpu); SendSettings(BreakOnException); watchExtressions.ForEach(x => DebuggerServer.AddWatchExpression(x)); Run(app, args ?? ""); EntryBreakpointFile = null; } }
public static void CloseWindows(CpuType cpuType) { List <Form> openedWindows = new List <Form>(_openedWindows); foreach (Form frm in openedWindows) { if (frm is IDebuggerWindow && ((IDebuggerWindow)frm).CpuType == cpuType) { frm.Close(); } } }
//IP vecchio "192.168.1.5" static public void Init(string variablePath, string ip = "192.168.2.104", CpuType cpu = CpuType.S71500) { plc = new Plc(cpu, ip, 0, 1); var result = plc.Open(); if (result != ErrorCode.NoError) { throw new Exception("Error: " + plc.LastErrorCode + "\n" + plc.LastErrorString); } ReadVariable(variablePath); }
/// <summary> /// Konstruktor klasy PLCMapper z ręcznym przekazaniem wartości parametrów. Pobiera zmienne potrzebne do rozpoczęcia komunikacji, inicjuje mapę zmiennych, rozpoczyna działanie timera. /// </summary> /// <param name="moduleID">ID modułu</param> /// <param name="moduleName">nazwa modułu</param> /// <param name="ipAddress">adres IP sterownika</param> /// <param name="communicationBit">bit komunikacyjny</param> /// <param name="moduleType">typ modułu</param> /// <param name="plcType">typ plc</param> /// <param name="slot">gniazdo</param> /// <param name="rack">szyna</param> public PLCMapper(int moduleID, string moduleName, IPAddress ipAddress, string communicationBit, ModuleTypeEnum moduleType, CpuType plcType, int slot, int rack) : base(moduleID, moduleName, ipAddress, communicationBit, moduleType) { CpuType cpuType = plcType; unchecked //żeby nie wyrzucało błędu przepełnienia przy rzutowaniu int na short { short sl = (short)slot; short rk = (short)rack; this.plc = new Plc(cpuType, this.IPAddress.ToString(), rk, sl); //inicjowanie obiektu typu S7.Net.PLC - potrzebny do komunikacji } this.initializeMap(); //inicjowanie mapy zmiennych (musi być wykonana po utworzeniu obiektu dla zmiennej plc this.startTimer(); //uruchamianie timera odświeżającego zmapowane zmienne }
public frmAssembler(CpuType?cpuType = null, string code = "", int startAddress = 0, int blockLength = 0) { if (cpuType != null) { _cpuType = cpuType.Value; } else { _cpuType = EmuApi.GetRomInfo().CoprocessorType == CoprocessorType.Gameboy ? CpuType.Gameboy : CpuType.Cpu; } if (_cpuType == CpuType.Sa1) { _cpuType = CpuType.Cpu; } InitializeComponent(); txtCode.ForeColor = Color.Black; AssemblerConfig cfg = ConfigManager.Config.Debug.Assembler; RestoreLocation(cfg.WindowLocation, cfg.WindowSize); txtCode.Font = new Font(cfg.FontFamily, cfg.FontSize, cfg.FontStyle); txtCode.Zoom = cfg.Zoom; UpdateCodeHighlighting(); _initialCode = code; _startAddress = startAddress; _blockLength = blockLength; ctrlHexBox.Font = new Font(BaseControl.MonospaceFontFamily, 10, FontStyle.Regular); ctrlHexBox.SelectionForeColor = Color.White; ctrlHexBox.SelectionBackColor = Color.FromArgb(31, 123, 205); ctrlHexBox.InfoBackColor = Color.FromArgb(235, 235, 235); ctrlHexBox.InfoForeColor = Color.Gray; ctrlHexBox.Width = ctrlHexBox.RequiredWidth; ctrlHexBox.ByteProvider = new StaticByteProvider(new byte[0]); if (_cpuType == CpuType.Gameboy) { txtStartAddress.MaxLength = 4; txtStartAddress.Text = _startAddress.ToString("X4"); } else { txtStartAddress.Text = _startAddress.ToString("X6"); } }
public frmBreakIn(CpuType cpuType) { InitializeComponent(); _cpuType = cpuType; DebuggerInfo cfg = ConfigManager.Config.Debug.Debugger; nudCount.Value = cfg.BreakInCount; radCpuInstructions.Checked = cfg.BreakInMetric == BreakInMetric.CpuInstructions; radPpuCycles.Checked = cfg.BreakInMetric == BreakInMetric.PpuCycles; radScanlines.Checked = cfg.BreakInMetric == BreakInMetric.Scanlines; radFrames.Checked = cfg.BreakInMetric == BreakInMetric.Frames; }
private static ICpuFactory GetFactory(CpuType type) { switch (type) { case CpuType.Amd: return(new AmdFactory()); case CpuType.Intel: return(new IntelFactory()); default: throw new EntryPointNotFoundException(); } }
public void SelectCPU(CpuType cpuType) { _driver.WaitForElementIsVisible(Filter); var proc = _driver.GetElement(ShowOtherCPU); _driver.Scroll((proc.Location.Y).ToString()); if (!_driver.CheckClassForElement(FilterPopoverVisible, "schema-filter-popover_visible")) { _driver.Click(ShowOtherCPU); } _driver.WaitForElementIsVisible(FilterPopoverVisible); _driver.Click(CreateOrderLocator(cpuType)); WaitComplitePrice(); }
public static void OpenAssembler(CpuType cpuType, string code = "", int startAddress = 0, int blockLength = 0) { if (_openedWindows.Count == 0) { DebugWorkspaceManager.GetWorkspace(); } frmAssembler frm = new frmAssembler(cpuType, code, startAddress, blockLength); frm.Icon = Properties.Resources.Chip; _openedWindows.Add(frm); frm.FormClosed += Debugger_FormClosed; frm.Show(); }
public static frmDebugger OpenDebugger(CpuType type) { switch (type) { case CpuType.Cpu: return((frmDebugger)OpenDebugWindow(DebugWindow.Debugger)); case CpuType.Spc: return((frmDebugger)OpenDebugWindow(DebugWindow.SpcDebugger)); case CpuType.Sa1: return((frmDebugger)OpenDebugWindow(DebugWindow.Sa1Debugger)); case CpuType.Gsu: return((frmDebugger)OpenDebugWindow(DebugWindow.GsuDebugger)); } throw new Exception("Invalid CPU type"); }
/// <summary> /// Generates a CpuDef that best matches the parameters. /// </summary> /// <param name="type">Specific CPU we want.</param> /// <param name="includeUndocumented">Set to true if "undocumented" opcodes should /// be included in the definition.</param> /// <returns>Best CpuDef.</returns> public static CpuDef GetBestMatch(CpuType type, bool includeUndocumented) { // Pretty much everything boils down to a 6502, 65C02, or 65816. // The Rockwell R65C02, described in an appendix in Eyes & Lichty, doesn't, // and would need its own CpuDef. CpuDef cpuDef; switch (type) { case CpuType.Cpu65802: case CpuType.Cpu65816: case CpuType.Cpu5A22: cpuDef = Cpu65816; break; case CpuType.Cpu65C02: cpuDef = Cpu65C02; break; default: cpuDef = Cpu6502; break; } cpuDef.GenerateCycleCounts(); // If we don't want undocumented opcodes, strip them out of the definition. // Entries are replaced with OpInvalid. if (!includeUndocumented) { CpuDef stripped = new CpuDef(cpuDef); for (int i = 0; i < 256; i++) { if (cpuDef.mOpDefs[i].IsUndocumented) { stripped.mOpDefs[i] = OpDef.OpInvalid; } else { stripped.mOpDefs[i] = cpuDef.mOpDefs[i]; } } cpuDef = stripped; } cpuDef.HasUndocumented = includeUndocumented; return(cpuDef); }
/// <summary> /// Konstruktor klasy PLCMapper z pobraniem danych z obiektu typu ComponentsTable (pobieranego przez entity framework z SQLa. Pobiera zmienne potrzebne do rozpoczęcia komunikacji, inicjuje mapę zmiennych, rozpoczyna działanie timera. /// </summary> /// <param name="module">Obiekt typu ComponentsTable przechowujący dane na temat modułu ze sterownika PLC</param> public PLCMapper(SQLConnection.ComponentsTable module) : base(module) { establishingConnection = false; CpuType cpuType = ModuleType.ToS7CpuType(); unchecked //żeby nie wyrzucało błędu przepełnienia przy rzutowaniu int na short { short sl = Convert.ToInt16(module.Slot); short rk = Convert.ToInt16(module.Rack); plc = new Plc(cpuType, this.IPAddress.ToString(), rk, sl); //inicjowanie obiektu typu S7.Net.PLC - potrzebny do komunikacji } this.initializeMap(); //inicjowanie mapy zmiennych (musi być wykonana po utworzeniu obiektu dla zmiennej plc this.startTimer(); //uruchamianie timera odświeżającego zmapowane zmienne }
public static DebugEventInfo[] GetDebugEvents(CpuType cpuType, EventViewerDisplayOptions options) { UInt32 maxEventCount = GetDebugEventCount(cpuType, options); DebugEventInfo[] debugEvents = new DebugEventInfo[maxEventCount]; DebugApi.GetDebugEventsWrapper(cpuType, debugEvents, ref maxEventCount); if (maxEventCount < debugEvents.Length) { //Remove the excess from the array if needed Array.Resize(ref debugEvents, (int)maxEventCount); } return(debugEvents); }
public MachHeader(byte[] buffer, int offset) { uint magic = BigEndianConverter.ToUInt32(buffer, offset); m_is64BitHeader = (magic == MachO64BitLittleEndianSignature); CpuType = (CpuType)LittleEndianConverter.ToUInt32(buffer, offset + 4); CpuSubType = LittleEndianConverter.ToUInt32(buffer, offset + 8); FileType = (FileType)LittleEndianConverter.ToUInt32(buffer, offset + 12); NumberOfLoadCommands = LittleEndianConverter.ToUInt32(buffer, offset + 16); SizeOfLoadCommands = LittleEndianConverter.ToUInt32(buffer, offset + 20); Flags = (MachHeaderFlags)LittleEndianConverter.ToUInt32(buffer, offset + 24); if (m_is64BitHeader) { Reserved = LittleEndianConverter.ToUInt32(buffer, offset + 28); } }
public static int GetAddressSize(this CpuType cpuType) { switch (cpuType) { case CpuType.Cpu: return(6); case CpuType.Spc: return(4); case CpuType.Sa1: return(6); case CpuType.Gsu: return(6); default: throw new Exception("Invalid CPU type"); } }
public s7Plc(string name, CpuType cputype, string ip, Int16 rack, Int16 slot) : base(cputype, ip, rack, slot) { this.name = name; //初始化定时器 CycleTimer = new System.Timers.Timer(5000); CycleTimer.Elapsed += new System.Timers.ElapsedEventHandler(cycleEvent); CycleTimer.AutoReset = true; CycleTimer.Enabled = false; //初始化变量列表 varlist = new List <s7plcVarItem>(); //初始化TreeNode Node = new TreeNode(); Node.Name = this.name; Node.Text = this.name + ":" + this.IP; Node.Tag = this; }
public static SnesMemoryType ToMemoryType(this CpuType cpuType) { switch (cpuType) { case CpuType.Cpu: return(SnesMemoryType.CpuMemory); case CpuType.Spc: return(SnesMemoryType.SpcMemory); case CpuType.Sa1: return(SnesMemoryType.Sa1Memory); case CpuType.Gsu: return(SnesMemoryType.GsuMemory); default: throw new Exception("Invalid CPU type"); } }
public PLCommunication(string ipAddress, string cput, string tagname, string dtString, int elemCount, bool writeToPlc, string valToWrite) { this.ipAddress = ipAddress; // cpu type format if (cput.Equals("LGX")) { this.cput = CpuType.LGX; } else if (cput.Equals("SLC")) { this.cput = CpuType.SLC; } else if (cput.Equals("PLC5")) { this.cput = CpuType.PLC5; } this.tagname = tagname; this.dtString = dtString; // data type format this.dtString = dtString; if (this.dtString == "Int16") { this.dtInt = DataType.Int16; } else if (this.dtString == "Int8") { this.dtInt = DataType.Int8; } else if (dtString == "Int32") { this.dtInt = DataType.Int32; } else if (dtString == "Float32") { this.dtInt = DataType.Float32; } else if (dtString == "String") { this.dtInt = DataType.String; } this.writeToPlc = writeToPlc; this.elemCount = elemCount; this.valToWrite = valToWrite; }
private void btnConnect_Click(object sender, EventArgs e) { try { CpuType cpuType = (CpuType)Enum.Parse(typeof(CpuType), cboxCPUType.SelectedValue.ToString()); string ipAddress = txtIPAddress.Text; short rack = short.Parse(txtRack.Text); short slot = short.Parse(txtSlot.Text); plc = new Plc(cpuType, ipAddress, rack, slot); errorState = plc.Open(); btnConnect.Enabled = false; } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void Connect(string CpuType, string IpAddress, string Rack, String Slot) { try { CpuType cpuType = (CpuType)Enum.Parse(typeof(CpuType), (string)(CpuType)); string ipAddress = IpAddress; short rack = short.Parse(Rack); short slot = short.Parse(Slot); plc = new Plc(cpuType, ipAddress, rack, slot); plc.Open(); //btnConnect.Enabled = false; } catch (S7.Net.PlcException ex) { MessageBox.Show(ex.Message + ex.ErrorCode, "Information"); } }
public List<WatchValueInfo> GetWatchContent(CpuType cpuType, List<WatchValueInfo> previousValues) { WatchFormatStyle defaultStyle = ConfigManager.Config.Debug.Debugger.WatchFormat; int defaultByteLength = 1; if(defaultStyle == WatchFormatStyle.Signed) { defaultByteLength = 4; } var list = new List<WatchValueInfo>(); for(int i = 0; i < _watchEntries.Count; i++) { string expression = _watchEntries[i].Trim(); string newValue = ""; EvalResultType resultType; string exprToEvaluate = expression; WatchFormatStyle style = defaultStyle; int byteLength = defaultByteLength; if(expression.StartsWith("{") && expression.EndsWith("}")) { //Default to 2-byte values when using {} syntax byteLength = 2; } ProcessFormatSpecifier(ref exprToEvaluate, ref style, ref byteLength); bool forceHasChanged = false; Match match = _arrayWatchRegex.Match(expression); if(match.Success) { //Watch expression matches the array display syntax (e.g: [$300,10] = display 10 bytes starting from $300) newValue = ProcessArrayDisplaySyntax(style, ref forceHasChanged, match); } else { Int32 result = DebugApi.EvaluateExpression(exprToEvaluate, cpuType, out resultType, true); switch(resultType) { case EvalResultType.Numeric: newValue = FormatValue(result, style, byteLength); break; case EvalResultType.Boolean: newValue = result == 0 ? "false" : "true"; break; case EvalResultType.Invalid: newValue = "<invalid expression>"; forceHasChanged = true; break; case EvalResultType.DivideBy0: newValue = "<division by zero>"; forceHasChanged = true; break; case EvalResultType.OutOfScope: newValue = "<label out of scope>"; forceHasChanged = true; break; } } list.Add(new WatchValueInfo() { Expression = expression, Value = newValue, HasChanged = forceHasChanged || (i < previousValues.Count ? (previousValues[i].Value != newValue) : false) }); } return list; }
public Cpu(byte numberOfCores, CpuType cpuType, IMotherboard motherboard) { this.cpuType = cpuType; this.NumberOfCores = numberOfCores; this.motherboard = motherboard; }
public Cpu(byte numberOfCores, CpuType numberOfBits, IMotherboard motherboard) { this.numberOfBits = (byte)numberOfBits; this.NumberOfCores = numberOfCores; this.motherboard = motherboard; }
public S7NetPlcDriver(CpuType cpu, string ip, short rack, short slot) { client = new Plc(cpu, ip, rack, slot); }