public Rs <T> GetRs <T>(string rsName) where T : class, new() { Resource rs; string type = Identifiers.TypeId(typeof(T)); string rsUid = rsName + "_" + type; _Logger.Trace($"GetRs <{type}>: {rsName}"); //if (!_Resources.TryGetValue(rsUid, out rs)) if (!GetResource(rsUid, out rs)) { rs = new Rs <T>(rsName); _Resources[rsUid] = rs; _Logger.Trace($"GetRs <{type}>: {rsName}. New Resource..."); if ((rs is Rs <GwTlfRs>) || (rs is Rs <GwLcRs>)) { DireccionamientoIP hostInfo = Top.Cfg.GetGwRsHostInfo(rsName); if ((hostInfo != null) && (hostInfo.TipoHost != Tipo_Elemento_HW.TEH_TOP) && (hostInfo.TipoHost != Tipo_Elemento_HW.TEH_TIFX) && !((hostInfo.TipoHost == Tipo_Elemento_HW.TEH_EXTERNO_TELEFONIA) && (hostInfo.Interno)) //Si es recurso externo de telefonia y es de la centralita interna (ipbx) entonces //no se llama a Reset para que no inicialice Content y el boton //aparezca con aspa al inicio si no está presente ) { rs.Reset(null, new T()); //Se inicializa sin ASPA } } } return((Rs <T>)rs); //Se inicializa con ASPA }
public Rs Share(object paramses) { //格式化参数 Dictionary <string, string> p = JsonConvert.DeserializeObject <Dictionary <string, string> >(paramses.ToString()); Rs rs = Rs.Ok(); if (p.TryGetValue("__id", out string _id) && Guid.TryParse(_id, out Guid id)) { using (Muse db = new Muse()) { var record = db.Get <ReportDataSetModel>(x => x.ShareId == id && id != Guid.Empty, new[] { "ReportDataSourceModel" }); string cs = record.ReportDataSourceModel.ConnectionString; string sql = record.Sql; MySqlHelper msHelper = new MySqlHelper(cs); DataTable dt = msHelper.Select(sql, out int recordsAffected); var dic = TableConvert.Table2Dictionary(dt); rs.Add("table", dic); rs.Add("recordsAffected", recordsAffected); return(rs); } } else { rs = Rs.Error(); } return(rs); }
private static TlfNet CreateIpNet(string number, Scv scv) { TlfNet net = new TlfNet(); net.Id = "Net_ATS_IP_" + scv.Id; Rs <GwTlfRs> rs = Top.Registry.GetRs <GwTlfRs>(number); string ScvIp; if (rs.Content == null) { //Si el recurso no tiene contenido actualizado, la IP es de los datos de configuración (principal) string id; ScvIp = scv.GetProxyIp(out id); if (rs.IsUnreferenced) { //Para que recién creado por defecto aparezca sin aspa, le añado un recurso GwTlfRs proxyRs = new GwTlfRs(); proxyRs.GwIp = ScvIp; rs.Reset(null, proxyRs); } } else { //Utilizo los datos del recurso (actualizado con el activo) ScvIp = ((GwTlfRs)rs.Content).GwIp; } SipLine line = new SipLine(rs, ScvIp, true); net.Lines.Add(line); net.RsTypes.Add(new RsIdxType(net.Lines.Count - 1, 0, TipoInterface.TI_IP_PROXY)); net.Routes.Add(0); return(net); }
private void OnFrRxChanged(object sender) { Rs <RdSrvRxRs> rs = (Rs <RdSrvRxRs>)sender; Debug.Assert(_AssociateRxRs.Contains(rs)); if (Rx) { string rsId = rs.Id.ToUpper(); _Logger.Debug("*** OnFrRxchanged({2}). rs.IsValid es {0} {1}:", rs.IsValid, Pos, rsId); if (rs.IsValid) { // Debug.Assert(!_RxPorts.ContainsKey(rsId)); if (_RxPorts.ContainsKey(rsId)) { //_RxPorts.Remove(rsId); /* Provocar el paso por aspas cuando se cae la red*/ RxOff(); // Provocar la liberación del transmisor HF // en caso de que estuviera ocupado por este usuario if (_TipoFrecuencia == TipoFrecuencia_t.HF) { _RtxGroup = Math.Min(_RtxGroup, 0); Tx = false; Top.Registry.SetTx(_Literal, false, _Priority, false); } _Rx = AssignState.Idle; _RtxGroup = 0; _Squelch = SquelchState.Unavailable; _Ptt = PttState.Unavailable; _PttSrcId = string.Empty; _Estado = RdSrvFrRs.FrequencyStatusType.NotAvailable; General.SafeLaunchEvent(StateChanged, this); /* Fin cambio */ } _Logger.Debug("*** OnFrRxchanged({2}). Llamando a CreateRdRxPort({0}, pos {1})", rsId, Pos, rsId); CreateRxAudio(rs, rsId); } else { int port; if (_RxPorts.TryGetValue(rsId, out port)) { Top.Mixer.Unlink(port); _Logger.Debug("*** OnFrRxChanged({2}). Llamando a DestroyRdRxPort({0})", port, rsId); SipAgent.DestroyRdRxPort(port); _RxPorts.Remove(rsId); } } } }
private void CreateRxAudio(Rs <RdSrvRxRs> rs, string rsId) { int port = SipAgent.CreateRdRxPort(rs.Info, Top.SipIp); _RxPorts[rsId] = port; if (AnySquelch) { MixerDev dev = (_AudioVia == RdRxAudioVia.HeadPhones ? MixerDev.MhpRd : (_AudioVia == RdRxAudioVia.HfSpeaker ? MixerDev.SpkHf : MixerDev.SpkRd)); Top.Mixer.Link(port, dev, MixerDir.Send, Mixer.RD_PRIORITY, FuentesGlp.RxRadio); } _Logger.Debug("*** CreateRxAudio. Llamando a CreateRdRxPort({0}) {1}", port, Literal); }
public override int GetHashCode() { int hash = 1; if (Rs != false) { hash ^= Rs.GetHashCode(); } if (UserId != 0) { hash ^= UserId.GetHashCode(); } return(hash); }
private void RsChanged <T>(RsChangeInfo change) where T : class { T rs = Deserialize <T>(change.Content); string id = change.Id; string type = Identifiers.TypeId(typeof(T)); string rsUid = id + "_" + type; _Logger.Trace($"RsChanged <{type} {rsUid}>"); if (rs is GwTlfRs) { object rsTlf = rs; // No trato los eventos de proxies externos if (((GwTlfRs)rsTlf).Type > (uint)RsChangeInfo.RsTypeInfo.InternalAltProxy) { return; } if (((GwTlfRs)rsTlf).Type >= (uint)RsChangeInfo.RsTypeInfo.ExternalSub) { //TODO Le quito la informacion de puerto que no me sirve, de momento, hay que cambiar CORESIP y mas String[] userData = ((GwTlfRs)rsTlf).GwIp.ToString().Split(':'); ((GwTlfRs)rsTlf).GwIp = userData[0]; if (((GwTlfRs)rsTlf).St == GwTlfRs.State.NotAvailable) { rs = null; } } } Top.WorkingThread.Enqueue("RsChanged", delegate() { Resource resource; //if (!_Resources.TryGetValue(rsUid, out resource)) if (!GetResource(rsUid, out resource)) { resource = new Rs <T>(change.Id); _Resources[rsUid] = resource; _Logger.Trace($"RsChanged. Resource Added <{type} {rsUid}>"); } resource.Reset(change.ContainerId, rs); _Logger.Trace($"RsChanged. Resource Reset <{type} {rsUid}>"); }); }
public JsonResult SetShare(Guid id) { Rs rs = Rs.Ok("共享成功"); using (Muse db = new Muse()) { var record = db.Get <ReportDataSetModel>(x => x.Id == id && id != Guid.Empty, null); record.ShareId = Guid.NewGuid(); if (db.Update(record, true) > 0) { rs.Add("record", record); } else { rs = Rs.Error("共享失败"); rs.Add("record", record); } return(Json(rs, JsonRequestBehavior.AllowGet)); } }
public async Task <List <SearchedOrgPosition> > Handle(SearchOrgPositionQuery request, CancellationToken cancellationToken) { List <SearchedOrgPosition> result = new List <SearchedOrgPosition>(); List <SearchedOrgPosition> data = await(from OP in _context.OrgPosition join PT in _context.PositionType on OP.PositionTypeId equals PT.Id into OPTs from resultOrgPositions in OPTs.DefaultIfEmpty() join OUT in _context.OrgUnitType on OP.OrgUnitTypeId equals OUT.Id into OUTs from resultOrgUnits in OUTs.DefaultIfEmpty() join R in _context.Rank on OP.RankId equals R.Id into Rs from resultRanks in Rs.DefaultIfEmpty() select new SearchedOrgPosition { Id = OP.Id, PositionTypeId = OP.PositionTypeId, OrgUnitTypeId = OP.OrgUnitTypeId, ParentId = OP.ParentId, RankId = OP.RankId, RankText = resultRanks.Name, PositionTypeText = resultOrgPositions.Name, OrgUnitText = resultOrgUnits.Name }).ToListAsync(cancellationToken); if (request.Id != null) { if (!request.Children) { result = data.Where(c => c.Id == request.Id).ToList(); } else { result = data.Where(c => c.ParentId == request.Id).ToList(); } } else { result = data; } return(result); }
public List <Funcionario> SelecionarFuncionarios() { // 1º O método Abre a Conexão com o BD, insere a Query passando a Con // 2º Cria-se uma Lista baseada na respectiva Model // É feito um looping para a leitura dos dados // Ao final a lista completa é retornada // 3º Caso o Procedimento não seja efetuado, mostra-se uma mensagem de erro // 4º Ao Final, independente da situação, é Fechado a Conexão com o BD try { AbrirConexao(); SqlQuery = new SqlCommand("SELECT * FROM Funcionario", Con); Rs = SqlQuery.ExecuteReader(); var lista = new List <Funcionario>(); while (Rs.Read()) { var func = new Funcionario { IdFuncionario = Convert.ToInt32(Rs["Id"]), Nome = Convert.ToString(Rs["Nome"]), Sobrenome = Convert.ToString(Rs["Sobrenome"]), Cidade = Convert.ToString(Rs["Cidade"]), Endereco = Convert.ToString(Rs["Endereco"]), Email = Convert.ToString(Rs["Email"]) }; lista.Add(func); } return(lista); }catch (Exception error) { throw new Exception(error.Message); } finally { FecharConexao(); } }
public void Reset(CfgEnlaceExterno cfg) { uint oldPriority = _Priority; SquelchState oldSquelch = Squelch; if (string.Compare(cfg.Literal, _Literal, true) != 0) { Reset(); _AssociateFrRs = Top.Registry.GetRs <RdSrvFrRs>(cfg.Literal); if (_AssociateFrRs.IsValid) { RdSrvFrRs frRs = _AssociateFrRs.Info; _Alias = frRs.SqSite; _Squelch = oldSquelch = (SquelchState)frRs.Squelch; _Ptt = GetPtt(frRs.PttSrcId); _RtxGroup = 0; if (frRs.RtxGroupId != 0) { _RtxGroup = (frRs.RtxGroupOwner != Top.HostId ? -1 : (int)frRs.RtxGroupId); } } } else { _AssociateRxRs.Clear(); _AssociateTxRs.Clear(); } _AssociateFrRs.NewMsg += OnFrMsg; _AssociateFrRs.Changed += OnFrChanged; _AssociateFrRs.SelCalMsg += OnSelCalMsg; _AssociateFrRs.SiteChanged += OnSiteChanged; _Literal = cfg.Literal; /** 20180321. AGL. ALIAS a mostrar en la tecla... */ var Alias = cfg.GetType().GetProperty("Alias"); _KeyAlias = Alias == null ? "NoAlias" : Alias.GetValue(cfg) as string; // _KeyAlias = cfg.Alias; //_Alias = cfg.ListaRecursos.Count > 0 ? cfg.ListaRecursos[0].IdEmplazamiento : ""; _Priority = cfg.Prioridad; _TipoFrecuencia = (TipoFrecuencia_t)cfg.TipoFrecuencia; _Monitoring = cfg.EstadoAsignacion == "M"; _RxOnly = false; switch (cfg.EstadoAsignacion) { case "M": // Monitor Rx = true; Tx = false; AudioVia = RdRxAudioVia.Speaker; SetTx(false, false); break; case "T": // Trafico if (!Tx) { SetTx(true, false); } AudioVia = RdRxAudioVia.Speaker; break; default: // Reposo break; } _RscSite.Clear(); foreach (CfgRecursoEnlaceExterno dst in cfg.ListaRecursos) { _RscSite.Add(dst.IdRecurso, dst.IdEmplazamiento); // Se añaden todos los recursos que con el estado // Estado=="S"elected o Estado=="A"ctivo if (dst.Estado == "S" || dst.Estado == "A") { if (dst.Estado == "S") { if (_Alias != dst.IdEmplazamiento) { Squelch = oldSquelch; _Alias = dst.IdEmplazamiento; } } //_Alias = dst.Estado == "S" ? dst.IdEmplazamiento : _Alias; if ((dst.Tipo == Cd40Cfg.RD_RX) || (dst.Tipo == Cd40Cfg.RD_RXTX)) { Rs <RdSrvRxRs> rs = Top.Registry.GetRs <RdSrvRxRs>(dst.IdRecurso); rs.Changed += OnFrRxChanged; _AssociateRxRs.Add(rs); } if ((dst.Tipo == Cd40Cfg.RD_TX) || (dst.Tipo == Cd40Cfg.RD_RXTX)) { Rs <RdSrvTxRs> rs = Top.Registry.GetRs <RdSrvTxRs>(dst.IdRecurso); //rs.Changed += OnFrTxChanged; _AssociateTxRs.Add(rs); } } } if ((_AssociateTxRs.Count == 0) && (_AssociateRxRs.Count > 0) && _TipoFrecuencia != TipoFrecuencia_t.HF) { _RxOnly = true; } if (_Rx == AssignState.Set) { Dictionary <string, int> portsToRemove = new Dictionary <string, int>(_RxPorts); foreach (Rs <RdSrvRxRs> rs in _AssociateRxRs) { string rsId = rs.Id.ToUpper(); if (rs.IsValid && !portsToRemove.Remove(rsId)) { _Logger.Debug("*** M+N. Reset(sender). Llamando a CreateRdRxPort({0},{1})", ((RdSrvRxRs)rs.Content).ToString(), Top.SipIp); CreateRxAudio(rs, rsId); } else { _Logger.Debug("*** M+N. Reset(sender). rs.IsValid && !portsToRemove.Remove(rsId) es false)"); } } foreach (KeyValuePair <string, int> p in portsToRemove) { Top.Mixer.Unlink(p.Value); _Logger.Debug("*** M+N. RxOff(sender). Llamando a DestroyRdRxPort({0})", p.Value); SipAgent.DestroyRdRxPort(p.Value); _RxPorts.Remove(p.Key); } } if ((_Tx != AssignState.Idle) && (_Priority != oldPriority)) { Top.Registry.SetTx(_Literal, true, _Priority, _Tx == AssignState.Trying); } }
static void Main(string[] argv) { string meth = Environment.GetEnvironmentVariable("REQUEST_METHOD"); string uri = Environment.GetEnvironmentVariable("SCRIPT_NAME"); string qs = Environment.GetEnvironmentVariable("QUERY_STRING"); Console.Error.WriteLine("ZXIDProvisCGI qs(" + qs + ") uri(" + uri + ") meth(" + meth + ")"); if (qs == null) { qs = ""; } Console.Error.WriteLine(zxidcs.version()); Console.Error.WriteLine(zxidcs.version_str()); zxid_conf cf = zxidcs.new_conf_to_cf("CPATH=/var/zxid/&BURL=https://yourhost.example.com:8443/sso/zxidprovisflow.exe&DEBUG=0x03"); //Console.Error.WriteLine(zxidcs.simple_show_conf(cf, null, null, 0)); if (uri.StartsWith("/sso/")) { // // Anything starting by /sso/ requires Single Sign-On // This may be simple logged in case if session cookie is already set, // or it may involve SSO protocol related redirects to IdP, etc. // All this is handled by zxidcs.simple_cf() and the switch (res) {} // that follows // Console.Error.WriteLine("sso qs(" + qs + ") uri(" + uri + ")"); if (meth == "POST") { qs = read_post(); } string res = zxidcs.simple_cf(cf, qs.Length, qs, null, 0x0d54); switch (res[0]) { case 'L': /* Redirect: ret == "LOCATION: urlCRLF2" */ Console.Error.WriteLine("redirect(" + res + ") len=" + res.Length); Console.Write(res); /* Location header redirect */ return; case '<': switch (res[1]) { case 's': /* <se: SOAP envelope */ case 'm': /* <m20: metadata */ Console.Write("Content-Type: text/xml\r\nContent-Length: " + res.Length + "\r\n\r\n"); break; default: Console.Write("Content-Type: text/html\r\nContent-Length: " + res.Length + "\r\n\r\n"); break; } Console.Write(res); return; case 'd': /* Logged in case */ //my_parse_ldif(ret); int x = res.IndexOf("\nsesid: "); int y = res.IndexOf('\n', x + 8); string sid = res.Substring(x + 8, y - x - 8); Console.Error.WriteLine("Logged in. sid=" + sid); break; default: Console.Error.WriteLine("Unknown zxid_simple() response."); break; } // At this point the SSO has been handled and we are ready to process the // application payload data. In our case we have multistep provisioning // flow expressed by names of submit buttons pressed: query, provisold, // provisnew, ... No button pressed means beginning of the process (the last else). NameValueCollection cgi = HttpUtility.ParseQueryString(qs); if (cgi.query) { // *** sanity check the cgi input to avoid evil like injection attacks zx_str ret = zxidcs.call(cf, ses, "urn:syn:pds:2015", null /* url */, null, null, "op=select&from=users&fields=cas,cn,addr&cnpat=" + cgi.cn + "&ddnpat=" + cgi.ddn + "&genderpat=" + cgi.gender + "&fmt=json&count=20"); string res_body_json = zxidcs.zx_str_s_get(ret); Console.Error.WriteLine("res(" + res_body_json + ") len=" + res_body_json.Length); // Parse response and render the choices //dynamic rs = Json.Decode(res_body_json); //JavaScriptSerializer jss = new JavaScriptSerializer(); //var rs = jss.Deserialize<dynamic>(res_body_json); Rs rs = JsonConvert.DeserializeObject <Rs>(res_body_json); Console.Write("Content-Type: text/html\r\n\r\n"); Console.WriteLine("<title>Query Exists</title><h1>Results of Query Existing Users</h1>"); Console.WriteLine("<form method=post>"); if (rs == null || rs.Length == 0) { Console.WriteLine("<h3>No existing users found</h3>"); } else if (rs.Length >= 20) { Console.WriteLine("<h3>WARNING: Too many matches. You need to refine your search criteria.</h3>"); } else if (rs.Length == 1) { Console.WriteLine("<h3>One user found. Confirm?</h3>"); Console.WriteLine("<input type=hidden name=cas value=\"" + rs[0].cas + "\">"); Console.WriteLine("CN: " + rs[0].cn + " Address: " + rs[0].addr); Console.WriteLine("<input type=submit name=provisold value=\" This is it \"><br>"); } else { Console.WriteLine("<h3>Many users found: Choose one</h3>"); for (int i = 0; i < rs.Length; ++i) { Console.WriteLine("<input type=radio name=cas value=\"" + rs[i].cas + "\">"); Console.WriteLine("CN: " + rs[i].cn + " Address: " + rs[i].addr); } Console.WriteLine("<input type=submit name=provisold value=\" Choose Selected User \"><br>"); } Console.WriteLine("Name: <input name=cn value=\"" + cgi.cn + "\"><br>"); Console.WriteLine("Data of Birth (YYYYMMDD): <input name=ddn value=\"" + cgi.ddn + "\"><br>"); string mselect = cgi.gender == "m" ? " selected":""; string fselect = cgi.gender == "f" ? " selected":""; Console.WriteLine("Gender: <input type=radio name=gender value=m" + mselect + "> Male, <input type=radio name=gender value=f" + fselect + "> Female<br>"); Console.WriteLine("<input type=submit name=query value=\" Search again \">"); Console.WriteLine("<input type=submit name=provisnew value=\" Create new user \">"); Console.WriteLine("</form>"); } else if (cgi.provisnew) { // *** TBW } else if (cgi.provisold) { // *** TBW } else { // Start of the provisioning flow (usually after nurse SSO) Console.Write("Content-Type: text/html\r\n\r\n"); Console.WriteLine("<title>Protected</title><h1>Logged in, Protected Content</h1>"); Console.WriteLine("session id(" + sid + ")"); //Console.WriteLine("res("+res+")"); Console.WriteLine("<h3>Start of provisioning flow</h3>"); Console.WriteLine("<form method=post>"); Console.WriteLine("<input type=hidden name=provstep value=queryexist>"); Console.WriteLine("Name: <input name=cn value=\"\"><br>"); Console.WriteLine("Data of Birth (YYYYMMDD): <input name=ddn value=\"\"><br>"); Console.WriteLine("Gender: <input type=radio name=gender value=m> Male, <input type=radio name=gender value=f> Female<br>"); Console.WriteLine("<input type=submit name=query value=\" Query if user exists \">"); Console.WriteLine("</form>"); } } else if (uri.StartsWith("/wsp/")) { // // Handle Web Service Provider interface // string post = read_post(); zxid_ses ses = zxidcs.alloc_ses(cf); string idpnid = zxidcs.wsp_validate(cf, ses, "", post); Console.Error.WriteLine("WSP: Serving a web service call. idpnid=" + idpnid + " uri=" + uri); string resp = "OK"; // Do your web service provider payload here zx_str wsp_resp = zxidcs.wsp_decorate(cf, ses, "", resp); Console.Write("Content-Type: text/plain\r\n\r\n"); Console.Write(zxidcs.zx_str_s_get(wsp_resp)); } else { Console.Write("Content-Type: text/html\r\n\r\n"); Console.WriteLine("<title>Unprotected</title><h1>Unprotected</h1>"); } }
private bool TestState(Rs state) { return ((_States & state) == state); }
private void OnFrChanged(object sender) { Rs <RdSrvFrRs> rs = (Rs <RdSrvFrRs>)sender; bool changed = false; bool changedQidx = false; if (!rs.IsValid) { RxOff(); // Provocar la liberación del transmisor HF // en caso de que estuviera ocupado por este usuario if (_TipoFrecuencia == TipoFrecuencia_t.HF) { _RtxGroup = Math.Min(_RtxGroup, 0); Tx = false; Top.Registry.SetTx(_Literal, false, _Priority, false); } _Rx = AssignState.Idle; _RtxGroup = 0; _Squelch = SquelchState.Unavailable; _Ptt = PttState.Unavailable; _PttSrcId = string.Empty; _Estado = RdSrvFrRs.FrequencyStatusType.NotAvailable; _QidxValue = 0; _QidxResource = string.Empty; changed = true; } else { RdSrvFrRs frRs = rs.Info; if (frRs.PttSrcId == "TxHfOff") { if (_Tx == AssignState.Set) { // Reflejar el estado real de Tx. Puede que el recurso no // esté disponble en la configuración de la pasarela. En // cuyo caso se debe quitar de transmisión _Tx = AssignState.Idle; _Ptt = PttState.NoPtt; _PttSrcId = frRs.PttSrcId; // Actualizar estado de Tx a Off General.SafeLaunchEvent(StateChanged, this); // Enviar mensaje para ventana de error General.SafeLaunchEvent(TxHfAlreadyAssigned, this, (uint)0xFE); } frRs.PttSrcId = string.Empty; //return; } // // Tratamiento del cambio en el estado de Squelch // switch (_TipoFrecuencia) { case TipoFrecuencia_t.FD: if (_Squelch != (SquelchState)frRs.Squelch) { _Squelch = (SquelchState)frRs.Squelch; changed = true; } if (ChangeInQidxInfo(frRs)) { // BSS Information _QidxMethod = frRs.QidxMethod; _QidxResource = _Squelch == SquelchState.NoSquelch ? string.Empty : frRs.SqSite; _QidxValue = _Squelch == SquelchState.NoSquelch ? 0 : frRs.QidxValue; changedQidx = true; } break; // EM case TipoFrecuencia_t.ME: if (_Squelch != (SquelchState)frRs.Squelch && (frRs.SqSite == Alias || frRs.SqSite == string.Empty)) { _Squelch = (SquelchState)frRs.Squelch; changed = true; // BSS Information _QidxMethod = frRs.QidxMethod; _QidxResource = frRs.SqSite; _QidxValue = frRs.QidxValue; } break; default: if (_Squelch != (SquelchState)frRs.Squelch) { _Squelch = (SquelchState)frRs.Squelch; changed = true; } break; } if (_Squelch != (SquelchState)frRs.Squelch && (frRs.SqSite == Alias || frRs.SqSite == string.Empty)) { _Squelch = (SquelchState)frRs.Squelch; changed = true; } // // Tratamiento del cambio en el estado de PTT // PttState ptt = GetPtt(frRs.PttSrcId); if ((frRs.PttSrcId != _PttSrcId) && (ptt == PttState.Error)) { Top.Rd.GenerateBadOperationTone(2000); } // Es posible que no cambie el ptt (externo) pero si cambie su procedencia: // Cambio de ptt externo de rtx a externo de otro HMI. // En este caso hay que evaluar el audio if (ptt != _Ptt || changed || frRs.PttSrcId != _PttSrcId) { if (ptt != _Ptt) { if (ptt == PttState.NoPtt) { if ((_Ptt == PttState.ExternPtt) || (_Ptt == PttState.PttOnlyPort) || (_Ptt == PttState.PttPortAndMod)) { //Al desactivarse el Ptt arranca un timer durante el cual se inhibe el audio de Rd Rx //Solo cuando el estado anterior es un ptt #3830 _PttOffTimer.Enabled = true; } } else { //Cualquier activacion del Ptt anula el timer _PttOffTimer.Enabled = false; } } // Si estoy en Ptt o // Estoy en RTX de otro SQ del grupo y soy dueño del grupo (dejo el otro audio) // no conecto mi audio if (InhiboMiAudio(ptt, frRs) == true) { foreach (int port in _RxPorts.Values) { Top.Mixer.Unlink(port); } } else { foreach (int port in _RxPorts.Values) { if (Rx) { if (Squelch == SquelchState.SquelchOnlyPort) { MixerDev dev = (_AudioVia == RdRxAudioVia.HeadPhones ? MixerDev.MhpRd : (_AudioVia == RdRxAudioVia.HfSpeaker ? MixerDev.SpkHf : MixerDev.SpkRd)); Top.Mixer.Link(port, dev, MixerDir.Send, Mixer.RD_PRIORITY, FuentesGlp.RxRadio); } else if (Squelch == SquelchState.NoSquelch) { Top.Mixer.Unlink(port); } } } } _Ptt = ptt; _PttSrcId = frRs.PttSrcId; changed = true; } // // Tratamiento del cambio en el estado de la retransmisión // int rtxGroup = 0; if (frRs.RtxGroupId != 0) { rtxGroup = frRs.RtxGroupOwner == Top.HostId ? (int)frRs.RtxGroupId : -1; } if (rtxGroup != _RtxGroup) { _RtxGroup = rtxGroup; changed = true; } // // Tratamiento del cambio en el estado de disponibilidad de la frecuencia. // if (frRs.FrequencyStatus != _Estado) { _Estado = frRs.FrequencyStatus; changed = true; } } if (changed || changedQidx) { General.SafeLaunchEvent(StateChanged, this); } }
/* Execute Step Comments: * The temp variables Rs,Rd,Operand8,etc registers are defined in constructor Main() method to avoid memory leaks. * But, this also means they will also retain the same value even after ExecuteStep() is called again. * So, for any temp variables, modify all its constituent variables then only use it. * e.g. Do not use Operand16 by modifying just its LB or HB. */ private void ExecuteStep() { IC++; CCC = CCC + Int32.Parse(I.Names[m[PC.DEC16].DEC8, 2]); if (changeInte == true) //Interrupt control logic (as ei/de affects inte f/f only during next instruction) { if (changeInteTo == true) { inte = true; } else { inte = false; } changeInte = false; UpdateInterrupt(); } Opcode.DEC8 = m[PC.DEC16].DEC8; // * DATA TRANSFER GROUP * if (BitCombination(Opcode[7], Opcode[6]) == "01") //MOV,HLT { //Except Rs=Rd=M 01110110 hlt if (BitCombination(Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "110110") { //Halt Rs=Rd=M 01110110 hlt Stop(); return; } else { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); Set8BitRegisterValue(Rs.DEC8, Opcode[5], Opcode[4], Opcode[3]); PC.INX(); } } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "00110") //MVI Rd,8BitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; Set8BitRegisterValue(Operand8.DEC8, Opcode[5], Opcode[4], Opcode[3]); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "000001") //LXI Rp,16BitData { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; Set16BitRegisterValue(true, Operand16.DEC16, Opcode[5], Opcode[4]); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00111010") //LDA { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PSW.HB.DEC8 = m[Operand16.DEC16].DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00110010") //STA { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; m[Operand16.DEC16].DEC8 = PSW.HB.DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00101010") //LHLD { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; HL.LB.DEC8 = m[Operand16.DEC16].DEC8; Operand16.INX(); HL.HB.DEC8 = m[Operand16.DEC16].DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00100010") //SHLD { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; m[Operand16.DEC16].DEC8 = HL.LB.DEC8; Operand16.INX(); m[Operand16.DEC16].DEC8 = HL.HB.DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00001010") //LDAX B { PSW.HB.DEC8 = m[BC.DEC16].DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00011010") //LDAX D { PSW.HB.DEC8 = m[DE.DEC16].DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11101010") //XCHG { Operand16.DEC16 = HL.DEC16; HL.DEC16 = DE.DEC16; DE.DEC16 = Operand16.DEC16; PC.INX(); } else if (Opcode.DEC8 == 219) //IN 8bitIOPortAddress { PC.INX(); PSW.HB.DEC8 = io[m[PC.DEC16].DEC8].DEC8; PC.INX(); } else if (Opcode.DEC8 == 211) //OUT 8bitIOPortAddress { PC.INX(); io[m[PC.DEC16].DEC8].DEC8 = PSW.HB.DEC8; PC.INX(); } // * ARITHMETIC GROUP * else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10000") //ADD Rs { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); if ((PSW.HB.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10001") //ADC R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); byte i; if (PSW.LB[0] == true) { i = 1; } else { i = 0; } if ((PSW.HB.GetLowerNibble() + Rs.GetLowerNibble() + i) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Rs.DEC8 + i) > 255) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 + i - 256); } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 + i); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11000110") //ADI 8bitdata { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; if ((PSW.HB.GetLowerNibble() + Operand8.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Operand8.DEC8) > 255) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 - 256); } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11001110") //ACI 8bitdata { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; byte i; if (PSW.LB[0] == true) { i = 1; } else { i = 0; } if ((PSW.HB.GetLowerNibble() + Operand8.GetLowerNibble() + i) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Operand8.DEC8 + i) > 255) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 + i - 256); } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 + i); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "00100") //INR R { Rs.DEC8 = Get8BitRegisterValue(Opcode[5], Opcode[4], Opcode[3]); if (Rs.GetLowerNibble() == 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if (Rs.DEC8 == 255) { Rs.DEC8 = (byte)(0 + 1); } else { Rs.DEC8 = (byte)(Rs.DEC8 + 1); } Set8BitRegisterValue(Rs.DEC8, Opcode[5], Opcode[4], Opcode[3]); UpdateP(Rs.DEC8); UpdateS(Rs.DEC8); UpdateZ(Rs.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10010") //SUB R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); Rs.DEC8 = Rs.Get2sComplement(); //In 2's complement addition, complement both CY and AC. Here, it is done directly in if conditional //by inverting true and false. if ((PSW.HB.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10011") //SBB R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); if (PSW.LB[0] == true) { if (Rs.DEC8 == 255) { Rs.DEC8 = 0; } else { Rs.DEC8 = (byte)(Rs.DEC8 + 1); } } Rs.DEC8 = Rs.Get2sComplement(); if ((PSW.HB.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11010110") //SUI 8bitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; Operand8.DEC8 = Operand8.Get2sComplement(); if ((PSW.HB.GetLowerNibble() + Operand8.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Operand8.DEC8) > 255) { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 - 256); } else { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11011110") //SBI 8BitDAta { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; if (PSW.LB[0] == true) { if (Operand8.DEC8 == 255) { Operand8.DEC8 = 0; } else { Operand8.DEC8 = (byte)(Operand8.DEC8 + 1); } } Operand8.DEC8 = Operand8.Get2sComplement(); if ((PSW.HB.GetLowerNibble() + Operand8.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Operand8.DEC8) > 255) { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 - 256); } else { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "00101") //DCR R { /*Rs.DEC8 = Get8BitRegisterValue(Opcode[5], Opcode[4], Opcode[3]); * * Rs.DEC8 = Rs.Get2sComplement(); * * if (Rs.GetLowerNibble() == 15) * PSW.LB[4] = true; * else * PSW.LB[4] = false; * * if (Rs.DEC8 == 255) * { * Rs.DEC8 = (byte)(0 + 1); * } * else * { * Rs.DEC8 = (byte)(Rs.DEC8 + 1); * } * * Set8BitRegisterValue(Rs.DEC8, Opcode[5], Opcode[4], Opcode[3]); * UpdateP(Rs.DEC8); * UpdateS(Rs.DEC8); * UpdateZ(Rs.DEC8); * * PC.INX(); * */ Rd.DEC8 = Get8BitRegisterValue(Opcode[5], Opcode[4], Opcode[3]); Rs.DEC8 = 1; //As 1 is substracted Rs.DEC8 = Rs.Get2sComplement(); //In 2's complement addition, complement both CY and AC. Here, it is done directly in if conditional //by inverting true and false. if ((Rd.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((Rd.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; Rd.DEC8 = (byte)(Rd.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; Rd.DEC8 = (byte)(Rd.DEC8 + Rs.DEC8); } Set8BitRegisterValue(Rd.DEC8, Opcode[5], Opcode[4], Opcode[3]); UpdateP(Rd.DEC8); UpdateS(Rd.DEC8); UpdateZ(Rd.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "000011") //INX Rp { switch (BitCombination(Opcode[5], Opcode[4])) { case "00": { BC.INX(); break; } case "01": { DE.INX(); break; } case "10": { HL.INX(); break; } case "11": { SP.INX(); break; } } PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "001011") //DCX Rp { switch (BitCombination(Opcode[5], Opcode[4])) { case "00": { BC.DCX(); break; } case "01": { DE.DCX(); break; } case "10": { HL.DCX(); break; } case "11": { SP.DCX(); break; } } PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "001001") //DAD Rp,16BitData { Operand16.DEC16 = Get16BitRegisterValue(true, Opcode[5], Opcode[4]); if ((HL.DEC16 + Operand16.DEC16) > 65535) { PSW.LB[0] = true; HL.DEC16 = (ushort)(HL.DEC16 + Operand16.DEC16 - 65536); } else { PSW.LB[0] = false; HL.DEC16 = (ushort)(HL.DEC16 + Operand16.DEC16); } PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00100111") //DAA { if ((PSW.HB.GetLowerNibble() > 9) || (PSW.LB[4] == true)) { //Add 6 to lower nibble if ((PSW.HB.GetLowerNibble() + 6) > 15) { PSW.LB[4] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + 6 - 16); //6 is added, 16 is sub to neutralize overflow out of nibble } else { PSW.LB[4] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + 6); } } else { PSW.LB[4] = false; } byte i; if (PSW.LB[4] == true) { i = 1; } else { i = 0; } if ((PSW.HB.GetHigherNibble() > 9) || (PSW.LB[0] == true)) { bool PreviousCY = PSW.LB[0]; //Add 6 to higher nibble if ((PSW.HB.GetHigherNibble() + 6 + i) > 15) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + (6 + i - 16) * 16); //i is carry from lower nibble, Multiply by 16 to reach uppaer nibble ( i.e. up by 4 bits 2^4) } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + (6 + i) * 16); } if (PreviousCY) //Set CY if it was initially set { PSW.LB[0] = true; } } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } // * LOGICAL GROUP * else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10100") //ANA R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 & Rs.DEC8); PSW.LB[0] = false; PSW.LB[4] = true; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11100110") //ANI 8bitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 & Operand8.DEC8); PSW.LB[0] = false; PSW.LB[4] = true; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10110") //ORA R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 | Rs.DEC8); PSW.LB[0] = false; PSW.LB[4] = false; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11110110") //ORI 8bitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 | Operand8.DEC8); PSW.LB[0] = false; PSW.LB[4] = false; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10101") //XRA R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 ^ Rs.DEC8); PSW.LB[0] = false; PSW.LB[4] = false; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11101110") //XRI 8bitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 ^ Operand8.DEC8); PSW.LB[0] = false; PSW.LB[4] = false; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00101111") //CMA { PSW.HB.DEC8 = (byte)(~PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00111111") //CMC { PSW.LB[0] = !PSW.LB[0]; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00110111") //STC { PSW.LB[0] = true; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10111") //CMP R { Operand8.DEC8 = PSW.HB.DEC8; Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); Rs.DEC8 = Rs.Get2sComplement(); if ((Operand8.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((Operand8.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; Operand8.DEC8 = (byte)(Operand8.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; Operand8.DEC8 = (byte)(Operand8.DEC8 + Rs.DEC8); } UpdateP(Operand8.DEC8); UpdateS(Operand8.DEC8); UpdateZ(Operand8.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10111") //CPI 8bitData { Operand8.DEC8 = PSW.HB.DEC8; PC.INX(); Rs.DEC8 = m[PC.DEC16].DEC8; Rs.DEC8 = Rs.Get2sComplement(); if ((Operand8.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((Operand8.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; Operand8.DEC8 = (byte)(Operand8.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; Operand8.DEC8 = (byte)(Operand8.DEC8 + Rs.DEC8); } UpdateP(Operand8.DEC8); UpdateS(Operand8.DEC8); UpdateZ(Operand8.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00000111") //RLC { bool D7 = PSW.HB[7]; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 << 1); PSW.HB[0] = D7; PSW.LB[0] = D7; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00001111") //RRC { bool D0 = PSW.HB[0]; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 >> 1); PSW.HB[7] = D0; PSW.LB[0] = D0; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00010111") //RAL { bool D7 = PSW.HB[7]; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 << 1); PSW.HB[0] = PSW.LB[0]; PSW.LB[0] = D7; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00011111") //RAR { bool D0 = PSW.HB[0]; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 >> 1); PSW.HB[7] = PSW.LB[0]; PSW.LB[0] = D0; PC.INX(); } // * STACK AND MACHINE CONTROL GROUP * else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "110101") //PUSH Rp { //FOR Push/Pop and in Branching only , IsSP = false i.e. return PC Operand16.DEC16 = Get16BitRegisterValue(false, Opcode[5], Opcode[4]); SP.DCX(); m[SP.DEC16].DEC8 = Operand16.HB.DEC8; SP.DCX(); m[SP.DEC16].DEC8 = Operand16.LB.DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "110001") //POP Rp { Operand16.LB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); Operand16.HB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); Set16BitRegisterValue(false, Operand16.DEC16, Opcode[5], Opcode[4]); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11111001") //SPHL { SP.DEC16 = HL.DEC16; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11100011") //XTHL { Operand16.DEC16 = HL.DEC16; HL.LB.DEC8 = m[SP.DEC16].DEC8; m[SP.DEC16].DEC8 = Operand16.LB.DEC8; if (SP.DEC16 == 255) //Check for overflow { HL.HB.DEC8 = m[0].DEC8; m[0].DEC8 = Operand16.HB.DEC8; } else { HL.HB.DEC8 = m[SP.DEC16 + 1].DEC8; m[SP.DEC16 + 1].DEC8 = Operand16.HB.DEC8; } PC.INX(); } else if (Opcode.DEC8 == 0) //NOP { PC.INX(); } else if (Opcode.DEC8 == 251) //EI { changeInte = true; changeInteTo = true; PC.INX(); } else if (Opcode.DEC8 == 251) //DI { changeInte = true; changeInteTo = false; PC.INX(); } else if (Opcode.DEC8 == 32) //RIM { //Read sid and output to d7 bit of accumulator if (rbSid0.IsChecked == true) { PC.HB[7] = false; } else { PC.HB[7] = true; } //No logic for interrupts pending in simulator //Read inte if (inte == true) { PC.HB[3] = true; } else { PC.HB[3] = false; } //Reads masks if (interrupt[2] == true) //M7.5 { PC.HB[2] = true; } else { PC.HB[2] = false; } if (interrupt[1] == true) //M6.5 { PC.HB[1] = true; } else { PC.HB[1] = false; } if (interrupt[0] == true) //M5.5 { PC.HB[0] = true; } else { PC.HB[0] = false; } PC.INX(); UpdateInterrupt(); } else if (Opcode.DEC8 == 48) //SIM { //Set sod=1 if sde=1 else sod=0 if (PC.HB[6] == true) { if (PC.HB[7] == true) { tbSod.Text = "1"; } else { tbSod.Text = "0"; } } if (PC.HB[4] == true) //Resets r7.5 f/f, else has no effect { r75 = false; } if (PC.HB[3] == true) //MSE { if (PC.HB[2] == true) //M'7.5 { interrupt[2] = true; } else { interrupt[2] = false; } if (PC.HB[1] == true) //M'6.5 { interrupt[1] = true; } else { interrupt[1] = false; } if (PC.HB[0] == true) //M'5.5 { interrupt[0] = true; } else { interrupt[0] = false; } } PC.INX(); UpdateInterrupt(); } // * BRANCH GROUP * //In branch group, take care of whether to execute PC.INX() or not at end. else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11101001") //PCHL { PC.DEC16 = HL.DEC16; } else if (Opcode.DEC8 == 195) //JMP { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PC.DEC16 = Operand16.DEC16; } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "11010") //Conditional Jump { if (CheckCondition(Opcode[5], Opcode[4], Opcode[3]) == true) { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PC.DEC16 = Operand16.DEC16; } else { PC.INX(); PC.INX(); PC.INX(); } } else if (Opcode.DEC8 == 205) //CALL { //Storing address to be branched in temp register Operand16 PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); //Push contents of PC onto stack SP.DCX(); m[SP.DEC16].DEC8 = PC.HB.DEC8; SP.DCX(); m[SP.DEC16].DEC8 = PC.LB.DEC8; //Branch PC.DEC16 = Operand16.DEC16; } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "11100") //Conditional CALL { if (CheckCondition(Opcode[5], Opcode[4], Opcode[3]) == true) { //Storing address to be branched in temp register Operand16 PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); //Push contents of PC onto stack SP.DCX(); m[SP.DEC16].DEC8 = PC.HB.DEC8; SP.DCX(); m[SP.DEC16].DEC8 = PC.LB.DEC8; //Branch PC.DEC16 = Operand16.DEC16; } else { PC.INX(); PC.INX(); PC.INX(); } } else if (Opcode.DEC8 == 201) //RET { //Pop content from stack to temp RegisterPair Operand16 Operand16.LB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); Operand16.HB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); //Branch PC.DEC16 = Operand16.DEC16; } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "11000") //Conditional Return { if (CheckCondition(Opcode[5], Opcode[4], Opcode[3]) == true) { Operand16.LB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); Operand16.HB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); //Branch PC.DEC16 = Operand16.DEC16; } else { PC.INX(); } } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "11111") //RST N { PC.INX(); //Push contents of PC onto stack SP.DCX(); m[SP.DEC16].DEC8 = PC.HB.DEC8; SP.DCX(); m[SP.DEC16].DEC8 = PC.LB.DEC8; //Branch switch (BitCombination(Opcode[5], Opcode[4], Opcode[3])) { case "000": { PC.DEC16 = 0; break; } case "001": { PC.DEC16 = 8; break; } case "010": { PC.DEC16 = 16; break; } case "011": { PC.DEC16 = 24; break; } case "100": { PC.DEC16 = 32; break; } case "101": { PC.DEC16 = 40; break; } case "110": { PC.DEC16 = 48; break; } case "111": { PC.DEC16 = 56; break; } } } else { //Unrecognised Instructions PC.INX(); } RefreshMIO(false); //Nofocus, as it will cause Stop button never to gain focus UpdateAll(); //Rucurse in Fast Mode but in idle priority if (rbFast.IsChecked == true) { bStep.IsEnabled = false; if (IsStopped == false) { bStart.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new ExecuteStepDelegate(ExecuteStep)); } } }
private void SetState(Rs state, bool value) { if (value == true) _States |= state; else _States &= ~state; }
public TlfNet GetNet(uint prefix, string number, ref StrNumeroAbonado altRoute) { string idEquipo; if (prefix == Cd40Cfg.ATS_DST) { ulong num; if (ulong.TryParse(number, out num)) { int centralId = -1; foreach (NumeracionATS centralAts in _SystemCfg.PlanNumeracionATS) { bool foundCentralAts = false; centralId++; foreach (RangosSCV range in centralAts.RangosOperador) { if ((range.Inicial <= num) && (range.Final >= num)) { if (!string.IsNullOrEmpty(range.IdAbonado)) { altRoute = new StrNumeroAbonado(); altRoute.Prefijo = range.IdPrefijo; altRoute.NumeroAbonado = range.IdAbonado; } foundCentralAts = true; break; } } if (!foundCentralAts) { foreach (RangosSCV range in centralAts.RangosPrivilegiados) { if ((range.Inicial <= num) && (range.Final >= num)) { if (!string.IsNullOrEmpty(range.IdAbonado)) { altRoute = new StrNumeroAbonado(); altRoute.Prefijo = range.IdPrefijo; altRoute.NumeroAbonado = range.IdAbonado; } foundCentralAts = true; break; } } } if (foundCentralAts) { int route = 0; TlfNet net = new TlfNet(); net.Id = "Net_ATS_" + centralId; foreach (PlanRutas ruta in centralAts.ListaRutas) { // Primero van las rutas directas y luego el resto route = (ruta.TipoRuta == "D") ? route : ++route; foreach (string trunk in ruta.ListaTroncales) { foreach (PlanRecursos recurso in _SystemCfg.GetTrunkResources(trunk)) { Rs <GwTlfRs> rs = Top.Registry.GetRs <GwTlfRs>(recurso.IdRecurso); string rsIp = GetGwRsIp(recurso.IdRecurso, out idEquipo); SipLine line = new SipLine(rs, rsIp); net.Lines.Add(line); net.RsTypes.Add(new RsIdxType(net.Lines.Count - 1, route, recurso.Tipo)); net.Routes.Add(route); } } } /* * * Los recursos dentro de un troncal ya no se ordenan primero los de R2 * y luego los de N-5 (tal y como se hizo para ACC). Se ordenan primero lado A * y luego lado B (Según Encamina (02/06) ). * Incidencia #2521 * net.RsTypes.Sort(delegate(RsIdxType a, RsIdxType b) * { * if (a.ruta == b.ruta) * return a.TipoInteface - b.TipoInteface; * if (a.ruta < b.ruta) * return -1; * * return 1; * }); */ return(net); } } //Devuelve una red vacía si no lo encuentra en la configuración _Logger.Info("Linea no encontrada para prefijo {0} {1}", prefix, number); TlfNet emptyNet = new TlfNet(); emptyNet.Id = "Net_ATS_" + centralId; return(emptyNet); } } // Por acceso indirecto, el prefijo PP // se comporta como un abonado con marcación else if (prefix == Cd40Cfg.PP_DST) { TlfNet net = new TlfNet(); Rs <GwTlfRs> rs = null; net.Id = "Net_" + "SEGURIDAD"; //Busca el equipo que le da servicio, pasarela o proxy string rsIp = GetGwRsIp(number, out idEquipo); if (idEquipo != null) { rs = Top.Registry.GetRs <GwTlfRs>(number); } if (rs == null) { //o nuestro proxy si es un teléfono IP no configurado if ((rsIp == null) || (idEquipo == null)) { rsIp = GetProxyIp(out idEquipo); rs = Top.Registry.GetRs <GwTlfRs>(idEquipo); } _Logger.Warn("Number not found in configurated resources {0}, use {1} instead", number, idEquipo); } //rs.Reset(null, new GwTlfRs()); if (rs != null) { _Logger.Debug("Resource found for {0}: {1}", number, rs.Id); SipLine line = new SipLine(rs, rsIp); net.Lines.Add(line); net.Routes.Add(0); net.RsTypes.Add(new RsIdxType(net.Lines.Count - 1, 0, TipoInterface.TI_BL)); } else { _Logger.Error("{0} not found in conf resources {0} and proxy not found either.", number, idEquipo); } return(net); } else if (prefix == Cd40Cfg.UNKNOWN_DST) //Destinos entrantes que no están configurados { TlfNet net = new TlfNet(); net.Id = "Net_" + "SEGURIDAD"; string rsIp = GetProxyIp(out idEquipo); if (rsIp != null) { Rs <GwTlfRs> rs = Top.Registry.GetRs <GwTlfRs>(idEquipo); GwTlfRs proxyRs = new GwTlfRs(); proxyRs.GwIp = rsIp; rs.Reset(null, proxyRs); SipLine line = new SipLine(rs, rsIp); net.Lines.Add(line); net.Routes.Add(0); net.RsTypes.Add(new RsIdxType(net.Lines.Count - 1, 0, TipoInterface.TI_BL)); return(net); } } else if (prefix == Cd40Cfg.IP_DST) { TlfNet net = new TlfNet(); net.Id = "Net_" + "SEGURIDAD"; string rsIp = GetProxyIp(out idEquipo); if (rsIp != null) { Rs <GwTlfRs> rs = Top.Registry.GetRs <GwTlfRs>(idEquipo); GwTlfRs proxyRs = new GwTlfRs(); proxyRs.GwIp = rsIp; rs.Reset(null, proxyRs); SipLine line = new SipLine(rs, rsIp); net.Lines.Add(line); net.Routes.Add(0); net.RsTypes.Add(new RsIdxType(net.Lines.Count - 1, 0, TipoInterface.TI_BL)); return(net); } } else { foreach (ListaRedes red in _SystemCfg.PlanRedes) { if (red.Prefijo == prefix) { TlfNet net = new TlfNet(); net.Id = "Net_" + red.IdRed; foreach (PlanRecursos recurso in red.ListaRecursos) { string rsIp; Rs <GwTlfRs> rs = Top.Registry.GetRs <GwTlfRs>(recurso.IdRecurso); rsIp = GetGwRsIp(recurso.IdRecurso, out idEquipo); SipLine line = new SipLine(rs, rsIp); net.Lines.Add(line); net.RsTypes.Add(new RsIdxType(net.Lines.Count - 1, altRoute != null ? 1000 : 0, TipoInterface.TI_AB)); // Si altRoute es distinto de null es que estamos obteniendo la red // de salida alternativa para un numero ATS. Esta red sólo se tiene // que usar cuando no podemos salir por la propia red ATS, por eso // ponemos un valor elevado de ruta de modo que se coja en GetDetourPath net.Routes.Add(altRoute != null ? 1000 : 0); } return(net); } } } return(null); }