void SCVdepSource::GetAuxEquations ( JPtrArray<JString>* lhsList, JPtrArray<JString>* rhsList, JPtrArray<JString>* varList ) const { SCDepSource::GetAuxEquations(lhsList, rhsList, varList); SCCircuit* theCircuit = GetCircuit(); JString* lhs = new JString(GetValueSymbol()); assert( lhs != NULL ); lhsList->Append(lhs); JString* rhs = new JString("("); assert( rhs != NULL ); *rhs += GetCoeffSymbol(); *rhs += ") * ("; *rhs += theCircuit->GetNodeName(itsPosDepNode); *rhs += " - "; *rhs += theCircuit->GetNodeName(itsNegDepNode); *rhs += ")"; rhsList->Append(rhs); }
SCVdepSource::SCVdepSource ( const SCVdepSource& source, SCCircuit* theCircuit, const JArray<JIndex>* nodeMap, const JString& coeffSymbol ) : SCDepSource(source, theCircuit, nodeMap, coeffSymbol) { if (nodeMap != NULL) { itsPosDepNode = nodeMap->GetElement(source.itsPosDepNode); itsNegDepNode = nodeMap->GetElement(source.itsNegDepNode); } else { itsPosDepNode = source.itsPosDepNode; itsNegDepNode = source.itsNegDepNode; } assert( theCircuit->NodeIndexValid(itsPosDepNode) ); assert( theCircuit->NodeIndexValid(itsNegDepNode) ); ListenTo(GetCircuit()->GetNodeList()); }
SCLinearComp::SCLinearComp ( const SCLinearComp& source, SCCircuit* theCircuit, const JArray<JIndex>* nodeMap ) : SCComponent(source, theCircuit, nodeMap) { itsValueSymbol = new JString(*(source.itsValueSymbol)); assert( itsValueSymbol != NULL ); itsCurrentSymbol = new JString(*(source.itsCurrentSymbol)); assert( itsCurrentSymbol != NULL ); if (nodeMap != NULL) { itsPosNode = nodeMap->GetElement(source.itsPosNode); itsNegNode = nodeMap->GetElement(source.itsNegNode); } else { itsPosNode = source.itsPosNode; itsNegNode = source.itsNegNode; } assert( theCircuit->NodeIndexValid(itsPosNode) ); assert( theCircuit->NodeIndexValid(itsNegNode) ); ListenTo((GetCircuit())->GetNodeList()); }
void SCVdepVSource::GetAuxEquations ( JPtrArray<JString>* lhsList, JPtrArray<JString>* rhsList, JPtrArray<JString>* varList ) const { SCVdepSource::GetAuxEquations(lhsList, rhsList, varList); SCCircuit* theCircuit = GetCircuit(); JString* lhs = new JString; assert( lhs != NULL ); *lhs = theCircuit->GetNodeName(GetPositiveNode()); *lhs += " - "; *lhs += theCircuit->GetNodeName(GetNegativeNode()); lhsList->Append(lhs); JString* rhs = new JString(GetValueSymbol()); assert( rhs != NULL ); rhsList->Append(rhs); JString* var = new JString(GetValueSymbol()); assert( var != NULL ); varList->Append(var); }
void SCLinearComp::SCLinearCompX() { itsValueSymbol = new JString; assert( itsValueSymbol != NULL ); itsCurrentSymbol = new JString; assert( itsCurrentSymbol != NULL ); ListenTo((GetCircuit())->GetNodeList()); }
void SCVdepSource::Receive ( JBroadcaster* sender, const Message& message ) { JCollection* nodeList = GetCircuit()->GetNodeList(); if (sender == nodeList && message.Is(JOrderedSetT::kElementsInserted)) { const JOrderedSetT::ElementsInserted* info = dynamic_cast<const JOrderedSetT::ElementsInserted*>(&message); assert( info != NULL ); info->AdjustIndex(&itsPosDepNode); info->AdjustIndex(&itsNegDepNode); } else if (sender == nodeList && message.Is(JOrderedSetT::kElementsRemoved)) { if (!nodeList->IsEmpty()) { const JOrderedSetT::ElementsRemoved* info = dynamic_cast<const JOrderedSetT::ElementsRemoved*>(&message); assert( info != NULL ); const JBoolean posOK = info->AdjustIndex(&itsPosDepNode); assert( posOK ); const JBoolean negOK = info->AdjustIndex(&itsNegDepNode); assert( negOK ); } } else if (sender == nodeList && message.Is(JOrderedSetT::kElementMoved)) { const JOrderedSetT::ElementMoved* info = dynamic_cast<const JOrderedSetT::ElementMoved*>(&message); assert( info != NULL ); info->AdjustIndex(&itsPosDepNode); info->AdjustIndex(&itsNegDepNode); } else if (sender == nodeList && message.Is(JOrderedSetT::kElementsSwapped)) { const JOrderedSetT::ElementsSwapped* info = dynamic_cast<const JOrderedSetT::ElementsSwapped*>(&message); assert( info != NULL ); info->AdjustIndex(&itsPosDepNode); info->AdjustIndex(&itsNegDepNode); } SCDepSource::Receive(sender, message); }
void SCLinearComp::PrintToNetlist ( ostream& output ) const { SCCircuit* theCircuit = GetCircuit(); SCComponent::PrintToNetlist(output); output << '\t' << theCircuit->GetNodeIndexForNetlist(itsPosNode); output << '\t' << theCircuit->GetNodeIndexForNetlist(itsNegNode); }
void SCVdepSource::PrintToNetlist ( std::ostream& output ) const { SCCircuit* theCircuit = GetCircuit(); SCDepSource::PrintToNetlist(output); output << '\t' << theCircuit->GetNodeIndexForNetlist(itsPosDepNode); output << '\t' << theCircuit->GetNodeIndexForNetlist(itsNegDepNode); output << '\t' << GetCoeffValue(); }
void SCLinearComp::Receive ( JBroadcaster* sender, const Message& message ) { JCollection* nodeList = (GetCircuit())->GetNodeList(); if (sender == nodeList && message.Is(JOrderedSetT::kElementsInserted)) { const JOrderedSetT::ElementsInserted* info = dynamic_cast(const JOrderedSetT::ElementsInserted*, &message); assert( info != NULL ); info->AdjustIndex(&itsPosNode); info->AdjustIndex(&itsNegNode); } else if (sender == nodeList && message.Is(JOrderedSetT::kElementsRemoved))
void SCXferFnDirector::EvaluateTransferFunction() { if (!itsXferFn->EndEditing()) { return; } else if (itsXferFn->ContainsUIF()) { (JGetUserNotification())->ReportError("Please finish entering the function."); itsXferFn->Focus(); return; } (GetCircuitDocument())->DataModified(); itsResult->ClearFunction(); const SCCircuit* circuit = GetCircuit(); if (!circuit->IsLinear()) { (JGetUserNotification())->ReportError("The circuit is not linear."); return; } const SCCircuitVarList* varList = GetVarList(); const JFunction* fn = itsXferFn->GetFunction(); const JString textFn = (SCGetSymbolicMath())->Print(*fn); JString result; JFunction* f; if (circuit->Evaluate(textFn, &result) && JParseFunction(result, varList, &f)) { itsResult->SetFunction(varList, f); } }
void SCVdepSource::SCVdepSourceX() { ListenTo(GetCircuit()->GetNodeList()); }
void SCFeedbackDirector::EvaluateFeedbackParameters() { if (!itsOutputFn->EndEditing()) { return; } else if (itsOutputFn->ContainsUIF()) { (JGetUserNotification())->ReportError("Please finish entering the output function."); itsOutputFn->Focus(); return; } (GetCircuitDocument())->DataModified(); itsH0->ClearFunction(); itsHinf->ClearFunction(); itsT->ClearFunction(); itsTn->ClearFunction(); itsScratchFn->ClearFunction(); const SCCircuit* circuit = GetCircuit(); if (!circuit->IsLinear()) { (JGetUserNotification())->ReportError("The circuit is not linear."); return; } JIndex indepSourceIndex; if (!itsInputSource->GetCompIndex(&indepSourceIndex)) { (JGetUserNotification())->ReportError( "There are no independent sources in this circuit."); return; } JIndex depSourceIndex; if (!itsDepSource->GetCompIndex(&depSourceIndex)) { (JGetUserNotification())->ReportError( "There are no dependent sources in this circuit."); return; } const SCCircuitVarList* varList = GetVarList(); const JFunction* fn = itsOutputFn->GetFunction(); const JString textFn = (SCGetSymbolicMath())->Print(*fn); JString H0, Hinf, T, Tn; if (!circuit->GetFeedbackParameters(indepSourceIndex, textFn, depSourceIndex, &H0, &Hinf, &T, &Tn)) { return; } JFunction* f; if (JParseFunction(H0, varList, &f)) { itsH0->SetFunction(varList, f); } if (JParseFunction(Hinf, varList, &f)) { itsHinf->SetFunction(varList, f); } if (JParseFunction(T, varList, &f)) { itsT->SetFunction(varList, f); } if (JParseFunction(Tn, varList, &f)) { itsTn->SetFunction(varList, f); } }