summaryrefslogtreecommitdiffstats
path: root/templates/machine/qemux86-64/test/hwtest.short.environment
blob: 779e1b4e03838814af52648872a8fb04e1e7610f (plain)
1
2
3
4
5
6
7
8
9
10
DEVICE_ARCH=x86_64
DEVICE_TYPE=qemu
DEVICE_NAME=qemux86-64
DEVICE_DTB=
DEVICE_KERNEL=bzImage
DEVICE_INITRAMFS=agl-demo-platform-qemux86-64.ext4.xz
DEVICE_INITRAMFS_COMPRESSION=xz
DEVICE_BOOT_METHOD=qemu
DEVICE_QEMU_ARGS='"-cpu Nehalem,check=false -soundhw hda"'
DEVICE_KERNEL_CMDLINE='"console=ttyS0,115200 root=/dev/hda debug verbose"'
.ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
var afbVshlCore;
var ws;
var evtIdx = 0;
var count = 0;
//**********************************************
// Logger
//**********************************************
var log = {
  command: function (url, api, verb, query) {
    console.log("subscribe api=" + api + " verb=" + verb + " query=", query);
    var question = url + "/" + api + "/" + verb + "?query=" + JSON.stringify(query);
    log._write("question", count + ": " + log.syntaxHighlight(question));
  },

  event: function (obj) {
    console.log("gotevent:" + JSON.stringify(obj));
    log._write("outevt", (evtIdx++) + ": " + JSON.stringify(obj));
  },

  reply: function (obj) {
    console.log("replyok:" + JSON.stringify(obj));
    log._write("output", count + ": OK: " + log.syntaxHighlight(obj));
  },

  error: function (obj) {
    console.log("replyerr:" + JSON.stringify(obj));
    log._write("output", count + ": ERROR: " + log.syntaxHighlight(obj));
  },

  _write: function (element, msg) {
    var el = document.getElementById(element);
    el.innerHTML += msg + '\n';

    // auto scroll down
    setTimeout(function () {
      el.scrollTop = el.scrollHeight;
    }, 100);
  },

  syntaxHighlight: function (json) {
    if (typeof json !== 'string') {
      json = JSON.stringify(json, undefined, 2);
    }
    json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
    return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
      var cls = 'number';
      if (/^"/.test(match)) {
        if (/:$/.test(match)) {
          cls = 'key';
        } else {
          cls = 'string';
        }
      } else if (/true|false/.test(match)) {
        cls = 'boolean';
      } else if (/null/.test(match)) {
        cls = 'null';
      }
      return '<span class="' + cls + '">' + match + '</span>';
    });
  },
};

//**********************************************
// Generic function to call binder
//***********************************************
function callbinder(url, api, verb, query) {
  log.command(url, api, verb, query);

  // ws.call return a Promise
  return ws.call(api + '/' + verb, query)
    .then(function (res) {
      log.reply(res);
      count++;
      return res;
    })
    .catch(function (err) {
      log.reply(err);
      count++;
      throw err;
    });
};


//**********************************************
// connect - establish Websocket connection
//**********************************************
function connect(elemID, api, verb, query) {
  connectVshlCore(elemID, api, verb, query);
}

function connectVshlCore(elemID, api, verb, query) {

  function onopen() {
    document.getElementById("main").style.visibility = "visible";
    document.getElementById("connected").innerHTML = "Binder WS Active";
    document.getElementById("connected").style.background = "lightgreen";
    ws.onevent("*", log.event);
    // Fetch and render voice agents.
    fetchAndRenderVoiceAgents();
  }

  function onabort() {
    document.getElementById("main").style.visibility = "hidden";
    document.getElementById("connected").innerHTML = "Connected Closed";
    document.getElementById("connected").style.background = "red";
  }

  var urlparams = {
    base: "api",
    token: "HELLO",
  };
  const vshlCoreAddressInput = document.getElementById('vshl-core-address');
  urlparams.host = vshlCoreAddressInput.value;

  afbVshlCore = new AFB(urlparams, "HELLO");
  ws = new afbVshlCore.ws(onopen, onabort);
}

function clearPre(preId) {
  const pre = document.getElementById(preId);
  while (pre && pre.firstChild) {
    pre.removeChild(pre.firstChild);
  }
}

function fetchAndRenderVoiceAgents() {
  const agentsDiv = document.getElementById('agentsDiv');
  while (agentsDiv.firstChild) {
    agentsDiv.removeChild(agentsDiv.firstChild);
  }

  const api = 'vshl-core';
  const verb = 'enumerateVoiceAgents';
  const query = {};

  log.command(afbVshlCore.url, api, verb, query);

  return ws.call(api + '/' + verb, query)
    .then(function (res) {
      log.reply(res);
      for (let index = 0; index < res.response.agents.length; ++index) {
        let voiceAgent = res.response.agents[index];
        addVoiceAgent(agentsDiv, voiceAgent, res.response.default == voiceAgent.id);
      }
    })
    .catch(function (err) {
      log.reply(err);
      console.log(JSON.stringify(err));
    });
}

function addVoiceAgent(containerDiv, voiceAgent, isDefault) {
  const agentDiv = document.createElement("div");

  const agentName = document.createElement("h2");
  agentName.innerHTML = voiceAgent.name;
  agentDiv.appendChild(agentName);

  const agentDescription = document.createElement("p");
  agentDescription.innerHTML = voiceAgent.description;
  agentDiv.appendChild(agentDescription);

  if (!isDefault) {
    const setDefaultBtn = document.createElement("button");
    setDefaultBtn.addEventListener('click', (evt) => {
      const query = {"id": voiceAgent.id};
      callbinder(afbVshlCore.url, 'vshl-core', 'setDefaultVoiceAgent', query);
      fetchAndRenderVoiceAgents();
    });
    setDefaultBtn.innerHTML = 'SetDefault';
    agentDiv.appendChild(setDefaultBtn);
  }

  const subscribeBtn = document.createElement("button");
  subscribeBtn.addEventListener('click', (evt) => {
    showAgentEventChooserDialog(voiceAgent.id);
  });
  subscribeBtn.innerHTML = 'Subscribe';
  agentDiv.appendChild(subscribeBtn);

  containerDiv.appendChild(agentDiv);
}

function showAgentEventChooserDialog(voiceAgentId) {
  const modal = document.getElementById('agent-event-chooser');
  const subscribeBtn = document.getElementById('agent-subscribe-btn');

  subscribeBtn.addEventListener('click', (evt) => {
    const authState = document.getElementById('authstate').checked;
    const dialogState = document.getElementById('dialogstate').checked;
    const connectionState = document.getElementById('connectionstate').checked;

    const query = {
      "va_id": voiceAgentId,
      "events":[]
    };
    if (authState)
      query.events.push('voice_authstate_event');
    if (dialogState)
      query.events.push('voice_dialogstate_event');
    if (connectionState)
      query.events.push('voice_connectionstate_event');

    callbinder(afbVshlCore.url, 'vshl-core', 'subscribe', query);
    modal.close();
  });

  // makes modal appear (adds `open` attribute)
  modal.showModal();
}

function startListening() {
    callbinder(afbVshlCore.url, 'vshl-core', 'startListening', {});  
}