Package de.maramuse.soundcomp.process

Examples of de.maramuse.soundcomp.process.SourceStore


  if(connectionIndex!=StandardParameters.IN.i&&connectionIndex!=StandardParameters.IN_IMAG.i)
    throw new UnknownConnectionException("attempt to set invalid calculation parameter");
  if(!source.getSourceTypes().containsKey(sourceIndex))
    throw new UnknownConnectionException("attempt to set invalid calculation parameter source");
  if(connectionIndex==StandardParameters.IN.i){
    in1=new SourceStore(source, sourceIndex);
    sourceMap.put(StandardParameters.IN.i, in1);
  }else{
    in2=new SourceStore(source, sourceIndex);
    sourceMap.put(StandardParameters.IN_IMAG.i, in2);
  }
  }
View Full Code Here


  }

  @Override
  public void setSource(int connectionIndex, NamedSource source, int sourceIndex)
    throws UnknownConnectionException, TypeMismatchException {
  src=new SourceStore(source, sourceIndex);
  sourceMap.clear();
  sourceMap.put(StandardParameters.OUT.i, src);
  }
View Full Code Here

            int sourceIndex) throws UnknownConnectionException,
      TypeMismatchException {
  if(!source.getSourceTypes().containsKey(sourceIndex))
    throw new UnknownConnectionException("attempt to set invalid source for PseudoHilbert");
  if(connectionIndex==StandardParameters.IN.i){
    sourceStoreMap.put(connectionIndex, new SourceStore(source, sourceIndex));
    nsetSource(nativeSpace, connectionIndex, source.getNativeSpace(), sourceIndex);
  }else
    throw new UnknownConnectionException("attempt to set unkown parameter for PseudoHilbert");
  }
View Full Code Here

      TypeMismatchException {
  if(connectionIndex!=StandardParameters.IN.i)
    throw new UnknownConnectionException("attempt to set unknown parameter for PinkFilter");
  if(!source.getSourceTypes().containsKey(sourceIndex))
    throw new UnknownConnectionException("attempt to set invalid input for PinkFilter");
  this.source=new SourceStore(source, sourceIndex);
  sourceStoreMap.put(StandardParameters.IN.i, this.source);
  }
View Full Code Here

  public void setSource(int connection, NamedSource source,
            int sourceIndex) throws UnknownConnectionException,
      TypeMismatchException {
  if(!source.getSourceTypes().containsKey(sourceIndex))
    throw new UnknownConnectionException("attempt to set invalid StateVariablefilter source");
  sourceStoreMap.put(connection, new SourceStore(source, sourceIndex));
  if(connection==StandardParameters.Q.i){
    qSource=source;
    qSourceIndex=sourceIndex;
  }else if(connection==StandardParameters.FREQUENCY.i){
    freqSource=source;
View Full Code Here

    Variable v=new Variable();
    v.setAbstractName(val.getText());
    containedVariables.put(val.getText(), v);
    subs.put(val.getText(), v);
    usedNames.add(val.getText());
    SourceStore sst=getAsSource(val.inner.get(0));
    v.setSource(0, sst.source, sst.sourceIndex);
  }
  /*
   * make all internal elements known to the internal accounting these may be process references and in the future
   * also inner process definitions
   */
  if(subprocesses!=null)
  for(ParserVal val:subprocesses.inner){
    NamedSource el;
    if(usedNames.contains(val.getText()))
    throw new IllegalArgumentException("Process "+name+" contains repeated element name "
      +val.getText());
    if(val instanceof ProcessRef){
    ProcessRef r=((ProcessRef)val);
    // TODO find the corresponding process, if it is not a primitive. Should be done during parsing?
    if(r.process==null){
      if(r.localName==null)
        throw new IllegalStateException("no process set for anonymous reference");
      throw new IllegalStateException("no process set for reference "+r.localName);
    }
    el=r.process.createTemplate();
    usedNames.add(r.localName);
    subprocessMap.put(val.getText(), (Process)el);
    subrefMap.put(val.getText(), r);
    subs.put(val.getText(), el);
    break; // do not insert it into subprocess map
    }
    // TODO: allow inner process definitions
    throw new IllegalArgumentException("Element "+val.getText()+" contained in element "
      +getText()
      +" is not of suitable type (must be process reference) in "+filename+", line "+line);
  }
  // TODO: now that we know all sub elements, iterate once again over them, and connect
  // their inputs. All connection counterparts, except for formulas, must be available now.
  // For formulas, anonymous subprocesses must be created on the fly and
  // get their inputs directly fed.
  for(String ename:subs.keySet()){
    // iterate over all subprocesses and subprocess references and connect their inputs
    NamedSource val=subs.get(ename);
    if(val instanceof ProcessRef){
     ProcessRef r=(ProcessRef)val;
     Process p=subprocessMap.get(r.localName);
     if(r.getInputAssignments()!=null)
        for(InputAssignment i:r.getInputAssignments().getAssignments()){
      // now for each input of the subprocess, check if there is an assignment
        if(i.getInputName()==null||i.getInputName().length()==0)
        continue;
      // first, get the destination index to which to connect to
      Parameter dest=p.namedInputs.get(i.getInputName());
      // then for each assignment, check if there is an input, and set the connection
      if(i.getFormula()==null){
        // this input of the sub element stays open, so ignore it
      }else{
        SourceStore sst=getAsSource(i.getFormula());
        p.setSource(dest.i, sst.source, sst.sourceIndex);
      }
        }
     }else if(val instanceof Process){
     throw new IllegalArgumentException("Found process "+val.getAbstractName()+" where a processreference was expected - nested process definitions not yet implemented");
     }else
    // don't expect that here.
     throw new IllegalArgumentException("Found symbol "+val.getAbstractName()+" where a processreference was expected");
   }
  // connect all variables to their value sources
  if(variables!=null)
  for(ParserVal val:variables.inner){
    Variable v=containedVariables.get(val.getText());
    SourceStore sst=getAsSource(val.inner.get(0));
    v.setSource(0, sst.source, sst.sourceIndex);
  }
  // after all internal elements are connected, fix the connections of the outputs.
  // here also, create anonymous subprocesses if applicable.
  for(ParserVal val:outputs.inner){
View Full Code Here

   */
  private SourceStore getAsSource(ParserVal val) throws UnknownConnectionException,
    TypeMismatchException {
  if(val instanceof FormulaElement){
    // nested formula
    return new SourceStore(createTemplateFormula((FormulaElement)val), StandardParameters.OUT.i);
  }
  if(val instanceof ConnectionPoint){
    // named process element output, look in tables
    ConnectionPoint cp=(ConnectionPoint)val;
    if(subs.containsKey(cp.getElementName())){
    NamedSource src=subs.get(cp.getElementName());
    Parameter param=src.outputsByName().get(cp.getConnectionName());
    if(param==null)
      throw new IllegalArgumentException(MessageFormat.format(
        "Element {0} does not have output {1} in {2}", cp.getElementName(),
        cp.getConnectionName(), cp.getLocationText()));
    return new SourceStore(src, param.i);
    }
    throw new UnknownConnectionException("Element "+cp.getElementName()+" in "+name.getText()
      +" not known in "
      +val.filename+" line "+val.line);
  }
  if(val instanceof NamelessSource){
    // a data source that has a stream whose name need not be given. NamelessSources by contract always
    // are NamedSources that connect to OUT
    // NamedSource src=subs.get(val);
    // return new SourceStore(src, StandardParameters.OUT.i);
  }
  if(val instanceof Element){
    // a single name appearing in a formula must refer to an interface input or a process variable
    String elementName=val.getText();
    Parameter param=inputsByName().get(elementName);
    if(param!=null){
    return getInputProxy(elementName);
    }
    Variable v=containedVariables.get(elementName);
    if(v != null){
    return new SourceStore(v, StandardParameters.OUT.i);
    }
    throw new UnknownConnectionException("Input "+elementName+" in "+name.getText()
      +" not known in "
      +val.filename+" line "+val.line);
  }
  if(val instanceof Connection){
    // TODO how to handle?
    Connection c=(Connection)val;
    @SuppressWarnings("unused")
    ConnectionPoint cp=c.source;

    throw new UnknownConnectionException("Connection "+c.getEndpoint()+" in "+name.getText()
      +" not known in "
      +val.filename+" line "+val.line);
  }
  if(val instanceof NamelessSource && val instanceof TemplateProvider){
    return new SourceStore(((TemplateProvider)val).getTemplate().clone(), StandardParameters.OUT.i);
  }
  if(val instanceof ConnectionPoint){
    // can this legally happen?
    ConnectionPoint cp=(ConnectionPoint)val;
    throw new UnknownConnectionException("ConnectionPoint "+
View Full Code Here

  el=((TemplateProvider)val).getTemplate().clone();
  // FormulaElements always are ParserVal-s
  el.setAbstractName(((ParserVal)val).getText());
  if(val instanceof FormulaElement3){
    ParserVal v3=((FormulaElement3)val).getInput3Val();
    SourceStore el3=getAsSource(v3);
    el.setSource(StandardParameters.IN.i, el3.source, el3.sourceIndex);
  }
  if(val instanceof FormulaElement2){
    ParserVal v2=((FormulaElement2)val).getInput2Val();
    SourceStore el2=getAsSource(v2);
    el.setSource(StandardParameters.IN.i, el2.source, el2.sourceIndex);
  }
  if(val instanceof FormulaElement1){
    ParserVal v1=((FormulaElement1)val).getInput1Val();
    SourceStore el1=getAsSource(v1);
    el.setSource(StandardParameters.IN.i, el1.source, el1.sourceIndex);
  }
  return el;
  }
View Full Code Here

    throw new UnknownConnectionException("Could not determine type of "+source.getAbstractName()
      +" output "+sourceIndex);
  if(!sourceType.equals(destType))
    throw new UnknownConnectionException("Connection end types "+name+"/"+connectionIndex+" and "
      +source.getAbstractName()+"/"+sourceIndex+" do not match");
  destinationMap.put(connectionIndex, new SourceStore(source, sourceIndex));
  }
View Full Code Here

    // take care of that here instead of taking Double.NaN.
    if(param==null){
      store.source=ConstStream.c(Double.NaN);
      return Double.NaN;
    }
    SourceStore _store=sourceMap.get(param.i);
    store.sourceIndex=_store.sourceIndex;
    store.source=_store.source;
    }
    return store.getValue();
  }
View Full Code Here

TOP

Related Classes of de.maramuse.soundcomp.process.SourceStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.